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

fix(storage): do not fetch all sst meta when create iterator #9517

Merged
merged 18 commits into from
May 5, 2023

Conversation

Little-Wallace
Copy link
Contributor

@Little-Wallace Little-Wallace commented Apr 27, 2023

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

Checklist For Contributors

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • All checks passed in ./risedev check (or alias, ./risedev c)

Checklist For Reviewers

Documentation

  • My PR DOES NOT contain user-facing changes.
Click here for Documentation

Types of user-facing changes

Please keep the types that apply to your changes, and remove the others.

  • Installation and deployment
  • Connector (sources & sinks)
  • SQL commands, functions, and operators
  • RisingWave cluster configuration changes
  • Other (please specify in the release note below)

Release note

Signed-off-by: Little-Wallace <[email protected]>
Copy link
Contributor

@soundOfDestiny soundOfDestiny left a comment

Choose a reason for hiding this comment

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

Incorrect.

Signed-off-by: Little-Wallace <[email protected]>
Signed-off-by: Little-Wallace <[email protected]>
Copy link
Contributor

@soundOfDestiny soundOfDestiny left a comment

Choose a reason for hiding this comment

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

seems unnecessary

Signed-off-by: Little-Wallace <[email protected]>
Copy link
Contributor

@soundOfDestiny soundOfDestiny left a comment

Choose a reason for hiding this comment

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

incorrect

Signed-off-by: Little-Wallace <[email protected]>
Copy link
Contributor

@soundOfDestiny soundOfDestiny left a comment

Choose a reason for hiding this comment

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

Perhaps we can improve.

self.current.as_ref().unwrap().current_epoch()
}

fn next(&mut self) -> Self::NextFuture<'_> {
Copy link
Contributor

Choose a reason for hiding this comment

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

In current implementation, after a next call, next_extended_user_key may stay invariant. Is this bad-taste?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But everywhere we call next_extended_user_key would always collect all keys whose user-key equals

Copy link
Contributor

@soundOfDestiny soundOfDestiny May 4, 2023

Choose a reason for hiding this comment

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

But everywhere we call next_extended_user_key would always collect all keys whose user-key equals

In MergeIterator, everywhere we call next_extended_user_key would always collect all keys IN OTHER ITERATORS whose user-key equals, but except the iterator itself

@TennyZhuang TennyZhuang changed the title fix(storage:): do not fetch all sst meta when create iterator fix(storage): do not fetch all sst meta when create iterator Apr 28, 2023
Copy link
Contributor

@soundOfDestiny soundOfDestiny left a comment

Choose a reason for hiding this comment

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

I'm ok if self.current.take() is in seek, but it should then be in rewind as well.

Copy link
Contributor

@soundOfDestiny soundOfDestiny left a comment

Choose a reason for hiding this comment

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

Incorrect.

Signed-off-by: Little-Wallace <[email protected]>
Copy link
Contributor

@soundOfDestiny soundOfDestiny left a comment

Choose a reason for hiding this comment

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

duplicate seek

Copy link
Contributor

@soundOfDestiny soundOfDestiny left a comment

Choose a reason for hiding this comment

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

typo

Copy link
Contributor

@soundOfDestiny soundOfDestiny left a comment

Choose a reason for hiding this comment

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

as in comment

Signed-off-by: Little-Wallace <[email protected]>
Copy link
Contributor

@soundOfDestiny soundOfDestiny left a comment

Choose a reason for hiding this comment

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

because we have checked self.sstables[self.idx + 1].range_tombstone_count > 0 before

Copy link
Contributor

@soundOfDestiny soundOfDestiny left a comment

Choose a reason for hiding this comment

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

incorrect

Signed-off-by: Little-Wallace <[email protected]>
Copy link
Contributor

@soundOfDestiny soundOfDestiny left a comment

Choose a reason for hiding this comment

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

the semantic of next_range_epoch() does not match

Signed-off-by: Little-Wallace <[email protected]>
Signed-off-by: Little-Wallace <[email protected]>
Signed-off-by: Little-Wallace <[email protected]>
Copy link
Contributor

@soundOfDestiny soundOfDestiny left a comment

Choose a reason for hiding this comment

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

incorrect


ord == Less || ord == Equal
}
DirectionEnum::Backward => {
let ord = FullKey::decode(table.largest_key()).cmp(&key);

let ord = FullKey::decode(largest_key(table)).cmp(&key);
Copy link
Contributor

Choose a reason for hiding this comment

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

If right key range is excluded, we will skip the key itself unexpectedly.

Signed-off-by: Little-Wallace <[email protected]>
Copy link
Contributor

@soundOfDestiny soundOfDestiny left a comment

Choose a reason for hiding this comment

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

LGTM

@soundOfDestiny soundOfDestiny enabled auto-merge May 5, 2023 15:19
@soundOfDestiny soundOfDestiny added this pull request to the merge queue May 5, 2023
Merged via the queue into risingwavelabs:main with commit 844175e May 5, 2023
Copy link
Contributor

@Li0k Li0k left a comment

Choose a reason for hiding this comment

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

Thanks for the effort

// We would fill block to high priority cache for level-0
self.sstable_store
.sstable_syncable(sstable_info, &local_stats)
if sstables.len() > 1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO, we need some doc to explain that we remove hit_sstable_bloom_filter when non_overlapping sstable.size() > 1. It may result in better code readability

Copy link
Collaborator

Choose a reason for hiding this comment

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

IMO, we need some doc to explain that we remove hit_sstable_bloom_filter when non_overlapping sstable.size() > 1. It may result in better code readability

+1

ord == Greater || ord == Equal
let ord = FullKey::decode(largest_key(table)).cmp(&key);
ord == Greater
|| (ord == Equal && !table.key_range.as_ref().unwrap().right_exclusive)
Copy link
Contributor

Choose a reason for hiding this comment

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

This logic is easy to use wrongly, encapsulate it into a function or add more comments to explain it?

// We would fill block to high priority cache for level-0
self.sstable_store
.sstable_syncable(sstable_info, &local_stats)
if sstables.len() > 1 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

IMO, we need some doc to explain that we remove hit_sstable_bloom_filter when non_overlapping sstable.size() > 1. It may result in better code readability

+1

.prefetch(&self.sstable_store, &mut self.stats)
let table = self
.sstable_store
.sstable(&self.tables[idx], &mut self.stats)
Copy link
Collaborator

Choose a reason for hiding this comment

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

random thought: we can prefetch the next sstable meta similar to the block prefetch in sstable iterator. not sure how much improvement we can get though

Copy link
Contributor

Choose a reason for hiding this comment

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

random thought: we can prefetch the next sstable meta similar to the block prefetch in sstable iterator. not sure how much improvement we can get though

We can get more memory :rolling_on_the_floor_laughing:

Copy link
Collaborator

Choose a reason for hiding this comment

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

random thought: we can prefetch the next sstable meta similar to the block prefetch in sstable iterator. not sure how much improvement we can get though

We can get more memory :rolling_on_the_floor_laughing:

True. But it looks acceptable because the memory usage is proportional to number of levels, not number of SSTs, and we have very few levels.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But after we support meta-cache refill after compaction, the meta-cache miss rate is very low.
So it is not necessary to prefetch the next TableHolder for delete-range (

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