Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce scanning of local filesystem needlessly every sync in monitor mode #433

Merged
merged 5 commits into from
Apr 1, 2019

Conversation

abraunegg
Copy link
Owner

Reduce scanning the entire local system in monitor mode for local changes

After performing all the DB sync fixes, there is still excessive CPU in monitor mode when performing this scan:

...
Uploading new items of .
...

This is due to scanning the entire sync_dir path for any changes.

This scan is excessing and needless, as the sync_dir path, in monitor mode, is already being monitored by inotify for any local changes, thus we should not need to scan the entire path / tree for changes, as they would have already been captured.

Example: a 35 sec 100% CPU load when 'scanning' for local changes with 50K files / folders
uploading-new-items-scan

With the proposed patch - zero extra CPU load:

uploading-no-new-items-scan

Thoughts?

* Reduce scanning the entire local system in monitor mode for local changes
* Separate out 'scanForDifferences' monitor & downloadOnly check
@abraunegg abraunegg requested a review from norbusan March 24, 2019 03:26
@norbusan
Copy link
Collaborator

Hmmm, but if an upload triggered due to inotify doesn't work, eg because offline, when will the files be uploaded?

@abraunegg
Copy link
Owner Author

Good point ...

What about some how scanning the local FS once at startup and then if 'detected been offline' ?

@abraunegg
Copy link
Owner Author

Or even a full scan every X hours ? scanning EVERY (by default) 45 seconds a full path walk to me is rather excessive ...

@norbusan
Copy link
Collaborator

I would go for both: Setting a dirty bit in the inotify handler and doing a full scan if that is set, plus every N (60? 100? Option) sync runs a full sync.

We have already a counter variable for the number of syncs (log frequency) that could be reused.

WDYT?

@abraunegg abraunegg changed the title Reduce scanning of local filesystem needlessly in monitor mode WIP: Reduce scanning of local filesystem needlessly in monitor mode Mar 24, 2019
@abraunegg abraunegg added this to the 2.3.1 milestone Mar 24, 2019
@abraunegg abraunegg modified the milestones: 2.3.1, 2.3.2 Mar 25, 2019
* Add 'monitor_fullscan_frequency' to set the freqency of performing a full disk scan when in monitor mode
@abraunegg
Copy link
Owner Author

@norbusan
with suggested changes:

(dmd-2.083.0)[alex@centos7full onedrive-pr433]$ ./onedrive --confdir '~/.config/onedrive-personal' --monitor --verbose
Loading config ...
Using Config Dir: /home/alex/.config/onedrive-personal
Initializing the OneDrive API ...
Opening the item database ...
All operations will be performed in: /home/alex/OneDrivePersonal
Initializing the Synchronization Engine ...
Account Type: personal
Default Drive ID: 66d53be8a5056eca
Default Root ID: 66D53BE8A5056ECA!101
Remaining Free Space: 4498492245
Fetching details for OneDrive Root
OneDrive Root exists in the database
Initializing monitor ...
OneDrive monitor interval (seconds): 10
Monitor directory: .
Applying changes of Path ID: 66D53BE8A5056ECA!101
Uploading differences of .
Processing root
The directory has not changed
Processing zero-file-size
The file has not changed
Processing 2nd-zero-file-size
The file has not changed
Uploading new items of .
Applying changes of Path ID: 66D53BE8A5056ECA!101
Applying changes of Path ID: 66D53BE8A5056ECA!101
Applying changes of Path ID: 66D53BE8A5056ECA!101
Applying changes of Path ID: 66D53BE8A5056ECA!101
Syncing changes from OneDrive ...
Applying changes of Path ID: 66D53BE8A5056ECA!101
Applying changes of Path ID: 66D53BE8A5056ECA!101
Applying changes of Path ID: 66D53BE8A5056ECA!101
Applying changes of Path ID: 66D53BE8A5056ECA!101
Applying changes of Path ID: 66D53BE8A5056ECA!101
Syncing changes from OneDrive ...
Applying changes of Path ID: 66D53BE8A5056ECA!101
Applying changes of Path ID: 66D53BE8A5056ECA!101
Uploading differences of .
Processing root
The directory has not changed
Processing zero-file-size
The file has not changed
Processing 2nd-zero-file-size
The file has not changed
Uploading new items of .
Applying changes of Path ID: 66D53BE8A5056ECA!101
Applying changes of Path ID: 66D53BE8A5056ECA!101
Applying changes of Path ID: 66D53BE8A5056ECA!101
Applying changes of Path ID: 66D53BE8A5056ECA!101
  • runs every 10 'sync' operations
  • defaults to true, so if service is restarted, sync will run

@abraunegg abraunegg changed the title WIP: Reduce scanning of local filesystem needlessly in monitor mode Reduce scanning of local filesystem needlessly every sync in monitor mode Mar 30, 2019
@abraunegg
Copy link
Owner Author

@norbusan
Should be good to approve / go if you are OK with the changes

@norbusan
Copy link
Collaborator

norbusan commented Apr 1, 2019

Fine with me. Strange enough GH says that it cannot rebase the conflicts, while master is already merged in ... it should not rebase, it should simply merge which is actually a fast-forward merge.

@abraunegg abraunegg merged commit 4444b9c into master Apr 1, 2019
@abraunegg abraunegg deleted the Issue-#432 branch April 1, 2019 16:59
@abraunegg abraunegg restored the Issue-#432 branch April 1, 2019 17:24
abraunegg added a commit that referenced this pull request Apr 1, 2019
* Add PR #433 changes
@lock
Copy link

lock bot commented May 1, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators May 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants