JingsongLi commented on code in PR #1405:
URL: https://github.com/apache/paimon-rust/pull/1405#discussion_r4662639225
##########
crates/paimon/src/variant.rs:
##########
@@ -1436,15 +1453,41 @@ impl RebuildMetadata {
}
}
-/// Bound parsed dictionaries to one assembly call. Exact bytes, not a hash or
-/// an address, determine whether field IDs can be reused.
+/// Bound parsed dictionaries and compact validation results to one assembly
call.
+/// Exact bytes, not a hash or address, determine whether results can be
reused.
#[derive(Default)]
pub(crate) struct RebuildMetadataCache {
entries: VecDeque<Arc<RebuildMetadata>>,
bytes: usize,
+ validated: VecDeque<Box<[u8]>>,
+ validated_bytes: usize,
}
impl RebuildMetadataCache {
+ fn validate_compact_metadata(&mut self, bytes: &[u8]) -> Result<()> {
+ if let Some(index) = self
+ .validated
+ .iter()
+ .position(|entry| entry.as_ref() == bytes)
+ {
+ let entry = self.validated.remove(index).expect("entry exists");
+ self.validated.push_back(entry);
+ return Ok(());
+ }
+ validate_metadata(bytes)?;
+ if bytes.len() <= MAX_COMPACT_METADATA_BYTES {
+ while self.validated.len() >= MAX_COMPACT_METADATA_ENTRIES
+ || self.validated_bytes + bytes.len() >
MAX_COMPACT_METADATA_BYTES
Review Comment:
**[P2] Reuse dictionary validation when the working set exceeds 2 MiB**
The entry-count change fixes the previous 17-dictionary reproducer. Adding
one more dictionary brings the working set to 2,220,102 bytes. With round-robin
access, the 2 MiB byte limit evicts each dictionary before its next use, so
every row repeats the full UTF-8 and duplicate-key checks.
I reproduced this with 512 rows of `{"age":27}`, with `age` fully shredded
as `BIGINT` and no residual. The 18 source dictionaries each contain 5,362
unused keys. I measured Arrow reconstruction after an in-memory Parquet round
trip. The median over 14 debug rebuilds per commit was **2.7 ms** on the merge
base `cb8633dc` and **789.4 ms** on `a283a180`.
Could we borrow the metadata bytes from the Arrow batch and reuse successful
validation for exact byte matches?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]