Skip to content

Use change notifications instead of polling #29

Closed

Description

@RandolfCarter

As far as I can tell, current sync-client implementations (at least those on Windows and on Linux platform, which I could test) simply rescan the whole local sync directories in a fixed interval (10 seconds); and for remote changes, apparently even less often (it can take up to 1 minute that a client picks up a change on the server for me, even in the local network).

When synced directories become larger, it's quite a nuisance to have owncloud client basically continuously running (and using quite much CPU time every 10 seconds).

To showcase that, I created a simple test directory with approximately 3500 empty (0 byte!) files. Even with only these, one sync client run already takes aproximately 1,5 seconds - and CPU usage is at 15%, but that is with a Core i7-3770K! 3500 files is not that much yet, I don't want to imagine synchronizing 100K files!

My assumption is that the number of files is the determining factor for perfomance, not so much the size of the files (since if nothing changed the file content doesn't have to be checked), though I haven't verified that; but the sync proves to be quite demanding with a moderate number of empty files already.

Since every supported (desktop) platform provides interfaces for listening to file changes (e.g. iNotify on Linux, FindFirstChangeNotification on Windows, see e.g. here http://stackoverflow.com/questions/3517460/is-there-anything-like-inotify-on-windows - wouldn't it be the best solution if these were used?

When reacting on such events, no full sync would be necessary anymore, but just a propagation of that single event (e.g. uploading a created file, remote-deleting a locally deleted file).

Local changes and changes on the client seem to be handled differently at the moment already, so the interface to the server wouldn't have to change that much probably; remote changes could still be synchronized by a not so frequent check, as it's currently done. However, even better would be if the server could also provide an interface for the client for querying remote changes (from another sync client or via the web interface) - ideally, the server would even push such changes, in a way similar to the local notifications.

The client would then listen to both these interfaces: The local file modifications and the remote file modifications.

This would not only decrease CPU usage vastly, but synchronization would also be much quicker!
And because not so much CPU cycles are wasted, it would also be more eco-friendly ;)! And for very large synced folders, in my opinion, this is even the only viable way.

On startup of the client - and possibly in a low frequency afterwards, like at the most once every hour or so (to catch possible missed border cases) - a full rescan should probably still be done.

Activity

  1. testbird commented on Oct 30, 2012

    @testbird

    The onwcloud server (as well as the clients) should just watch for changes on the local filesystems, to make them compatible with all methods to access the filesystem. Then trigger syncs upon changes.

    A helper application that will set up filesystem-watches locally and remotely (and triggers efficient and rock solid unison syncs appropriately) is:
    https://launchpad.net/sucsynct

    To make notifications work even with plain webservers (non-ssh enabled) they may be tunneled (idealy directly as stdin and stdout shell pipes) with something like:
    https://cgi-shell.binaervarianz.de (maybe a FastCGI version of it)

  2. RandolfCarter commented on Nov 7, 2012

    @RandolfCarter
    Author

    Is there any documentation on how to build this client version with inotify support? The one in the repositories for ubuntu doesn't seem to be compiled with it (the log there shows a scan every 10 seconds) - and in the comment above there is just one file linked, is it in a branch of some sort? Isn't gitorious the old code repository, shouldn't it be on github?

  3. rconstanzo commented on Nov 8, 2012

    @rconstanzo

    I've tried and abandoned a few versions of owncloud for similar reasons. I've got about 14k files and it spikes the client and server CPUs pretty hard.

  4. nukeador commented on Dec 6, 2012

    @nukeador

    +1

    Having thousands of files and syncing all the time is cpu and bandwidth consuming :)

  5. tafinho commented on Dec 6, 2012

    @tafinho

    +1
    Currently my system takes around 8 hours to check that no files where changed :)

  6. nukeador commented on Dec 7, 2012

    @nukeador

    I've just updated my Linux client from 1.1.1 to 1.1.3 and it seems it behaves better in terms of not polling all the time. Any clue if it was updated to support inotify?

  7. dragotin commented on Dec 7, 2012

    @dragotin
    Contributor

    @nukeador I think you might have suffered from another bug in 1.1.1, happy that it works better with 1.1.3

    We are working on better inotify support on all platforms. Please stay tuned.

  8. jvandenbroek commented on Jan 2, 2013

    @jvandenbroek

    +1 as well! With 13.000 files in 606 folders it takes more than 30 secs at 100% CPU, and that every minute.. :-( Very annoying! This is holding me from implementing ownCloud on larger scale..

  9. RandolfCarter commented on Jan 2, 2013

    @RandolfCarter
    Author

    Have to test yet with 1.2 (beta), but there this should be implemented already as far as I heard!

  10. jvandenbroek commented on Jan 2, 2013

    @jvandenbroek

    I have tested it with 1.2 beta1 on Windows.. Inotify works for new/changed files on client-side, but unfortunately not for files changed on server-side. So it still needs to poll the server to check for changes. Which is way too inefficient.

  11. der-gilb commented on Jan 10, 2013

    @der-gilb

    +1
    We are trying to implement owncloud as an alternative to dropbox in our university research group, but at the moment this is not possible due to the spiking CPU usage of the windows client. I have ~10000 files in ~1000 folders, and running the owncloud 1.1.4 client my CPU load looks like this:
    owncloud-cpu

  12. jvandenbroek commented on Jan 11, 2013

    @jvandenbroek

    I read my own comment and statement, however, I think I was mistaken. The problem exists, but I don't think my explanation is correct. With the new client filesystem notifier, there shouldn't be a need for periodic polling. Maybe something which will be fixed in the next beta, after confirming that the new notifier works reliable enough? Or perhaps create an option to manually initiate this polling as an integrity check? And/or able to schedule it (perhaps also trigger on user inactivity)? I think it should be at least configurable.

  13. napoleon41 commented on Jan 22, 2013

    @napoleon41

    I agree. The current beta 1.2 windows client still causes periodic CPU spikes. I am REALLY hoping that this is fixed soon as that's a deal breaker (power consumption, irritating fan noise variance, slow systems), and I really like what I've seen from owncloud. If there was a way to make this sync every 10 minutes instead of every minute, it might be bearable based on the duration of scanning my file set.

    I did notice that changing the CPU priority of the owncloud process to lowest did reduce the impact on my system. However, it also increased the time over which the spike occurs. Obviously no free lunch.

  14. 22 remaining items

  15. fragtion commented on Aug 13, 2013

    @fragtion

    \o/ About time.. looking forward to moving back to Owncloud :)

  16. ccoenen commented on Aug 13, 2013

    @ccoenen

    I'd like to apologize for the "demading" tone of my previous comment. Thanks for looking into this! It's very important to me. I'm looking forward to the upcoming version!

  17. ogoffart commented on Aug 16, 2013

    @ogoffart
    Contributor

    In 1.4, the poll is just an HTTP request to check that nothing changed on the server.
    There is still a full sync hapenning every 5 minutes to be sure we catch all the changes that may not been seen by the file system watcher.

  18. fragtion commented on Sep 20, 2013

    @fragtion

    What's the status on this - still a work in progress? Still needs to do a full sync every 5 minutes?

  19. dragotin commented on Sep 20, 2013

    @dragotin
    Contributor

    @fragtion absolutely not. Every fife minutes, we do one PROPFIND on the server and a poll through the local filesystem. No full sync.

  20. disconn3ct commented on Oct 17, 2013

    @disconn3ct

    Even on the newest client (1.4 on OSX) I'm still seeing 100% cpu usage.
    owncloud-cpu

    This is doubly irritating on OSX, since there is a hacky (but functional) filesystem notification method in fsevents. (If used properly, you never have to do a scan - you can catch up with changes that were missed when the client was not running.)

    9800 files, 2100 directories.

  21. fosple commented on Oct 17, 2013

    @fosple

    @disconn3ct Same here on MacOS... :(

  22. fragtion commented on Oct 17, 2013

    @fragtion

    It's definitely a lot better on Windows now, haven't noticed a problem! Hope the devs can help you guys with Mac too, cause this rocks :)

  23. wilzbach commented on Jul 14, 2014

    @wilzbach

    Hi guys,

    is there an update on the use of inotify to traverse only parts of the tree?

    If I look at the logs of the client 1.6 I still see the polling every 30sec for general changes on the filesystem and if there is only one detected change (etag), the client traverses the whole tree which sucks and takes a long time as I have 124K files ..

    In summary my real-time syncing takes about 5-10 minutes (thanks to SSD and i7).

    07-14 12:44:27:886 !!! Mirall::CheckQuotaJob created for  QUrl( "xxx" )  querying "/" 
    07-14 12:44:40:777 * Polling "ownCloud" for changes. (time since last sync: 30 s) 
    07-14 12:44:40:777 !!! Mirall::RequestEtagJob created for  QUrl( "xxx" )  querying "" 
    07-14 12:44:41:168 * Compare etag  with previous etag:  false 
    07-14 12:44:58:272 !!! Mirall::CheckQuotaJob created for  QUrl( "xxx" )  querying "/" 
    07-14 12:45:10:777 * Polling "ownCloud" for changes. (time since last sync: 60 s) 
    07-14 12:45:10:777 !!! Mirall::RequestEtagJob created for  QUrl( "xxx" )  querying "" 
    07-14 12:45:11:124 * Compare etag  with previous etag:  false 
    07-14 12:45:28:770 !!! Mirall::CheckQuotaJob created for  QUrl( "xxx" )  querying "/" 
    07-14 12:45:40:777 * Polling "ownCloud" for changes. (time since last sync: 90 s) 
    07-14 12:45:40:777 !!! Mirall::RequestEtagJob created for  QUrl( "xxx" )  querying "" 
    07-14 12:45:41:168 * Compare etag  with previous etag:  false 
    
  24. ogoffart commented on Jul 14, 2014

    @ogoffart
    Contributor

    The 30 seconds polling is only for server-side change, we don't look at the file system there.
    We have a fille system watcher that track the changes. But it is not reliable so we still force a full scan of the local directory every 5 minutes. You can increase this time with the forceSyncInterval option in the mirall config file (and set a number of milliseconds)

  25. christophwolff commented on Aug 5, 2014

    @christophwolff

    This issue is the only thing That keeps me away Form own cloud.

  26. RandolfCarter commented on Aug 6, 2014

    @RandolfCarter
    Author

    @pixelpoesie you might notice that this issue is closed (and in this case, that more or less means, implemented). What exactly about it is it that keeps you away? If you have any suggestions on what to do better you probably should report a new issue.

  27. ccoenen commented on Aug 6, 2014

    @ccoenen

    @pixelpoesie it's fine now. There might be room for improvement, but since 1.4 or 1.5 i don't notice the syncer anymore (which is probably the highest kind of praise for this type of software).

    Before that, i used to turn it off in certain situations to save disk-io, CPU cycles and battery. Haven't done this in a while.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions