Defer live file query in FindObsoleteFiles #238
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Signed-off-by: tabokie xy.tao@outlook.com
This PR contains two optimizations to reduce DB mutex held time when generating obsolete files purging jobs:
This relies on the fact that
PurgeObsoleteFiles()
is only called whenJobContext::HaveSomethingToDelete()
is true, and the job context is unchanged after callingFindObsoleteFiles()
This relies on the fact that
Version
will only be public when it's finalized, and finalized version has immutable file list.We examine the patch in an artificial workload, where iterators are frequently created and released (active iterator count around 250, write OPS around 20K). The logging shows before patching,
AddLiveFiles()
call takes 100+ms and in that process copies 250W file metas with 6W of them being unique.(left: patched, right: vanilla)