core icon indicating copy to clipboard operation
core copied to clipboard

mirall sync: sync performance scales linearly with number of directories

Open Supermathie opened this issue 12 years ago • 12 comments

Steps to reproduce

Configure a large number of directories in a repository

Expected behaviour

sync should not suck horribly with a large number of directories

Actual behaviour

mirall is doing one PROPFIND per directory:

192.168.0.183 - - [26/Mar/2014:14:38:22 -0400] "PROPFIND /remote.php/webdav/server1-files/archive/2009/deep/directory/dir1 HTTP/1.1" 207 1184 "-" "Mozilla/5.0 (Linux) csyncoC/0.91.5 neon/0.30.0" "192.168.0.183"
192.168.0.183 - - [26/Mar/2014:14:38:23 -0400] "PROPFIND /remote.php/webdav/server1-files/archive/2009/deep/directory/dir2 HTTP/1.1" 207 3141 "-" "Mozilla/5.0 (Linux) csyncoC/0.91.5 neon/0.30.0" "192.168.0.183"
192.168.0.183 - - [26/Mar/2014:14:38:23 -0400] "PROPFIND /remote.php/webdav/server1-files/archive/2009/deep/directory/dir3 HTTP/1.1" 207 1165 "-" "Mozilla/5.0 (Linux) csyncoC/0.91.5 neon/0.30.0" "192.168.0.183"

resulting in a single sync from the client taking the better part of an hour (over the LAN) - we just did a data import to bring a customer up and they have... 17700 directories in the tree.

Latency on each request at the server is around 100-200ms to respond, but that's not even taking into account Internet latency.

Other than reducing the number of directories, is there something we can do to make this workable?

Server configuration

Operating system: RHEL 6 x64

Web server: nginx

Database: mysql

PHP version: 5.5.9

ownCloud version: 6.0.2.2

Updated from an older ownCloud or fresh install: fresh

List of activated apps: Activity, Deleted files, Documents, First Run Wizard, Full Text Search, LDAP user and group backend, PDF Viewer, Pictures, Share Files, Text Editor, Updater, Versions, Video Viewer

The content of config/config.php:

<?php
$CONFIG = array (
  'instanceid' => '(redacted)',
  'passwordsalt' => '(redacted)',
  'trusted_domains' => 
  array (
    0 => 'owncloud.cust.com',
  ),
  'datadirectory' => '/owncloud/data/oc_cust,
  'dbtype' => 'mysql',
  'version' => '6.0.2.2',
  'dbname' => 'oc_cust,
  'dbhost' => 'localhost',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'oc_cust,
  'dbpassword' => '(redacted)',
  'installed' => true,
  'ldapIgnoreNamingRules' => false,
  'maxZipInputSize' => 838860800,
  'allowZipDownload' => true,
);

Are you using external storage, if yes which one: no

Are you using encryption: no

Client configuration

Browser: Chrome or mirall

Operating system: Linux

Logs

Web server error log

n/a

ownCloud log (data/owncloud.log)

n/a

Browser log

n/a

Supermathie avatar Mar 26 '14 21:03 Supermathie

There is work in progress to increase the responsiveness of the server.

I don't know why the server is doing a PROPFIND of the whole structure.

Is this the initial sync or also happens on subsequent syncs?

CC @dragotin

PVince81 avatar Mar 27 '14 08:03 PVince81

Oh god, thankfully it looks like this only happens on initial sync.

When completing this initial sync, we were having it mostly happen but not quite finish and the client was having to restart the sync right from the very beginning and enumerate all the directories. This was also affected by #7905.

Once it completed the first time and achieved syncage it was better, though it seems the (Windows) client is still having to examine all the files at the start of each sync. But really that's a spinning rust problem.

Given this, it seems the best option for initial sync of a large amount of files will be syncing an initial empty directory, then moving files into place. We were moving the files into place them starting a sync.

Is there any existing documentation on best practices for certain scenarios (such as this initial bulk load) that I missed? Or does it need to be created? :)

Supermathie avatar Mar 28 '14 15:03 Supermathie

I had the same feeling yesterday about the initial sync. There was a test case with a lot of empty folders and subfolders (I tried to recreate a directory structure for testing). After 2-3 minutes the sync client was still doing its "preparation phase" for the initial sync.

PVince81 avatar Apr 10 '14 10:04 PVince81

@dragotin I'm not sure why it's taking that long and doing a PROPFIND on the whole structure ? Maybe this could be optimized somehow by providing a single call that returns the whole filetree structure at once ? This might not match the WebDAV standard though.

PVince81 avatar Apr 10 '14 10:04 PVince81

@guruz could you explain our strategy about recursive propfind pls?

dragotin avatar Apr 10 '14 12:04 dragotin

The syncing client will do a recursive PROPFIND on the initial sync, I'm however not sure from which ownCloud server version this is supported/integrated now. Also, with the way the server is currently implemented, I'm thinking if this not actually makes things worse for this amount of files/directories.

