Use change notifications instead of polling
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.
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)
I concur, this is a major issue. However, only for Windows and Mac because owncloud for Linux can already be compiled with inotify support. [1]
Unfortunately, QT's QFileSystemWatcher class (QT 4.7) does not help, as it does not work properly. [1] [2] hints that also for QT 5.1 there won't be better support. Searching for a way out I found [3]. But it seems to be a lot of work especially since owncloud for Windows needs to be cross-compiled... And this would only apply for Windows.
However, this is a major drawback (cf. [4]) and should be solved soon IMHO.
[1] http://gitorious.org/owncloud/mirall/blobs/b66f8fba16124c18a43a52dcc1337d20d161801a/src/mirall/folderwatcher.h [2] http://blog.rburchell.com/2012/03/qt-51-aka-when-qfilesystemwatcher-might.html [3] http://qualapps.blogspot.de/2010/05/understanding-readdirectorychangesw.html [4] http://bugs.owncloud.org/thebuggenie/owncloud/issues/oc-1533
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?
Even though I never did it, I guess, you have to pass -DUSE_INOTIFY=ON to cmake (cf. [5]) The linked file [1] is indeed old. But it is the only explaination I found why inotify is used instead of QFileSystemWatcher.
[5] http://dragotin.wordpress.com/2012/03/22/csync-and-mirall-development-setup/#comment-265
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.
+1
Having thousands of files and syncing all the time is cpu and bandwidth consuming :)
+1 Currently my system takes around 8 hours to check that no files where changed :)
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?
@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.
+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..
Have to test yet with 1.2 (beta), but there this should be implemented already as far as I heard!
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.
+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:

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.
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.
I am also using the 1.2 beta client. I set the polling interval to 5 minutes (localPollInterval=300000 in owncloud.cfg) which works. BUT there still is a further problem - whenever a change in a file is detected by owncloud (e.g. I open a spreadsheet and openoffice/excel writes a .lock file or I close a spreadsheet and the .lock file is deleted) a 'syncing spike' is caused. So whenever any file is changed/created/deleted, the whole cloud directory seems to be synced, which at this point is very resource ineffective for large amounts of files and folders.
CPU load is much better in 1.2 stable client for Windows. Good job, devs!
edit: Sadly this statement was made prematurely - I still have the problems described above. Please keep working on this.
I have the same Problem even with owncloud 1.2 I have 24GB of files with 40k Objects (Files and Folder) in it. CPU power always on 100 to 120 %. My Battery lasts 1 Hour with the owncloud client on ;). Theres absolutly no way of getting it in a productive Environment. Sorry if i doubled some notes here. But its very important to change this. Thank you so much.
Beside that. Very good job devs :+1:

This is a major problem for me too, on a Windows machine trying to sync a 50GB documents folder made up by a few thousand files. Constant mountains on the CPU graph. The only real disappointment from this awesome software so far! Really hoping this gets fixed asap XD inotify-win may be a good project for source insight?
Note to self: Skip local run if no inotify event came in between to sync runs. It should be possible to construct the tree from db.