Monday, May 2, 2011

DotNetFish - Headed towards optimization land

Looks like its time to take a trip towards optimization land.

I knocked one of the items off of my list, which was adding some directionality into the path finding to help it out. Then I attempted to process a small pond. This didn't go so well, as it ground to a halt. The problem I was having is that during debug I was saving each image I was processing. 800 tiles produces 200,000 images in a single directory which was a major source of the slowdown.

After fixing this issue, I will still need to increase the performance. I don't want to spend 4-5 hours building the map of a small lake. So far, I have followed the advanced rule of optimization which states

Don't Optimize Yet

You see, I have not done much performance tuning up to this point, although I did optimize the actual process of processing the tile. I think its important to know when to optimize. I'm now to the point where I need to start processing larger maps, so it makes sense to address this issue now.  I could have made these changes earlier of course, since I understood where the bottleneck was occurring, but there were more important things to work on.

I may have touched on the optimizations that I need to perform, but what it comes down to is processing the edge tiles at the largest magnification, and processing everything else at a much smaller magnification.

Currently, I am processing each 256 tile at the largest zoom setting into  256 tiles. Each of those tiles is having its borders processed as well. A good first optimization would be to only break a tile down into smaller tiles if it actually has an edge on it. Add in zooming out a few levels, and the performance should increase several orders of magnitude.

Currently it took about 6-7 minutes to process 1200 tiles which was about 1000x1000 feet. Given that even a fairly small lake hear my house  is 52,800x 26,400, you can easily understand why this is so important.


On a final note:
After the second run, I had approximately a 4% failure rate. Now I have something to shoot towards beating.

No comments:

Post a Comment