client icon indicating copy to clipboard operation
client copied to clipboard

OSX: [1.5.1 - 1.5.2] Still high CPU spikes

Open sgcoffee opened this issue 12 years ago • 53 comments

Hey devs,

since 1.5.1, and even with 1.5.2 I am facing high CPU spikes during the regular sync process. I have around 30.000 files on my server. And those are getting checked every 5-8 minutes or so... Even there is no changing of files on my Mac and or on the server. My fans are also kicking in. Using the OS X client is no fun at all at the moment. I have to shut down my client until I can use it again...

OC client: ownCloud 1.5.2 (under OS X 10.9.2) OC server: ownCloud 6.0.1 (under OS X Server 10.9.2)

Some logs

02-27 20:24:29:411 _csync_merge_algorithm_visitor: INSTRUCTION_NONE file: --PATH--DELETED--/images/017.gif 02-27 20:24:29:411 csync_reconcile: Reconciliation for remote replica took 1,00 seconds visiting 29950 files. 02-27 20:24:29:456 Transaction Start "checkConnect" 02-27 20:24:29:456 Columns in the current journal: ("phash", "pathlen", "path", "inode", "uid", "gid", "mode", "modtime", "type", "md5", "fileid") 02-27 20:24:29:607 N------N Network Limits changed! 02-27 20:24:30:027 Transaction Start "All Finished." 02-27 20:24:30:081 CSync run took 171875 Milliseconds 02-27 20:24:30:081 [PROGRESS] progressed 0 bytes in 0 files in msec 670 02-27 20:24:30:082 -> CSync Finished slot with error false warn count 0 02-27 20:24:30:082 OO folder slotSyncFinished: result: 2 02-27 20:24:30:082 Folder in overallStatus Message: Mirall::Folder(0x10c64f740) with name "ownCloud" 02-27 20:24:30:084 Sync state changed for folder "ownCloud" : "Success" 02-27 20:24:30:084 SocketApi: Sync state changed 02-27 20:24:30:084 SocketApi: Broadcasting to 0 listeners: "UPDATE_VIEW" 02-27 20:24:30:084 <===================================== sync finished for "ownCloud" 02-27 20:24:30:286 XX slotScheduleFolderSync: folderQueue size: 0 02-27 20:24:32:440 !!! Mirall::CheckQuotaJob created for QUrl( "https://......com:xxxx" ) querying "/"

some minutes later:

02-27 20:32:33:339 _csync_merge_algorithm_visitor: INSTRUCTION_NONE file: --PATH--DELETED--/images/017.gif 02-27 20:32:33:339 csync_reconcile: Reconciliation for remote replica took 0,67 seconds visiting 29950 files. 02-27 20:32:33:382 Transaction Start "checkConnect" 02-27 20:32:33:382 Columns in the current journal: ("phash", "pathlen", "path", "inode", "uid", "gid", "mode", "modtime", "type", "md5", "fileid") 02-27 20:32:33:530 N------N Network Limits changed! 02-27 20:32:33:902 Transaction Start "All Finished." 02-27 20:32:33:960 CSync run took 181811 Milliseconds 02-27 20:32:33:960 [PROGRESS] progressed 0 bytes in 0 files in msec 621 02-27 20:32:33:960 -> CSync Finished slot with error false warn count 0 02-27 20:32:33:961 OO folder slotSyncFinished: result: 2 02-27 20:32:33:961 Folder in overallStatus Message: Mirall::Folder(0x10c64f740) with name "ownCloud" 02-27 20:32:33:962 Sync state changed for folder "ownCloud" : "Success" 02-27 20:32:33:962 SocketApi: Sync state changed 02-27 20:32:33:962 SocketApi: Broadcasting to 0 listeners: "UPDATE_VIEW" 02-27 20:32:33:962 <===================================== sync finished for "ownCloud" 02-27 20:32:34:163 XX slotScheduleFolderSync: folderQueue size: 0 02-27 20:32:39:044 !!! Mirall::CheckQuotaJob created for QUrl( "https://......com:xxxx" ) querying "/"