guruz avatar Apr 11 '14 07:04 guruz

Is this recursive PROPFIND behaviour in master yet? I just tested with today's snapshots server: 6,90,0,2 and client: 1.6.0.2676beta1 and didn't see that behaviour.

Also, a normal periodic after the initial sync is still takes a very long time. For instance, this is on a fast machine (Win7 Pro 64, [email protected], 8GB RAM) on a local network to the owncloud server - here are some (abridged) logs from the client (1.5.3):

04-09 15:35:35:978 SocketApi:  Sync state changed 
04-09 15:35:35:978 SocketApi:  Broadcasting to 0 listeners:  "UPDATE_VIEW" 
04-09 15:35:35:978 folder is sync enabled:  true 
04-09 15:35:35:978 <===================================== sync finished for  "shared" 
04-09 15:35:36:243 XX slotScheduleFolderSync: folderQueue size:  0 
04-09 15:36:05:992 * Polling "shared" for changes. (time since last sync: 30 s) 
04-09 15:36:05:992 !!! Mirall::RequestEtagJob created for  QUrl( "https://owncloud.example.com" )  querying "shared-files/server1-files" 
04-09 15:36:06:242 * Compare etag  with previous etag:  true 
04-09 15:36:06:242 Schedule folder  "shared"  to sync! 
04-09 15:36:06:538 !!! Mirall::CheckQuotaJob created for  QUrl( "https://owncloud.example.com" )  querying "/" 
04-09 15:36:08:254 XX slotScheduleFolderSync: folderQueue size:  1 
04-09 15:36:08:301 Sync state changed for folder  "shared" :  "SyncPrepare" 
04-09 15:36:08:301 SocketApi:  Sync state changed 
04-09 15:36:08:301 SocketApi:  Broadcasting to 0 listeners:  "UPDATE_VIEW" 
04-09 15:36:08:301 folder is sync enabled:  true 
04-09 15:36:08:301 *** Start syncing 
04-09 15:36:08:301   ==> returning exclude file path:  "C:/Program Files (x86)/ownCloud/sync-exclude.lst" 
04-09 15:36:08:301 ==== added system ignore list to csync: "C:/Program Files (x86)/ownCloud/sync-exclude.lst" 
04-09 15:36:08:317   ==> returning exclude file path:  "C:/Users/octest/AppData/Local/ownCloud/sync-exclude.lst" 
04-09 15:36:08:317 ==== added user defined ignore list to csync: "C:/Users/octest/AppData/Local/ownCloud/sync-exclude.lst" 
04-09 15:36:08:317  QUrl( "https://owncloud.example.com/remote.php/webdav/shared-files/server1-files" )  
04-09 15:36:08:317 >===================================== sync started for  "shared" 
04-09 15:36:08:317 void Mirall::CSyncThread::startSync() Sync started 
04-09 15:36:08:317 starting to sync  QThread(0x434e2f0) QThread(0x10810490) 
04-09 15:36:08:317 No database Transaction to commit 
04-09 15:36:08:317 =====sync with existing DB 
04-09 15:36:08:317 #### Update start #################################################### >> 
04-09 15:36:08:317 csync_update: Journal: S:\shared/.csync_journal.db
04-09 15:36:08:410 void Mirall::FolderWatcher::changeDetected(const QString&) "S:\shared/" 
04-09 15:36:08:410  the current folder is currently syncing. 
04-09 15:36:08:410 void Mirall::FolderWatcher::changeDetected(const QString&) "S:\shared/" 
04-09 15:36:08:426 void Mirall::FolderWatcher::changeDetected(const QString&) "S:\shared/" 
04-09 15:36:12:685 csync_statedb_get_stat_by_hash: No result record found for phash = 2400739429619359888
04-09 15:36:12:685 csync_statedb_get_stat_by_hash: No result record found for phash = 4213418407012460730
04-09 15:36:40:765 !!! Mirall::CheckQuotaJob created for  QUrl( "https://owncloud.example.com" )  querying "/" 
04-09 15:36:56:037 csync_update: Update detection for local replica took 47.14 seconds walking 61800 files.
04-09 15:36:56:037 oc_module: opendir method called on ownclouds://owncloud.example.com/remote.php/webdav/shared-files/server1-files
04-09 15:36:56:037 oc_module: * scheme ownclouds
04-09 15:36:56:037 oc_module: * host owncloud.example.com
04-09 15:36:56:037 oc_module: * port 0
04-09 15:36:56:037 oc_module: * path /remote.php/webdav/shared-files/server1-files
04-09 15:36:56:037 oc_module: * user 
04-09 15:36:56:037 oc_module: No proxy configured.
04-09 15:36:56:053 oc_module: Call the csync callback for SSL problems
04-09 15:36:56:053 SSL Fingerprint from neon:  "68:32:bb:c9:ef:8a:96:39:c6:12:24:6e:d9:bc:8a:c9:ce:38:59:a6"  compared to verified:  "68:32:bb:c9:ef:8a:96:39:c6:12:24:6e:d9:bc:8a:c9:ce:38:59:a6" 
04-09 15:36:56:053 oc_module: ## VERIFY_SSL CERT: 0
04-09 15:36:56:302 oc_module: Simple propfind result code 207.
04-09 15:36:56:302 oc_module: opendir returning handle 0f9ffd78 (count=13)
04-09 15:37:37:268 void Mirall::FolderWatcher::changeDetected(const QString&) "S:\shared/" 
04-09 15:37:37:268  the current folder is currently syncing. 
04-09 15:38:17:360 !!! Mirall::CheckQuotaJob created for  QUrl( "https://owncloud.example.com" )  querying "/" 
04-09 15:38:47:765 !!! Mirall::CheckQuotaJob created for  QUrl( "https://owncloud.example.com" )  querying "/" 
04-09 15:39:18:075 !!! Mirall::CheckQuotaJob created for  QUrl( "https://owncloud.example.com" )  querying "/" 
04-09 15:39:48:340 !!! Mirall::CheckQuotaJob created for  QUrl( "https://owncloud.example.com" )  querying "/" 
04-09 15:40:18:526 !!! Mirall::CheckQuotaJob created for  QUrl( "https://owncloud.example.com" )  querying "/" 
04-09 15:40:48:758 !!! Mirall::CheckQuotaJob created for  QUrl( "https://owncloud.example.com" )  querying "/" 
04-09 15:41:19:007 !!! Mirall::CheckQuotaJob created for  QUrl( "https://owncloud.example.com" )  querying "/" 
04-09 15:41:49:209 !!! Mirall::CheckQuotaJob created for  QUrl( "https://owncloud.example.com" )  querying "/" 
04-09 15:42:19:441 !!! Mirall::CheckQuotaJob created for  QUrl( "https://owncloud.example.com" )  querying "/" 
04-09 15:42:46:445 oc_module: closedir method called 0f9ffd78!
04-09 15:42:46:445 csync_update: Update detection for remote replica took 350.41 seconds walking 61800 files.
04-09 15:42:46:445 <<#### Update end ####################################################  398122 
04-09 15:42:47:787 csync_reconcile: Reconciliation for local replica took 1.34 seconds visiting 61800 files.
04-09 15:42:49:066 csync_reconcile: Reconciliation for remote replica took 1.28 seconds visiting 61800 files.
04-09 15:42:49:144 Transaction Start  "checkConnect" 
04-09 15:42:49:144 Columns in the current journal:  ("phash", "pathlen", "path", "inode", "uid", "gid", "mode", "modtime", "type", "md5", "fileid") 
04-09 15:42:49:393  N------N Network Limits changed! 
04-09 15:42:51:094 Transaction Start  "All Finished." 
04-09 15:42:51:156 CSync run took  402830  Milliseconds 
04-09 15:42:58:925 !!! Mirall::CheckQuotaJob created for  QUrl( "https://owncloud.example.com" )  querying "/" 
04-09 15:43:12:169 void Mirall::FolderWatcher::changeDetected(const QString&) "S:\shared/" 
04-09 15:43:12:169  the current folder is currently syncing. 
04-09 15:43:12:169 [PROGRESS] progressed  0  bytes in  0  files  in msec  39 
04-09 15:43:12:185 -> CSync Finished slot with error  false warn count 0 
04-09 15:43:12:185 OO folder slotSyncFinished: result:  2 
04-09 15:43:12:185 Folder in overallStatus Message:  Mirall::Folder(0x43aaaa8)  with name  "personal" 
04-09 15:43:12:185 Folder in overallStatus Message:  Mirall::Folder(0x43b7ca8)  with name  "shared" 
04-09 15:43:12:185 Folder in overallStatus Message:  Mirall::Folder(0x43b0d80)  with name  "archive" 
04-09 15:43:12:185 Sync state changed for folder  "shared" :  "Success" 

For some of our remote users, this is taking hours, with a single CPU burning away the whole time.

We're trying to figure out the best way to mitigate this and I'm working on duplicating the environment to a test site.

Supermathie avatar Apr 15 '14 20:04 Supermathie

@Supermathie I think you will see much better results (especially with the periodics when no changes happend) with 1.6.0. Beta1 is there already, please try (with backuped data of course): http://owncloud.org/sync-clients/#testing

dragotin avatar Apr 16 '14 07:04 dragotin

The initial sync of 1.6.0b1 is still SOOOO SLOW but it's happening. Then I can get some numbers on how long it takes.

Supermathie avatar Apr 16 '14 19:04 Supermathie

Bollocks - the 1.6.0b1 client threw a runtime error midway through so I'm having to restart the initial sync.

Supermathie avatar Apr 17 '14 14:04 Supermathie

@PVince81 Is this issue the same as #7072 ? Then maybe close this one (7906)?

VincentvgNn avatar Aug 15 '14 10:08 VincentvgNn

Closing as duplicate of #7072 Let's continue the discussion there.

PVince81 avatar Aug 15 '14 10:08 PVince81