-
Notifications
You must be signed in to change notification settings - Fork 637
fix(obserivation): fix missed hitmap updates, fix drop order #14788
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
Conversation
Signed-off-by: MrCroxx <[email protected]>
Signed-off-by: MrCroxx <[email protected]>
Signed-off-by: MrCroxx <[email protected]>
Signed-off-by: MrCroxx <[email protected]>
@@ -246,7 +261,10 @@ impl BlockIterator { | |||
} | |||
|
|||
/// Searches the restart point index that the given `key` belongs to. | |||
fn search_restart_point_index_by_key(&self, key: FullKey<&[u8]>) -> usize { | |||
fn search_restart_point_index_by_key(&mut self, key: FullKey<&[u8]>) -> usize { | |||
// Create a temporary local hitmap. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just update the local hitmap instead of creating a new one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The block binary search requires the iterator's immutable reference, and the hitmap cannot be updated in the closure for it requires the mutable reference. (I forgot to restore this diff line, let me fix it.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the immutable reference is required to call decode_prefix_at
of self
. However, looking into the implementation of decode_prefix_at
, it only uses self.block
. Therefore, if we change to implement decode_prefix_at
as method of BlockHolder
, we don't need the immutable reference of self
here. And it makes sense to me to make decode_prefix_at
a method of a single block instead of a method of BlockIterator
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we can just inline the call of decode_prefix_at
as
KeyPrefix::decode(
&mut &self.block.data()[offset..],
offset,
key_len_type,
value_len_type,
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the offset
information is duplicated here, once in slice range, and once as method parameter.
Maybe we can change the first parameter of decode
from buf: &mut impl Buf
to &[u8]
and we generate the &mut &self.block.data()[offset..]
inside the code of KeyPrefix::decode
so that we remove the duplicated offset information in method call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for inline call, but I think duplicated offset
sounds okay here, it will unify the encode/decode parameters of KeyPrefix
.
/// | ||
/// - `hitmap` is supposed to be updated each time accessing the block data in a new position. | ||
/// - `hitmap` is supposed to be dropped before `block` | ||
hitmap: ManuallyDrop<LocalHitmap<HITMAP_ELEMS>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current way of report hitmap leverages the drop
of local hitmap, but the correctness of the drop
of local hitmap should depend on the correct implementation of the drop
of BlockIterator
. If so, I think we'd better decouple hitmap and local hitmap, which means we won't associate a hitmap the local hitmap, and the local hitmap won't implement its drop. We only manually apply the local hitmap to the block hitmap in the drop
of BlockIterator
.
Signed-off-by: MrCroxx <[email protected]>
Signed-off-by: MrCroxx <[email protected]>
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
FIx:
Checklist
./risedev check
(or alias,./risedev c
)Documentation
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.