perf: build + serialization fast paths - #106
Merged
Merged
Conversation
thin LTO gives cross-crate inlining with ~30% less compile time than fat LTO. codegen-units = 1 enables maximum LLVM optimization within each crate. strip = "symbols" reduces binary size ~40% with no runtime cost. intentionally skip panic = "abort" to preserve stack unwinding for graceful shutdown.
adds a `wire` module with pre-serialized byte constants for OK, PONG, NULL, and small integers (0, 1, -1). Frame::serialize() now matches these common values and writes the constant bytes directly, avoiding per-field formatting overhead. these are the hottest responses in typical workloads — SET returns OK, EXISTS/DEL/EXPIRE return 0 or 1, GET misses return NULL.
AofRecord::to_bytes() now pre-computes the expected size via estimated_size() and allocates with Vec::with_capacity(). this eliminates 2-4 intermediate reallocations per persistence write, especially for SET records with large values.
SnapEntry::estimated_size() pre-computes the serialized size so write_entry() can allocate the buffer in a single shot. eliminates repeated growth + copy cycles for entries with large values or many collection elements.
kacy
added a commit
that referenced
this pull request
Feb 19, 2026
* perf: enable thin LTO, single codegen unit, and symbol stripping thin LTO gives cross-crate inlining with ~30% less compile time than fat LTO. codegen-units = 1 enables maximum LLVM optimization within each crate. strip = "symbols" reduces binary size ~40% with no runtime cost. intentionally skip panic = "abort" to preserve stack unwinding for graceful shutdown. * perf: pre-computed wire bytes for common RESP3 responses adds a `wire` module with pre-serialized byte constants for OK, PONG, NULL, and small integers (0, 1, -1). Frame::serialize() now matches these common values and writes the constant bytes directly, avoiding per-field formatting overhead. these are the hottest responses in typical workloads — SET returns OK, EXISTS/DEL/EXPIRE return 0 or 1, GET misses return NULL. * perf: add capacity hints to AOF record serialization buffer AofRecord::to_bytes() now pre-computes the expected size via estimated_size() and allocates with Vec::with_capacity(). this eliminates 2-4 intermediate reallocations per persistence write, especially for SET records with large values. * perf: add capacity hints to snapshot entry serialization buffer SnapEntry::estimated_size() pre-computes the serialized size so write_entry() can allocate the buffer in a single shot. eliminates repeated growth + copy cycles for entries with large values or many collection elements. * style: fix formatting in persistence capacity hints
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
summary
tier 1 performance optimizations from the throughput/latency audit. these are the highest-impact, lowest-risk changes.
AofRecord::estimated_size()pre-computes the serialized size soto_bytes()allocates once instead of growing 2-4 times per recordSnapEntry::write_entry()— single allocation for the entry bufferintentionally skipped
panic = "abort"to preserve stack unwinding for graceful shutdown.what was tested
cargo test --workspace --features protobuf— all tests passcargo clippy --workspace --features protobuf -- -D warnings— clean