Skip to content

Single-read verified hydration: drop redundant range re-read #87

Description

@valiantone

Summary

Remove the redundant range read in verified hydration: memory.hydrate_memory_detailed reads the byte range (src/hotmem/memory.py:244), then provenance.verify_range (src/hotmem/provenance.py:103) re-reads the same range to hash it.

Measured impact (spike #48, PR #84, B1)

Single-read hashing of the already-held bytes is ~1.16–1.65x faster than the current double-read path across range sizes (+16% at 100 MB). Both reads hit the page cache, so the cost is copy+syscalls, not I/O — still pure overhead.

Proposal

Hash the bytes already read in hydrate (or add a verify API that accepts in-memory bytes), keeping the same ProvenanceError semantics on mismatch.

Acceptance criteria

  • Verified hydration reads each range once.
  • Parity: digests identical to current path (spike B1 parity arms are reusable as fixtures).
  • Benchmarks in bench/native_spike/results.json show the improvement; no API/behavior change otherwise.

Context

Spike recommendation follow-up #1: bench/native_spike/README.md. Related: #48, #38, #40.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:hydrationHydration profiles and zero-copy/reference hydrationenhancementNew feature or requestpriority:p2Do after evidence or dependency gates; optional portability capabilityv0.2.NEXTCommitted for a future 0.2.x release; not yet pinned to 0.2.4/0.2.5v0.2.xHotMem post-v0.2 follow-up work

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions