Scoped sequence indexed-read locality candidate
Status: rejected after the standalone screen, against
d8635bfe951e98561d0b25703155a030d6e7054d / 005041.
The decision
and reviewed screen
record 24 body improvements and 564 regressions among 588 cases. Repeated indexed
reads benefit, but putting the cache in every view penalizes most ordinary calls.
No default sequence-view or API change is selected. The frozen proposal follows;
an explicit batch-read or cursor-reuse approach remains an unmeasured future idea.
A scoped Deque, HistoryRing or AppendLog view currently repeats resource admission, the 56-byte sequence header and an 8-byte read at each radix level for every indexed lookup. A loop using the same view cannot retain those facts even when its exact query scope excludes mutation. Existing cursors already seek once; their algorithm is not replaced here.
The candidate makes these three views SequenceView values with one bounded,
owned cache: the admitted header and interval plus two lazy 256-byte radix windows
for the top two levels. Deeper levels retain their narrow child read. No Store
special case, persistent cache, TLS state, heap allocation, format change or new
application configuration is introduced. The existing data.get(index) syntax and
all ordinary methods remain. Views are deliberately no longer Copy; persistent
handles and independently obtained views retain their existing behavior. Callers
need no new lifetime management.
Queries reuse admission only through Store's sealed exact immutable-scope proof.
Update views admit the current resource before comparing its revision, discarding
all saved private addresses when that revision changes. Thus mutations through a
second alias, resource retirement and slot reuse cannot authorize stale reads.
The cache contains owned bytes, never native pointers or backing slices. Its
RefCell borrow ends before arbitrary value decoding; the enclosing Store read
continues to exclude mutation. Index allocations initialize all 256 bytes, including
unused child slots. Reads do not assume a node fits one physical page.
A cold out-of-range lookup returns before loading the header or windows. Endpoint reads do not load radix windows. A first middle lookup can copy up to 512 bytes instead of two 8-byte child words, so single-hit and small-collection regressions are a real tradeoff to measure. The estimated view size is about 700 bytes on 64-bit targets; exact compiler layout is to be recorded by the native qualification. This storage is bounded per live view, independent of collection length.
The candidate also calls the already validated cursor page routine when the Deque/HistoryRing page wrapper has just constructed its cursor under the same uninterrupted Store read. This removes a second admission without extending its lifetime. Iterators otherwise retain their existing revision and fusion behavior.
Qualification
source-baseline.json records exact source hashes. source.patch contains only
collection-layer source changes. tests.patch adds both-placement alias mutation,
chunk/index retirement and reuse, Ring eviction, Log absolute-position pruning,
empty/refill, out-of-range and reopen tests to scoped_sequences.rs. Existing
cursor stale/fuse checks remain covered. supplemental.patch checks that warmed
views reject resources after their owning fields are replaced and the old aliases
are retired, both before and after reclamation. No build or benchmark has been
run by the candidate author.
Frozen SHA-256 hashes:
- Source:
3eb0ec02dab0f18f291092b625dda2881c2bf42f84f9f0b65407482654f4cf5d. - Tests:
2d990804a609210f49a6e01ce522846ed6e65e2a678f958f68300cc1d2ac2185. - Retirement test:
515c3880f781473a4577219603659f8ea7d8e6d9da196451871d31b42fd52700.
Native qualification should run the collection crate's existing sequence/log
unit and integration tests, especially scoped_sequences. The IC screen should
run complete Deque, HistoryRing and AppendLog catalogs at 100, 10,000 and 100,000
records on both placements. Inspect single hit/miss, get_hit_batch_32, front/back,
iteration/pages and all mutation controls. IC source evidence motivates avoiding
repeated source-page reads, but the exact instruction and page-charge effect must
come from this baseline's new ordinary Wasms; no fixed 80,000 saving is claimed.