Thank you very much Stefan

screenshot 2014-02-27 um 20 47 08

sgcoffee avatar Feb 27 '14 19:02 sgcoffee

Same here, owncloud mac client 1.5.2, build 2335, while network usage stays very low 3KB up, 11KB down (no network limits); disk i/o low, mem footprint low. Whilst my mac air is quick to make fan noise when busy, this is quite intolerable.

antigraviton avatar Feb 28 '14 09:02 antigraviton

@sgcoffee The client does a full check every 5 minutes at the moment. This is not a regression. The regression was that in 1.5.1, it would not spike, but consume CPU continuously. We are working on an improvement for 1.6.

danimo avatar Feb 28 '14 10:02 danimo

@danimo Thanks for the explanation. How does the Dropbox client work in that way? Since 1.6 is a bit away, will a downgrade to 1.5.0 might help?

sgcoffee avatar Mar 01 '14 21:03 sgcoffee

Can we use the native Mac OS X folder watch to trigger a full check instead of the client checking every five minutes needlessly? Maybe an option that would install a plist for watch folder triggering a command telling owncloud to do a full check.

mkormendy avatar Mar 06 '14 07:03 mkormendy

@mkormendy the native MacOSX APIs are used: https://github.com/owncloud/mirall/blob/1be322579cf3f12e4d6747a9652a1e4226dfd4c3/src/mirall/folderwatcher_mac.cpp

I wonder if it would be possible to switch off the 5 minute syncs if on the Mac? I have heard that the developers said that they keep the 5 min check due to the APIs being unreliable. Is this a general statement (Win, Linux, Mac) or are there specific cases where the FSEventStream fails to notify the app?

jcfischer avatar Mar 06 '14 08:03 jcfischer

@jcfischer If they are being used then why would a 5 minutes sync be required? The folder watching should be doing the trigger for checking .. Not the timer.

mkormendy avatar Mar 06 '14 08:03 mkormendy

as I said - both are used...

jcfischer avatar Mar 06 '14 08:03 jcfischer

it is exactly how @jcfischer says. We're still having the fife minutes timer because there are circumstances when we do not get notification about files changing with the current system, think of a change during a running sync for example. But you can stay tuned, we have that on the radar and will work on a solution for that.

dragotin avatar Mar 06 '14 08:03 dragotin

@dragotin - that is weird. If I read the docs https://developer.apple.com/library/mac/documentation/Darwin/Conceptual/FSEvents_ProgGuide/UsingtheFSEventsFramework/UsingtheFSEventsFramework.html correct, the API will know exactly what has changed since the last time (and that is even persistent across system reboots) "Using Persistent Events" shows how to do that.

jcfischer avatar Mar 06 '14 08:03 jcfischer

@dragotin & @jcfischer that's why I am saying that we don't need the timer. the docs state it exactly as it happens .. So no need for timer.

Maybe for safety's sake run the timer once every two hours,...if that even.

mkormendy avatar Mar 06 '14 08:03 mkormendy

Yes, the api knows. But it's not that easy. Imagine this: During a sync run, we download foo.png (1) from the server, followed by 15678 other downloads that take some time. During the sync runs, user is happy about foo.png, opens it and turns it (2). Both (1) and (2) fire change events, and (1) has to be ignored but (2) not, because it means we have to sync foo.png back to the server.

We thought about that: during the download of foo.png we know that there will be events coming for foo.png, and we can ignore them. After the download is finished, we should not ignore them any more.

That has a couple of problems tough:

  • Our file system watcher needs to report changes for a specific file as discussed above, currently it only indicates a change within the directory, not specifically for the file.
  • All that has to work cross platform with as little platform specific code as possible.
  • It can take some time until an event is delivered by the system. So the code must be prepared to handle the event for foo.png correctly in a little timespan if the download is finished.
  • File system change events have system dependant limits. We have to think how that can work for our friends with 350,000 and more files - cross platform again!

