On 30 Jan 2013, at 15:53, Thomas Zoechling <thomas.zoechl...@gmx.at> wrote:

> Hello,
> 
> My NSDocument based app uses packages with the following structure:
> 
> - document.package
> +- metadata.plist (small, mutable)
> +- large0.file (large, immutable)
> +- large1.file (large, immutable)
> +- large2.file (large, immutable)
> 
> While the metadata.plist file can change any time, all large files are 
> created once and then stay as they are.
> As my "large0-2" files can be several gigabytes, I try to carefully avoid 
> unnecessary IO by using document packages with NSFileWrapper.
> My package reading/writing methods resemble the ones in the "Document Package 
> with iCloud" sample (But I don't use iCloud): 
> http://developer.apple.com/library/mac/#samplecode/PackagedDocument/ 
> I appended the relevant parts of my code at the end of this message.
> 
> With this setup, I was hoping that the occasions where the document 
> architecture has to copy the whole bundle are reduced to:
> - File duplication
> - Moves to another volume
> 
> But after investigating file activity with Instruments.app, it turned out 
> that my app is reading and writing chunks of my unmodified, immutable & large 
> files during each save.
> It seems that the copying is related to document revisions (a.k.a. Versions).
> Instruments logs hundreds of IO operations in the form of:
> #     Caller  Function        FD      Path    Bytes
> ...
> 70    copyfile        read    22      document.package/large0.file    1048576
> 71    copyfile        write   23      
> /.vol/16777218/2/.DocumentRevisions-V100/staging/adding.Wohcjo4i/4772FAAA-78D3-44A9-9412-A2D651B6EB5A.package/large0.file
>        1048576
> 70    copyfile        read    22      document.package/large0.file    1048576
> 71    copyfile        write   23      
> /.vol/16777218/2/.DocumentRevisions-V100/staging/adding.Wohcjo4i/4772FAAA-78D3-44A9-9412-A2D651B6EB5A.package/large0.file
>        1048576
> 70    copyfile        read    22      document.package/large0.file    1048576
> 71    copyfile        write   23      
> /.vol/16777218/2/.DocumentRevisions-V100/staging/adding.Wohcjo4i/4772FAAA-78D3-44A9-9412-A2D651B6EB5A.package/large0.file
>        1048576
> ...
> 
> How can I tell Versions that the only file that constantly changes within my 
> document.package is metadata.info? (Without turning off document revisions 
> altogether)
> I am targetting 10.8 (with sandboxing enabled) and also adopted async saving 
> and autosavesInPlace.

Given the right conditions, NSFileWrapper can make writing vastly more 
efficient by writing hard links for unchanged files, rather than recreating 
them afresh. Have you determined whether this is happening at all?

In my experience Versions tends to be pretty inefficient about its work. Are 
you seeing it block the main thread though? That can generally be avoided.


_______________________________________________

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