Skip to content

Investigate if csync processing local diretories can be optimized #880

Closed

Description

@guruz

We're doing a opendir/readdir call but then also stat each of the contained files.

I'm guessing this is expensive.

We could optimize this. However the problem is that readdir does not return all needed information (e.g. mtime)

There is probably system calls that allow this though, for example FindFile on Windows (
http://msdn.microsoft.com/en-us/library/aa364418%28VS.85%29.aspx) or fts on Linux (http://linux.die.net/man/3/fts).

Should investigate if this is faster.

The relevant code is in csync_ftw in csync_update.c

Activity

  1. ghost assigned on Aug 17, 2013
  2. guruz commented on Aug 18, 2013

    @guruz
    ContributorAuthor

    Looks like on OS X and glibc the fts do stat internally too :( I had hoped they would do something more cool.

  3. guruz commented on Aug 18, 2013

    @guruz
    ContributorAuthor

    Work in progress patch for fts, doesn't improve performance: https://gist.github.com/guruz/6260817

    (benchmarked with 1000 files, local ownCloud and ./client/ocsync --test-update

  4. guruz commented on Aug 27, 2013

    @guruz
    ContributorAuthor

    I haven't investigated more here, but I still have hope that on Windows FindFile is faster because the Windows POSIX functions might not be implemented that well..

  5. shoeper commented on Nov 27, 2013

    @shoeper

    I think on windows there is another way. You can register your program to watch directories - owncloud gets notified by windows when there is a change then.
    http://msdn.microsoft.com/en-us/library/aa365465.aspx

    That should be much faster

  6. guruz commented on Nov 28, 2013

    @guruz
    ContributorAuthor

    Mirall is already watching directories, no worries :) https://github.com/owncloud/mirall/blob/master/src/mirall/folderwatcher_win.cpp

    This is about iterating which is currently needed for each sync.

  7. guruz commented on Feb 5, 2014

    @guruz
    ContributorAuthor

    Some more findings regarding Windows:
    We use a special call GetFileInformationByHandle (in csync_vio_local_stat) to get an inode (as on Windows, the inode is not retrieved via stat).
    However, we don't seem to be using the inode anymore for move dection. (as per f1b4a7a )
    But we use it somewhere else..

    EDIT: I was mistaken, it is still used for rename detection, just not for update detection.

  8. guruz commented on Feb 5, 2014

    @guruz
    ContributorAuthor

    The csync_vio_local_stat calls GetFileTime although GetFileInformationByHandle already can retrieve the time values.

  9. guruz commented on Feb 21, 2014

    @guruz
    ContributorAuthor

    I was able to optimize csync_vio_local_stat on Windows
    4630244

  10. modified the milestones: 1.6 - Performance Improvements, on Mar 26, 2014
  11. danimo commented on Mar 26, 2014

    @danimo
    Contributor

    @guruz Since you committed this, do you want to close the issue or keep investigating?

  12. guruz commented on Mar 26, 2014

    @guruz
    ContributorAuthor

    I'll move this 1.7 ..

  13. modified the milestones: , 1.6 - Performance Improvements on Mar 26, 2014
  14. 14 remaining items

  15. modified the milestones: , 2.0 - Multi-account on Jun 19, 2015
  16. modified the milestones: 2.0 - Multi-account, on Jul 5, 2015
  17. added a commit that references this issue on Jul 13, 2015
  18. guruz commented on Jul 13, 2015

    @guruz
    ContributorAuthor

    Update: @dragotin has switched the Windows code to use FindFirstFileW for 2.0. I'll try to do some optimizations based on this.

  19. modified the milestones: , 2.0 - Multi-account on Jul 27, 2015
  20. assigned and unassigned on Jul 27, 2015
  21. modified the milestones: , on Aug 31, 2015
  22. dragotin commented on Sep 28, 2015

    @dragotin
    Contributor

    This is done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions