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

Improve CPU Efficiency of ApproximateSize (part 1) #5613

Closed
wants to merge 1 commit into from

Conversation

elipoz
Copy link
Contributor

@elipoz elipoz commented Jul 23, 2019

  1. Avoid creating the iterator in order to call BlockBasedTable::ApproximateOffsetOf(). Instead, directly call into it.
  2. Optimize BlockBasedTable::ApproximateOffsetOf() keeps the index block iterator in stack.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@elipoz has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

db/version_set.cc Show resolved Hide resolved
@facebook-github-bot
Copy link
Contributor

@elipoz has updated the pull request. Re-import the pull request

@facebook-github-bot
Copy link
Contributor

@elipoz has updated the pull request. Re-import the pull request

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@elipoz has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@@ -505,4 +506,31 @@ void TableCache::Evict(Cache* cache, uint64_t file_number) {
cache->Erase(GetSliceForFileNumber(&file_number));
}

uint64_t TableCache::ApproximateSize(Version* v, const FdWithKeyRange& f,
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't pass Version here.
I believe there is TableCache::env_options_, and we need to pass in InternalComparator and prefix extractor separately.

@facebook-github-bot
Copy link
Contributor

@elipoz has updated the pull request. Re-import the pull request

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@elipoz has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

db/table_cache.h Outdated
@@ -170,6 +171,11 @@ class TableCache {
}
}

uint64_t ApproximateSize(const FdWithKeyRange& f, const Slice& key,
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to add comment about what the function does. Also, does it makes sense to call it ApproximateOffsetOf() instead, considering that we are returning the file offset up to the key?

delete iter;
TableReader* table_reader = f.file_metadata->fd.table_reader;
if (table_reader) {
result = table_reader->ApproximateOffsetOf(key, caller);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we put this call into TableCache::ApproximateSize too, just like other TableCache functions do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@siying is this call made from VersionSet::ApproximateSize always going to return not null?

TableCache* table_cache = v->cfd_->table_cache();

@facebook-github-bot
Copy link
Contributor

@elipoz has updated the pull request. Re-import the pull request

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@elipoz has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@elipoz has updated the pull request. Re-import the pull request

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@elipoz has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@siying siying left a comment

Choose a reason for hiding this comment

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

Awesome!

@facebook-github-bot
Copy link
Contributor

@elipoz merged this pull request in 6b7fcc0.

merryChris pushed a commit to merryChris/rocksdb that referenced this pull request Nov 18, 2019
Summary:
1. Avoid creating the iterator in order to call BlockBasedTable::ApproximateOffsetOf(). Instead, directly call into it.
2. Optimize BlockBasedTable::ApproximateOffsetOf() keeps the index block iterator in stack.
Pull Request resolved: facebook#5613

Differential Revision: D16442660

Pulled By: elipoz

fbshipit-source-id: 9320be3e918c139b10e758cbbb684706d172e516
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants