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

refactor(storage): use arc SstableInfo in HummockVersion #18573

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

zwang28
Copy link
Contributor

@zwang28 zwang28 commented Sep 18, 2024

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

What's changed and what's your intention?

Given that compute node now will retain many recent hummock versions, to reduce its memory footprint, this PR stores and reuses Arc<SstableInfo> instead of SstableInfo in HummockVersion for compute node.

Two major changes:

  • make relevant methods compatible with both Arc<SstableInfo> and SstableInfo.
  • add a SstableInfoCache in HummockObserverNode, where PbHummockVersion and PbHummockVersionDelta are converted from to types, i.e. HummockVersion<Arc<SstableInfo>>. Arc<SstableInfo> is retrieved from the cache whenever feasible.

Please find more details about how the Arc<SstableInfo> is cached and shared in impl From<&PbSstableInfo> for SstableInfoRef in sstable_info_ref.rs.

This PR is part1 of the refactor, aiming to adapt the related methods to be compatible with both Arc<SstableInfo> and SstableInfo. After this PR, the HummockVersion in compute node will use Arc<SstableInfo>. However these Arc<SstableInfo> is not reused across HummockVersion, i.e. the memory footprint is not reduced yet. It'll be done in another PR after this one.

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.

@zwang28 zwang28 force-pushed the wangzheng/arc_sstinfo branch 3 times, most recently from 062bcb2 to 365b2e4 Compare September 18, 2024 06:48
@zwang28 zwang28 marked this pull request as ready for review September 18, 2024 07:05
@zwang28 zwang28 force-pushed the wangzheng/arc_sstinfo branch 4 times, most recently from 32f5534 to 852b9a7 Compare September 18, 2024 07:55
@zwang28 zwang28 requested a review from a team as a code owner September 19, 2024 09:45
}

#[derive(Debug, PartialEq, Clone, Default)]
pub struct SstableInfoRef {
Copy link
Contributor

Choose a reason for hiding this comment

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

As we have implemented our own SstableInfo struct, can we just make the implementation of the clone of SstableInfo a shallow clone instead of explicitly introducing a struct wrapping it with arc? In this way, most of the changes in this PR can be avoided.

}

task_local! {
pub static SSTABLE_INFO_CACHE: *mut SstableInfoCache;
Copy link
Contributor

Choose a reason for hiding this comment

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

May use LazyCell

pub type HummockVersionType = HummockVersionCommon<SstableInfoType>;
pub type HummockVersionDeltaType = HummockVersionDeltaCommon<SstableInfoType>;

pub trait SstableInfoReader {
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of implementing this trait, it's easier to use impl Deref<Target = SstableInfo>

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.

2 participants