Restore HistoryBuf write performance - #687
Open
wyf-777 wants to merge 2 commits into
Open
Conversation
Reuse the backing slice and access the write slot without repeated bounds checks. The private write-position invariant keeps the unchecked access in bounds, while zero-capacity buffers continue to panic. Add a Divan benchmark for the regression reported in issue rust-embedded#598. Assisted-by: OpenAI Codex:GPT-5
Document the restored write performance in the Unreleased section.
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
HistoryBuf(fer)::write()with heapless 0.9.1 #598.HistoryBuf::write()optimization after the generic storage/view refactor introduced repeated backing-slice indexing that LLVM could not eliminate.Safety
write_atstarts at zero and is reset before reachingcapacity. The zero-capacity case is rejected before the unchecked access, and debug builds additionally assertwrite_at < capacity. The HistoryBuf test suite passes under Miri, including wraparound, drop-panic, and zero-capacity paths.Performance
Windows x86_64, Rust 1.97.1, 8 MiB issue workload (
cargo bench --bench history_buf):Testing
cargo test --features "alloc,mpmc_large,portable-atomic-critical-section,serde,ufmt,bytes,zeroize,embedded-io-v0.7"(294 unit, 8 concurrency, and 204 doc tests passed)cargo check --features defmtcargo test --release history_buf::tests(15 passed)MIRIFLAGS=-Zmiri-ignore-leaks cargo +nightly-2025-10-11 miri test history_buf::tests(15 passed)cargo +nightly-2025-10-11 fmt --all -- --checki686-unknown-linux-muslwith all configured featuresallocchecks fori686-unknown-linux-musl,riscv32imc-unknown-none-elf,armv7r-none-eabi,thumbv6m-none-eabi,thumbv7m-none-eabi,thumbv8m.base-none-eabi, andthumbv8m.main-none-eabigit diff --checkThe Windows host cannot link executable tests with the embedded
defmtfeature because its runtime symbols are intentionally supplied by an embedded target; the feature itself passedcargo check, and the repository CI exercises the supported Linux configuration.AI assistance
OpenAI Codex (GPT-5) assisted with issue analysis, implementation, benchmark construction, test execution, and pull request wording. The commit includes the corresponding
Assisted-bytrailer.