Draft
Conversation
Co-authored-by: PSeitz <1109503+PSeitz@users.noreply.github.com>
Co-authored-by: PSeitz <1109503+PSeitz@users.noreply.github.com>
… literal copy 1. decompress_safe.rs: Replace clone + read_u16() call with direct array indexing in the hot loop. Since input is &[u8; 16] and literal_length is 0-14, the indices are provably in bounds. This eliminates a clone, function call, bounds check, and error handling path from the hot loop. 2. compress.rs: Pass a wider slice (+8 bytes) to extend_from_slice_wild in the safe-encode path, enabling efficient fixed-size copy paths in slice_copy for small literals. This matches the unsafe version's behavior of unconditionally copying 8/16/24 bytes. Safe because MFLIMIT guarantees sufficient input bytes and get_maximum_output_size provides sufficient output capacity. Co-authored-by: PSeitz <1109503+PSeitz@users.noreply.github.com>
Co-authored-by: PSeitz <1109503+PSeitz@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Investigate and implement performance improvements
Optimize safe encode/decode hot paths
Mar 14, 2026
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.
Two targeted improvements to the safe (default) code paths, each eliminating unnecessary work from hot loops.
Safe decompression hot loop: direct offset read — Replace
read_u16(input, &mut literal_length.clone())?withu16::from_le_bytes([input[literal_length], input[literal_length + 1]]). Sinceinputis&[u8; 16]andliteral_lengthis 0–14 (enforced bydoes_token_fit), this eliminates a clone, function call,.get()bounds check, and an unreachable?error path from the innermost loop.Safe compression literal copy: enable actual wild copy — The safe
copy_literals_wildwas passing an exactly-sized slice, defeating the wild copy optimization entirely. Now passeslen + 8bytes soslice_copyhits efficient fixed-sizedouble_copy_trickpaths for small literals, matching what the unsafe path already does. Bounds safety: MFLIMIT guarantees ≥12 bytes of input headroom;get_maximum_output_sizemargin covers output.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/repos/main--/rust-lz-fear/commits/HEAD/home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/bin/cargo /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/bin/cargo test(http block)If you need me to access, download, or install something from one of these locations, you can either:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.