JingsongLi commented on code in PR #1501:
URL: https://github.com/apache/paimon-rust/pull/1501#discussion_r4674492730
##########
crates/paimon/src/variant.rs:
##########
@@ -1448,20 +1507,34 @@ impl RebuildMetadata {
let offset_size = metadata_offset_size(bytes)?;
let dict_size = read_unsigned(bytes, 1, offset_size)?;
let mut key_ids = HashMap::with_capacity(dict_size);
+ let mut keys = Vec::with_capacity(dict_size);
for id in 0..dict_size {
- key_ids.insert(get_metadata_key(bytes, id)?, id);
- }
- let estimated_bytes = key_ids.keys().fold(
- bytes.len().saturating_add(
- key_ids
- .capacity()
- .saturating_mul(std::mem::size_of::<(String, usize)>() +
1),
- ),
- |bytes, key| bytes.saturating_add(key.capacity()),
+ let key: Arc<str> = Arc::from(get_metadata_key_ref(bytes, id)?);
+ key_ids.insert(key.clone(), id);
+ keys.push(key);
+ }
+ let estimated_bytes = keys.iter().fold(
+ bytes
+ .len()
+ .saturating_add(
+ key_ids
+ .capacity()
+ .saturating_mul(std::mem::size_of::<(Arc<str>,
usize)>() + 1),
+ )
+ .saturating_add(
+ keys.capacity()
+ .saturating_mul(std::mem::size_of::<Arc<str>>()),
Review Comment:
**[P2] Keep reusable dictionaries within the existing rebuild cache budget**
The ID vector and per-key `Arc` allocations push eight dictionaries that fit
in the current 8 MiB cache past the admission limit. With these eight
dictionaries alternating in a batch, each insert evicts the one needed next, so
the scan reparses every dictionary for every row. I wrote an ordinary shredded
Parquet table with 64 rows, eight rotating dictionaries of 9,501 keys, and
1,501 populated fields per row. A full read of the same files returned correct
values on both builds. Across seven warm local debug scans, the median rose
from 214 ms on `main` to 576 ms on this head. A compact ID-to-offset index over
the already validated dictionary could keep fast ID lookup without this
eviction cliff. Please include the rotating-dictionary case in the benchmark.
--
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]