> On Jul 6, 2016, at 3:06 AM, Jonathan Taylor <jonathan.tay...@glasgow.ac.uk> 
> wrote:
> 
> I should also clarify that (in spite of my other email thread running in 
> parallel to this) I am not doing any complex encoding of the data being 
> streamed to disk - these are just basic TIFF images and metadata.

Since you said previously that you use -[NSData writeToFile:…], it sounds like 
you’re creating a lot of files with one image in each. This is going to incur a 
lot of extra overhead for updating filesystem metadata: creating a file is 
pretty heavyweight compared to writing to a file. This is partly because HFS 
has greater durability guarantees for the filesystem itself than for data 
within files, so changes to filesystem structures are more expensive to write. 
And there’s also the overhead of the kernel calls for opening and closing the 
file.

(You can see this for yourself by comparing how long it takes the Finder or “cp 
-R” to copy a single 1GB file, vs. 1000 1MB files.)

TL;DR: It will be a lot more efficient to write all of the images+metadata to a 
single file. You can make up your own file format by just prefixing each image 
with a byte count. Or you can get a library that knows how to write Zip files 
and use that. (I don’t mean gzip; I mean the .zip archive format that contains 
multiple files.)

—Jens
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to