forked from KillingSpark/zstd-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
perf(encoding): reuse encoded scratch buffer across streaming blocks #47
Copy link
Copy link
Open
Labels
P2-mediumMedium priority — important improvementMedium priority — important improvementenhancementNew feature or requestNew feature or requestperformancePerformance optimizationPerformance optimization
Description
Context
Found during review of #45.
Problem
StreamingEncoder::encode_block() allocates a fresh Vec<u8> (encoded) for every emitted block. On the streaming hot path with large inputs, this adds avoidable allocation churn.
Suggested approach
Add an encoded_scratch: Vec<u8> field to StreamingEncoder, clear() it per block, and reuse the capacity across calls — similar to how FrameCompressor reuses its output buffer.
Files involved
zstd/src/encoding/streaming_encoder.rs(line 280)
Time estimate
1h
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2-mediumMedium priority — important improvementMedium priority — important improvementenhancementNew feature or requestNew feature or requestperformancePerformance optimizationPerformance optimization