Re: NSDocument packages and incremental writing using NSFileWrapper
Re: NSDocument packages and incremental writing using NSFileWrapper
- Subject: Re: NSDocument packages and incremental writing using NSFileWrapper
- From: Thomas Zoechling <email@hidden>
- Date: Wed, 06 Feb 2013 18:48:44 +0100
> If originalContentsURL is supplied, a directory wrapper checks its child wrappers against that directory. If a file exists there by the same name and with the same modification date, it gets hardlinked, rather than written out from scratch.
> Certainly as of 10.8, NSDocument cunningly makes use of the previous version of the document, rather than writing it out anew. But I believe Versions then copies that whole doc regardless.
> Versions has no knowledge of your file wrapper I suspect. You may well be into DTS incident territory looking for a way to speed this up.
After thinking about it, I also suspect Versions to be the culprit.
I will ask DTS about that issue.
Thanks,
Thomas
>
> On 5 Feb 2013, at 10:38, Thomas Zoechling <email@hidden> wrote:
>
>>
>> Thanks for your response,
>>> 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?
>> Currently I am trying to figure out what those conditions are :)
>
> If originalContentsURL is supplied, a directory wrapper checks its child wrappers against that directory. If a file exists there by the same name and with the same modification date, it gets hardlinked, rather than written out from scratch.
>>
>>> In my experience Versions tends to be pretty inefficient about its work.
>> I wonder what NSDocument's private _preserveContentsIfNecessaryAfterWriting (see above call stack) uses to determine whether a file has to be copied or not.
>
> Certainly as of 10.8, NSDocument cunningly makes use of the previous version of the document, rather than writing it out anew. But I believe Versions then copies that whole doc regardless.
>>
>>> Are you seeing it block the main thread though? That can generally be avoided.
>> No. Saving and Version preservation are off the main thread.
>> That's why I almost didn't notice the vast amount of copying that's going on after each save.
>>
>> My usage of NSDocument & file packages seems to be straightforward.
>> I didn't overwrite any of the write* methods, I keep a root file wrapper for the lifetime of each NSDocument instance, ...
>>
>> What am I doing wrong? There must be a way to avoid this unnecessary copying...
>
> Versions has no knowledge of your file wrapper I suspect. You may well be into DTS incident territory looking for a way to speed this up.
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden