NSFileWrapper/NSDocument package saving performance trouble
NSFileWrapper/NSDocument package saving performance trouble
- Subject: NSFileWrapper/NSDocument package saving performance trouble
- From: Markus Spoettl <email@hidden>
- Date: Sat, 09 Jun 2012 19:31:48 +0200
Hello,
I have an NSDocument based app that uses the NSFileWrapper based reading and
writing methods to save a package document file. Works fine in theory and with
small documents but when I put a lot of files in my package, saving is seriously
slow.
My understanding is that if one changes the contained file wrappers in the
package file wrapper to reflect changed content, but leave unchanged content
file's wrappers as they are, time required to save should be reduced greatly
(compared to writing everything all the time).
As an extreme example of a completely unchanged document, one could use the
original NSFileWrapper (received through -readFromFileWrapper:ofType:error:)
unchanged and return in in -fileWrapperOfType:error: when the NSDocument gets
saved through -saveDocument:.
That should get the maximum possible performance as nothing changed and leave
the resulting file as is.
I started out with this hierarchy within my package:
package
|- file
|- file
|- file
|- folder
|- 6400 files
Saving the unchanged file wrapper as outlined above takes whopping 67 seconds.
The package's total size is 840MB. In 67 seconds the package can be file-copied
to the same disk easily.
Suspecting that the number of files in just one folder could possibly be a
problem (I can only speculate on reasons, maybe a badly implemented index
somewhere?) I partitioned the folder content into 8 sub-folders holding about
800 files each:
package
|- file
|- file
|- file
|- folder (1x)
|- folder (8x)
|- 800 files
|- folder
|- 800 files
...
It improved performance by 40 seconds to 27 seconds. As a last experiment I
tried partitioning further, dividing the 800 files into 10 sub-folders with 80
files each.
package
|- file
|- file
|- file
|- folder (1x)
|- folder (8x)
|- folder (10x)
|- 80 files
|- folder
|- 80 files
...
|- folder
|- folder (10x)
|- 80 files
|- folder
|- 80 files
...
...
This gets saving down to 11 seconds for the same, unchanged document package
file wrapper.
This is still completely unacceptable (for my app anyway). I was expecting much
better results in the sub 5 seconds range for unchanged content.
At this point I'm hoping I'm doing something wrong, so I'd appreciate if someone
could tell me what it is. I'm using Lion 10.7.4 and base SDK 10.7, deployment
target is 10.6.
Regards
Markus
--
__________________________________________
Markus Spoettl
_______________________________________________
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