[core] In memory caching of stack length (clen)#19
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces an in-memory cache of the committed payload length (“clen”) so len/is_empty can be answered under a read lock without performing file-size syscalls, while keeping the cache synchronized with on-disk header updates.
Changes:
- Added an in-memory committed-length cache (
clen) to the Rust and C implementations and plumbed it through write paths. - Updated Rust
BStack::len/BStack::is_emptyand Cbstack_len/bstack_is_emptyto read the cached length rather than callingmetadata/fstat/GetFileSizeEx. - Updated documentation (crate docs, README, changelog, and C header comments) to reflect the new caching behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib.rs | Stores (File, clen) behind the rwlock and updates len/is_empty to use cached committed length. |
| README.md | Documents that len/is_empty no longer require a syscall due to caching. |
| CHANGELOG.md | Notes the no-syscall behavior change for Rust/C length queries without API/signature changes. |
| c/bstack.h | Updates API comments to describe cached len/is_empty semantics. |
| c/bstack.c | Adds clen to bstack_t, updates length reads, and threads cache updates through length-committing write paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Description: Caching the length of the bstack to reduce need for io syscalls when reading length.
New Feature: No; No change to API
Important Feature: No
Type: Core - Optimization
Feature Flags: None
Breaking change: No
New Types: None
Rust Only: No
Fuzz: Not needed
Safety Review: Needed: Crash Safety, Invariants, Concurrency