NSFileWrapper/NSDocument package saving performance trouble

  • 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
previous month june 2012 next month
MTWTFSS
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30  
Go to today