Skip to content

Local file discovery should be done at most once per run, use file watcher events to seed Discovery #2297

Closed

Description

@ckamm

Currently the client runs a full local discovery every five minutes due to limitations in our file watching code (see #2268 for previous discussion). These limitations should be removed to allow the client to be reliable with only a single run of the local file discovery or without it entirely.

On Mac: We don't get notifications for changes our own process caused, so a single run should be enough. We may be able to hook into the filesystem change journal to even skip that.

On Linux: We get full path information about changes and that could be used to filter out the changes on files we cause ourselves.

On Windows: Similar to Linux (have to use ReadDirectoryChanges instead of FindFirstChangeNotification) and could even possibly skip the single discovery by using "Change Journals".

Activity

  1. moscicki commented on Oct 10, 2014

    @moscicki
    Contributor

    These kind of stuff becomes important as we see people having 50K+ files in their sync folder. If you manage to sort this out to work at scale of a few 100K files in a sync directory then you will have extreme competitive advantage. But that's some way to go, still....

  2. guruz commented on Oct 22, 2014

    @guruz
    Contributor

    Linking #880 since it's related.
    I still have some ideas for Windows directory traversal..

  3. ckamm commented on Nov 6, 2014

    @ckamm
    ContributorAuthor

    @moscicki points out in #2451:

    Please also consider that in some cases an (advanced) user may require to keep the ability of periodic full scans of the local sync folder (on per folder-pair basis). This is if someone have their local folders on mounted filesystems which do not always reliably provide the notifications (e.g. in some cases the AFS). In that case a setting in the folders config file could be sufficient.

  4. 70 remaining items

  5. Trefex commented on Aug 14, 2018

    @Trefex
  6. jnweiger commented on Aug 14, 2018

    @jnweiger
    Contributor

    @Trefex I'll need to avoid the initial sync for that, otherwise we get results next month. Will try.

  7. Trefex commented on Aug 14, 2018

    @Trefex
  8. dragotin commented on Aug 14, 2018

    @dragotin
    Contributor

    Why is 2.4.3 so much faster on 'first force resync:' compared to the other two? Typo?

  9. moscicki commented on Aug 15, 2018

    @moscicki
    Contributor

    What about inotify watch limits? Also with 1M files it will take around 1GB of kernel memory according to: https://unix.stackexchange.com/questions/13751/kernel-inotify-watch-limit-reached

    Will the sync client actually warn the user that there are more files to watch than the current limit?

    Also, I would be good to check/document what would be the practical limits for oc sync client per platform (OSX, Win, Linux)?

  10. jnweiger commented on Aug 15, 2018

    @jnweiger
    Contributor

    @dragotin Not exactly sure, but I noticed that with 2.4.3 when the initial sync finished, the ichon was green only for one or two seconds, then it became blue again and was busy for another 15 seconds. My guess is, it then already did, what the other two would do only on the first resync. Tried twice with same behaviour.

  11. jnweiger commented on Aug 15, 2018

    @jnweiger
    Contributor

    @moscicki yes, we warn the user when we run out of inotify listeners. See #6119 for details.
    I am curious what exact limit is needed for 1M files, and how much kmem that adds.
    My 10k files test did not hit the limit 8000.

  12. jnweiger commented on Aug 15, 2018

    @jnweiger
    Contributor

    200k files - a demonstrator that shows good speedup in 2.5.0

    Summary: 200.000 files scattered in 2.000 folders on the server are in sync with a 2.4.1 and a 2.5.0 desktop client. When editing, adding or deleting a single file, the 2.4.1 client needs less than 10 seconds.

    for ii in $(seq 1 100); do for i in $(seq 1 100); do echo "$i/$ii"; mkdir -p "t$i/$ii"; for j in $(seq 1 100); do cp /etc/samba/smb.conf t$i/$ii/f$j; done; done; done
    

    have enough inotify watches for 1M files.
    echo 200000 | sudo tee -a /proc/sys/fs/inotify/max_user_watches

    client 2.5.0daily20181014

    • vmstat-m.20180815-13:03:56.txt
    • selective sync with t1 t2 t3 t4 t5 t6 t7 t8 t9 10 (100k file).
    • initial 'sync' with sqlite removed: 2:05.1 sec
    • enabling folders t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 (new total 200k files)
      (false warning printed, that unchecked folders will be removed. they are not removed.)
    • second 'sync' with more folders added:
      • Thousands of false messages scroll through the activity log: 'Datei ist seit der Entdeckung geändert worden'
      • Files are being downloaded from the server although identical files exist locally.
      • The client process grows to 1.8GB memory footprint.
      • Duration: 38:34.0 sec (all 4 CPUs of a quadcore busy with client and server activity)
      • 5 sec idle, then another sync: 10:28.3 sec (one CPU busy, no server activity seen)
      • The client process drops to 1.1GB memory footprint.
    • vmstat-m.20180815-14:28:33.txt
    • client stop; start: 45.5 sec
    • small local file change: 6.6 sec, 5.1 sec (including 3 sec before the sync starts)
    • small remote file change: 3.4 sec, 4.4 sec

    client quit: vmstat-m.20180815-14:29:55.txt

    client 2.4.1

    • selective sync with t1 t2 t3 t4 t5 t6 t7 t8 t9 10 (100k file).
    • initial 'sync' with sqlite removed: 3:20.2 sec
    • enabling folders t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 (new total 200k files)
    • second 'sync' with more folders added:
      • The client process grows to 2.4GB memory footprint.
      • 80 messages correclty name the remaining unsynced folder. (Nothing scrolls wildly.)
      • Duration: 10:15.6 sec
      • The client process remains at to 2.4GB memory footprint.
    • first force resync: 48.2 sec
    • 2nd, 3rd force resync: 46.5 sec, 35.2 sec
    • client stop; start: 28.5 sec
    • small local file change: 33.7 sec, 45.1 sec
    • small remote file change: 25.1 sec, 31.3 sec
  13. jnweiger commented on Aug 15, 2018

    @jnweiger
    Contributor

    1M files - a demonstrator that shows moderate speedup in 2.5.0

    Summary: 1.000.000 files scattered in 10.000 folders on the server are in sync with a 2.4.1 and a 2.5.0 desktop client. When editing, adding or deleting a single file, the 2.4.1 client needs between 1 and 2 minutes, but 2.5.0 only needs 20 to 30sec to sync to the server.

    client 2.5.0daily20181014

    • client stop; rm db; client start: ca 15 min (1M files are now included)
    • small local file change: 30.1 sec, 22.0 sec, 20.3 sec
    • small remote file change: 1:05.5 sec, 27.4 sec, 51.9 sec

    client 2.4.1

    • client stop; rm db; client start: ca 15 min (1M files are now included)
    • small local file change: 2:48.8 sec, 1:04.7 sec, 1:02.6 sec
    • small remote file change: 1:02.1 sec, 1:45.3 sec, 1:03.2 sec
  14. jnweiger commented on Aug 16, 2018

    @jnweiger
    Contributor

    @moscicki Good news about inotify watch limits:
    With a test tree of exactly 1010010 files in 10103 folders, the official number of watches appears to be 10390.
    This number was found by bisecting /proc/sys/fs/inotify/max_user_watches settings.
    Compared with earlier tests, this confirms the impression that we have one watch per folder plus ca. 200 -- the number of files seems irrelevant.

    Linux slabinfo (via vmstat -s and slabtop, using echo 3 > /proc/sys/vm/drop_caches) did not seem to be accurate enough to actually measure additional kernel memory consumption for the watches. In some cases kernel memory footprint even appeared to be smaller while the client was watching the tree.

  15. gnanet commented on Sep 2, 2018

    @gnanet

    @jnweiger i consider switching from 2.4.3 to a 2.5 client on Ubuntu 14.04.5,
    while checking /proc/sys/fs/inotify/max_user_watches the value is: 65536

    So i looked into /etc/sysctl.d and found these settings with grep inotify.max_user_watches *.conf

    100-owncloud-inotify.conf:fs.inotify.max_user_watches = 524288
    100-sync-inotify.conf:fs.inotify.max_user_watches = 524288
    30-tracker.conf:fs.inotify.max_user_watches = 65536
    
    

    AGAIN the current value is 65536, this confirms my assumption, that the usual load-order specification has two digits for a reason:
    According the docs

    All configuration files are sorted by their filename in lexicographic order, regardless of which of the directories they reside in. If multiple files specify the same option, the entry in the file with the lexicographically latest name will take precedence. It is recommended to prefix all filenames with a two-digit number and a dash, to simplify the ordering of the files.

    The #4107 (comment) suggesting to set the owncloud-inotify.conf load-order to 100, and the resulting commit owncloud/administration@8218eb3 created a bug.

  16. guruz commented on Sep 3, 2018

    @guruz
    Contributor

    @gnanet Thanks for debugging. Your suggestion would be 99-*-inotify.conf?

  17. reopened this on Sep 3, 2018
  18. ogoffart commented on Sep 3, 2018

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

Metadata

Metadata

Assignees

Labels

EnhancementPerformanceReadyToTesttechnical debt

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions