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

perf: batch json decode checkpoint actions when writing to parquet #2983

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions crates/core/src/protocol/checkpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,18 +353,22 @@ fn parquet_bytes_from_state(
// Count of actions
let mut total_actions = 0;

for j in jsons {
let buf = serde_json::to_string(&j?).unwrap();
let _ = decoder.decode(buf.as_bytes())?;

total_actions += 1;
let span = tracing::debug_span!("serialize_checkpoint").entered();
for chunk in &jsons.chunks(CHECKPOINT_RECORD_BATCH_SIZE) {
let mut buf = Vec::new();
for j in chunk {
serde_json::to_writer(&mut buf, &j?)?;
total_actions += 1;
}
let _ = decoder.decode(&buf)?;
while let Some(batch) = decoder.flush()? {
writer.write(&batch)?;
}
}
drop(span);

let _ = writer.close()?;
debug!("Finished writing checkpoint parquet buffer.");
debug!(total_actions, "Finished writing checkpoint parquet buffer.");

let checkpoint = CheckPointBuilder::new(state.version(), total_actions)
.with_size_in_bytes(bytes.len() as i64)
Expand Down
Loading