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

feat(storage): improve block memory usage #15024

Merged
merged 7 commits into from
Feb 23, 2024
Merged

Conversation

Li0k
Copy link
Contributor

@Li0k Li0k commented Feb 6, 2024

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

What's changed and what's your intention?

part of #14949

related to #15022

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added test labels as necessary. See details.
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

Bytes::from(decoded)

assert_eq!(uncompressed_capacity, decoded.len());
decoded.freeze()
Copy link
Contributor

Choose a reason for hiding this comment

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

I check the implement of Bytes and I find that it will not allocate and copy any extra memory when convert Vec to Bytes. It just record the length of content. cc @MrCroxx

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I revert it first. It looks same when len == cap

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And, Enhanced assert limitations

@Li0k Li0k requested a review from MrCroxx February 6, 2024 10:02
Copy link
Contributor

@MrCroxx MrCroxx left a comment

Choose a reason for hiding this comment

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

Please provide the memory usage comparasion of w/wo this PR. 🥰

.read_to_end(&mut decoded)
.map_err(HummockError::decode_error)?;
debug_assert_eq!(decoded.capacity(), uncompressed_capacity);
assert_eq!(read_size, uncompressed_capacity);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe debug_assert_eq is better here.

Copy link
Contributor

@Little-Wallace Little-Wallace Feb 7, 2024

Choose a reason for hiding this comment

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

check equal is enough light for decompress

@@ -704,6 +707,15 @@ impl<W: SstableWriter, F: FilterBuilder> SstableBuilder<W, F> {
data_len, block_meta.offset
)
});

if data_len as usize > self.options.capacity * 2 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this log necessary to keep?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer to keep this log for debugging, Therefore, we can quickly identify similar problems, such as not switching block

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO, that log shouldn't show up under normal circumstances.

Copy link
Contributor

@Little-Wallace Little-Wallace left a comment

Choose a reason for hiding this comment

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

LGTM

@Li0k Li0k enabled auto-merge February 21, 2024 02:57
auto-merge was automatically disabled February 22, 2024 06:09

Merge queue setting changed

@Li0k Li0k enabled auto-merge February 22, 2024 07:55
auto-merge was automatically disabled February 23, 2024 01:45

Merge queue setting changed

@Li0k Li0k added this pull request to the merge queue Feb 23, 2024
Merged via the queue into main with commit 41e723b Feb 23, 2024
26 of 27 checks passed
@Li0k Li0k deleted the li0k/storage_improve_block_memory branch February 23, 2024 02:59
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.

3 participants