I am happy to discuss your patches against the branch https://github.com/owncloud/mirall/tree/new_folderwatcher which I started recently to work on the new fs watcher.

dragotin avatar Mar 06 '14 09:03 dragotin

Also, please take into account situations on filesystems where inotify is broken or unreliable.

kuba

On Mar 6, 2014, at 10:10 AM, dragotin [email protected] wrote:

Yes, the api knows. But it's not that easy. Imagine this: During a sync run, we download foo.png (1) from the server, followed by 15678 other downloads that take some time. During the sync runs, user is happy about foo.png, opens it and turns it (2). Both (1) and (2) fire change events, and (1) has to be ignored but (2) not, because it means we have to sync foo.png back to the server.

We thought about that: during the download of foo.png we know that there will be events coming for foo.png, and we can ignore them. After the download is finished, we should not ignore them any more.

That has a couple of problems tough:

Our file system watcher needs to report changes for a specific file as discussed above, currently it only indicates a change within the directory, not specifically for the file. All that has to work cross platform with as little platform specific code as possible. It can take some time until an event is delivered by the system. So the code must be prepared to handle the event for foo.png correctly in a little timespan if the download is finished. File system change events have system dependant limits. We have to think how that can work for our friends with 350,000 and more files - cross platform again! I am happy to discuss your patches against the branch https://github.com/owncloud/mirall/tree/new_folderwatcher which I started recently to work on the new fs watcher.

— Reply to this email directly or view it on GitHub.

moscicki avatar Mar 06 '14 09:03 moscicki

Maybe I jump in for a second, as an end user. I have around 30.000 files on the server. It will take around 2-3min to run the check. That means, after around a 2 min break it will start again...

Looking forward to a useful solution

Thank you guys for your efforts Stefan

Von meinem iPhone gesendet

Am 06.03.2014 um 09:54 schrieb Mike Kormendy [email protected]:

@dragotin & @jcfischer that's why I am saying that we don't need the timer. the docs state it exactly as it happens .. So no need for timer.

Maybe for safety's sake run the timer once every two hours,...if that even.

— Reply to this email directly or view it on GitHub.

sgcoffee avatar Mar 06 '14 10:03 sgcoffee

@sgcoffee We are very aware of those problems.

danimo avatar Mar 06 '14 10:03 danimo

(1) does not fire event, if the file changes to (2) then that fires the watch event.

I realize that you guys are using qt to compile and manage code cross platform. I know for certain the devs at dropbox have different teams that only code for specific platforms. This is one of the bottlenecks here.

mkormendy avatar Mar 06 '14 10:03 mkormendy

@mkormendy Qt is not the problem here. The file watchers in Mirall are mostly native code. For Mac OS, it's API compatibility (we would need to drop 10.6 support for better file watchers), for Linux, it's overall unreliability of inotify, on Windows, it's the existence of two different watcher APIs and vague documentation for certain cases which needs a lot of testing. We'll get there, one step at at a time.

danimo avatar Mar 06 '14 10:03 danimo

Yes lion has better fsevent ... For files like inotify. https://developer.apple.com/library/mac/documentation/Darwin/Reference/FSEvents_Ref/Reference/reference.html#//apple_ref/doc/c_ref/kFSEventStreamCreateFlagFileEvents

mkormendy avatar Mar 06 '14 10:03 mkormendy

@mkormendy That's what I said :-)

danimo avatar Mar 06 '14 10:03 danimo

I'm writing on my iPad ... I'm slower than at my computer :-)

mkormendy avatar Mar 06 '14 10:03 mkormendy

Seems like we need a universal library for folderfile watching that doesn't suck.

...... Amongst many things. ;-)

Either way, I wonder why the Linux one is so flakey? I don't know many people who run anything less than lion, considering that Mac OS X Mavericks is free upgrade from snow leopard (10.6.8). I'm sorry for the people on windows that's just asking for trouble.

mkormendy avatar Mar 06 '14 10:03 mkormendy