Vectorize bit packing and remove the payload clone from ring sends - #140
Merged
Conversation
dkales
previously approved these changes
Aug 17, 2026
dkales
left a comment
Collaborator
There was a problem hiding this comment.
does what it says, but is a bit crude IMO
Might be worth investigating if the serialization can work like this in general for all types
philsippl
force-pushed
the
codex/cpu-linear-scan-primitives
branch
from
August 24, 2026 12:48
b1ffb57 to
a558365
Compare
Two allocation/copy reductions in the exact-scan threshold hot path, both byte-identical on the wire: - pack_bits/unpack_bits packed one bit per iteration with per-bit index arithmetic and bounds checks; they now process a byte (8 bits, LSB-first as before) per step. - send_ring_vec cloned the whole payload Vec into an owned NetworkValue, which the striped transport then serialized again into its wire buffer - two full copies per protocol message. A PreFramed NetworkValue variant carries the message already in wire format (serialized once from the borrowed slice), and the striped send consumes it via into_network() without re-serializing. PreFramed never appears on the wire as itself; into_vec/unpack_bits decode it transparently so in-process LocalNetworking paths are unaffected. Measured on the iris-mpc CPU linear scan (3x r8g.24xlarge, 1M records): these were ~11% memcpy + ~6% pack_bits of threshold-side cycles; the change is worth ~2% end-to-end there (6.33M -> 6.47M comparisons/s). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
philsippl
force-pushed
the
codex/threshold-buffer-reuse
branch
from
August 24, 2026 13:11
2053bb6 to
bb7ee68
Compare
dkales
approved these changes
Aug 24, 2026
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.
Stacked on #138. Two allocation/copy reductions in the exact-scan threshold hot path. Wire format is byte-identical; no protocol changes.
What
pack_bits/unpack_bits: were scalar per-bit loops with per-bit index arithmetic and bounds-checked writes; now process a byte (8 bits, LSB-first exactly as before) per step.send_ring_vecpayload clone: it cloned the entire payloadVecinto an ownedNetworkValue, which the striped transport then serialized again into its wire buffer — two full copies per protocol message. A newNetworkValue::PreFramedvariant carries the message already in wire format (serialized once from the borrowed slice), and the striped send consumes it via the newinto_network()without re-serializing.PreFramednever appears on the wire as itself;into_vec/unpack_bitsdecode it transparently, so in-processLocalNetworkingpaths are unaffected.Why / measured
Profiling the iris-mpc CPU linear scan on 3× r8g.24xlarge (1M records, both orientations), the threshold side paces the whole request and spends ~11% of its cycles in memcpy and ~6% in
pack_bits. With this change the end-to-end scan goes from 6.33M to 6.47M comparisons/s (331.5 → 324.5 ms/request), measured with worldcoin/iris-mpc#2348.Validated: crate test suite, the full iris-mpc-cpu suite against the patched crate, and the 3-node TCP e2e (striped TLS transport, mirror detection) with cross-party agreement.
🤖 Generated with Claude Code