• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSDocument packages and incremental writing using NSFileWrapper
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDocument packages and incremental writing using NSFileWrapper


  • Subject: Re: NSDocument packages and incremental writing using NSFileWrapper
  • From: Mike Abdullah <email@hidden>
  • Date: Mon, 04 Feb 2013 14:12:41 +0000

On 30 Jan 2013, at 15:53, Thomas Zoechling <email@hidden> 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 (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

  • Follow-Ups:
    • Re: NSDocument packages and incremental writing using NSFileWrapper
      • From: Thomas Zoechling <email@hidden>
References: 
 >NSDocument packages and incremental writing using NSFileWrapper (From: Thomas Zoechling <email@hidden>)

  • Prev by Date: Re: What's the difference between [NSOperationQueue currentQueue] and performSelectorOnMainThread (iOS platform)
  • Next by Date: Re: NSDocument's Open File Panel unresponsive when opening large file from disc
  • Previous by thread: NSDocument packages and incremental writing using NSFileWrapper
  • Next by thread: Re: NSDocument packages and incremental writing using NSFileWrapper
  • Index(es):
    • Date
    • Thread