views:

305

answers:

6

Hi,

I'm rendering millions of tiles which will be displayed as an overlay on Google Maps. The files are created by GMapCreator from the Centre for Advanced Spatial Analysis at University College London. The application renders files in to a single folder at a time, in some cases I need to create about 4.2 million tiles. Im running it on Windows XP using an NTFS filesystem, the disk is 500GB and was formatted using the default operating system options.

I'm finding the rendering of tiles gets slower and slower as the number of rendered tiles increases. I have also seen that if I try to look at the folders in Windows Explorer or using the Command line then the whole machine effectively locks up for a number of minutes before it recovers enough to do something again.

I've been splitting the input shapefiles into smaller pieces, running on different machines and so on, but the issue is still causing me considerable pain. I wondered if the cluster size on my disk might be hindering the thing or whether I should look at using another file system altogether. Does anyone have any ideas how I might be able to overcome this issue?

Thanks,

Barry.

Update:

Thanks to everyone for the suggestions. The eventual solution involved writing piece of code which monitored the GMapCreator output folder, moving files into a directory heirarchy based upon their filenames; so a file named abcdefg.gif would be moved into \a\b\c\d\e\f\g.gif. Running this at the same time as GMapCreator overcame the filesystem performance problems. The hint about the generation of DOS 8.3 filenames was also very useful - as noted below I was amazed how much of a difference this made. Cheers :-)

A: 

You could try an SSD....

http://www.crucial.com/promo/index.aspx?prog=ssd

UpTheCreek
A: 

For XP try this tip:
How to Turn Off Image Preview Thumbnail and Disable Windows Picture and Fax Viewer in Windows XP

On Windows Server 2008 :
Preview thumbnails in Windows Explorer

lsalamon
I don't think this is the issue, as his problem persists even when listing files from the command line.
snicker
really, but my suggestion may help just as a configurable option that aids in performance.
lsalamon
+1  A: 

Use more folders and limit the number of entries in any given folder. The time to enumerate the number of entries in a directory goes up (exponentially? I'm not sure about that) with the number of entries, and if you have millions of small files in the same directory, even doing something like dir folder_with_millions_of_files can take minutes. Switching to another FS or OS will not solve the problem---Linux has the same behavior, last time I checked.

Find a way to group the images into subfolders of no more than a few hundred files each. Make the directory tree as deep as it needs to be in order to support this.

JSBangs
Thanks for the insight into Linux - I was wondering about that. Part of my pain is caused by the fact that the GMapCreator program only outputs to one folder at a time; I have no way to make it use a folder heirarchy. Your answer got me wondering if I could perhaps setup another process which moves the files out into folders as you suggest.
Elliveny
A: 

The solution is most likely to restrict the number of files per directory.

I had a very similar problem with financial data held in ~200,000 flat files. We solved it by storing the files in directories based on their name. e.g.

gbp97m.xls

was stored in

g/b/p97m.xls

This works fine provided your files are named appropriately (we had a spread of characters to work with). So the resulting tree of directories and files wasn't optimal in terms of distribution, but it worked well enough to reduced each directory to 100s of files and free the disk bottleneck.

Brian Agnew
Downvoted why ?
Brian Agnew
+2  A: 

There are several things you could/should do

  • Disable automatic NTFS short file name generation (google it)
  • Or restrict file names to use 8.3 pattern (e.g. i0000001.jpg, ...)

  • In any case try making the first six characters of the filename as unique/different as possible

  • If you use the same folder over and (say adding file, removing file, readding files, ...)

    • Use contig to keep the index file of the directory as less fragmented as possible (check this for explanation)
    • Especially when removing many files consider using the folder remove trick to reduce the direcotry index file size
  • As already posted consider splitting up the files in multiple directories.

.e.g. instead of

directory/abc.jpg
directory/acc.jpg
directory/acd.jpg
directory/adc.jpg
directory/aec.jpg

use

directory/b/c/abc.jpg
directory/c/c/acc.jpg
directory/c/d/acd.jpg
directory/d/c/adc.jpg
directory/e/c/aec.jpg
jitter
Oh my.. I am amazed how much difference that disabling the 'automatic NTFS short file name generation' suggestion has made - a complete world of difference! Thanks for this. My data is all in the UK and so the filenames all begin with the same 9 or 10 letters, based upon the Google maps naming requirements, and so the short filename generation was obviously a HUGE overhead.
Elliveny
Did you consider to accept the answer?
jitter
Yes I did - sorry it took me a while to get there! Thanks for your very useful checklist.
Elliveny
A: 

One solution is to implement haystacks. This is what Facebook does for photos, as the meta-data and random-reads required to fetch a file is quite high, and offers no value for a data store.

Haystack presents a generic HTTP-based object store containing needles that map to stored opaque objects. Storing photos as needles in the haystack eliminates the metadata overhead by aggregating hundreds of thousands of images in a single haystack store file. This keeps the metadata overhead very small and allows us to store each needle’s location in the store file in an in-memory index. This allows retrieval of an image’s data in a minimal number of I/O operations, eliminating all unnecessary metadata overhead.

brianegge
Nice! I implemented something similar to Haystack. Is Haystack Open Source? http://github.com/fictorial/logstore
z8000