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

Defer live file query in FindObsoleteFiles #238

Closed
wants to merge 3 commits into from

Conversation

tabokie
Copy link
Member

@tabokie tabokie commented Jun 24, 2021

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:

  1. Avoid querying live files when there is no obsolete files to purge

This relies on the fact that PurgeObsoleteFiles() is only called when JobContext::HaveSomethingToDelete() is true, and the job context is unchanged after calling FindObsoleteFiles()

  1. Query live files outside of DB mutex

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)

{6CF6D5FB-AF52-4E5D-A8AC-321A8F1D0D18}

{8D5DEF79-B6F3-4CBC-A1F2-5D4F95C33A1A}

{9CA22B47-140B-4971-9C18-FB8F45E4AF79}

Signed-off-by: tabokie <xy.tao@outlook.com>
Signed-off-by: tabokie <xy.tao@outlook.com>
Copy link
Member

@Connor1996 Connor1996 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to take a look at the metrics of the number of snapshots

@tabokie
Copy link
Member Author

tabokie commented Jun 24, 2021

I want to take a look at the metrics of the number of snapshots

@Connor1996

http://172.16.5.123:43088/d/RDVQiEzZz/test-tikv-details?orgId=1&from=1624530590279&to=1624533504062

{2779A187-048D-4638-A747-0B9B8FF042CF}

@zhangjinpeng87
Copy link
Member

How about push back to rocksdb upstream?

@yiwu-arbug
Copy link
Collaborator

How about push back to rocksdb upstream?

Let's do that after code review.

Signed-off-by: tabokie <xy.tao@outlook.com>
@tabokie tabokie changed the title Optimize live files query when initializing purge jobs Defer live file query in FindObsoleteFiles Jun 25, 2021
@yiwu-arbug
Copy link
Collaborator

duplicated with #250

@yiwu-arbug yiwu-arbug closed this Jul 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants