Skip to content

Share bytes by Arc in keyhive protocol#236

Merged
jtfmumm merged 4 commits into
mainfrom
jtfm/memory-fixes
Jun 9, 2026
Merged

Share bytes by Arc in keyhive protocol#236
jtfmumm merged 4 commits into
mainfrom
jtfm/memory-fixes

Conversation

@jtfmumm

@jtfmumm jtfmumm commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Store the periodic event cache's serialized events as Arc<[u8]> and hand every peer-pair sync response Arc dupes instead of deep-copying the byte set.

During cold start of a new peer, we normally sync exactly the entire public set of keyhive ops from the server to the peer. When there are many concurrent peers cold-starting at the same time, we don't want to copy those bytes unnecessarily. The cache now builds that map once per refresh and shares it by Arc.

Testing

  • New tests cover the Arc-sharing semantics of events_for_peer_pair (shared on the public-only path, a fresh map on the private path) and the byte round-trips.
  • Adds a criterion bench (periodic_cache) for the refresh build cost and an opt-in dhat heap membench (cache/membench.rs, behind a new dhat-heap feature) that measures the working set for the periodic keyhive op cache.

@jtfmumm jtfmumm requested review from alexjg and expede as code owners June 8, 2026 12:05
@jtfmumm jtfmumm force-pushed the jtfm/memory-fixes branch from 13cfa40 to 75804b3 Compare June 8, 2026 12:34
@jtfmumm jtfmumm force-pushed the jtfm/memory-fixes branch from 75804b3 to a067229 Compare June 8, 2026 13:28

@expede expede left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly a couple style / long term legibility questions, but the actual functionality seems good!

Comment thread subduction_keyhive/src/message.rs Outdated
Comment thread subduction_keyhive/src/message.rs Outdated
Comment thread subduction_keyhive/src/protocol.rs Outdated
Comment thread subduction_keyhive/src/cache.rs Outdated
@jtfmumm jtfmumm merged commit 6660e77 into main Jun 9, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants