P4: performance — passkey allocations, walk delegation, socket reuse - #27
Merged
Conversation
The RFC 3414 key expansion looped 16384 times, allocating two Strings per iteration (a rotated copy of the password + a 64-byte tiling). Feed the digest a single reused 64-byte buffer indexed cyclically instead. - v3/security: passkey builds one Bytes(64) buffer, no per-iteration allocation NOTE: the password is now indexed per octet (RFC 3414 operates on octets) rather than per character; identical for ASCII passwords (all real SNMP secrets), a correctness fix for non-ASCII ones. RFC A.2.1 vectors verified byte-identical. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The non-block walk duplicated the block form's loop. Delegate to it and document
that it buffers the whole subtree — prefer the block form or #bulk_walk to stream.
- client: walk(oid) : Array now calls walk(oid) { ... }
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
with_socket connected a fresh socket and closed it on every operation, churning sockets and changing the source port each call. Keep one socket, connected on first use and reused; reset it only on error. - client: connected_socket / reset_socket; with_socket no longer closes on success; add Client#close and a not-concurrency-safe note Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
64 tasks
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.
The P4 (performance) group from the audit (#7). One commit per item.
Commits
perf(v3): avoid per-iteration String allocation in passkey— the RFC 3414 key expansion looped 16384 times allocating two Strings each iteration (a rotated password copy + a 64-byte tiling). It now feeds the digest a single reusedBytes(64)buffer indexed cyclically.refactor(client): delegate the array walk to the block form— the non-blockwalkduplicated the block form's loop; it now delegates, and documents that it buffers the whole subtree (prefer the block form or#bulk_walkto stream).perf(client): reuse the UDP socket across requests—with_socketconnected a fresh socket and closed it on every operation, churning sockets and changing the source port each call. The socket is now connected on first use and reused; reset only on error. AddsClient#closeand a note that aClientis not safe for concurrent use.Tests
The passkey change is guarded byte-for-byte by the RFC 3414 A.2.1 vectors (
security_spec). The walk delegation is behaviour-preserving. Socket reuse is transport glue, exercised by thee2esuite. Deterministic 82/82, multi-threaded 82/82, legacy 3/3, ameba clean, format clean; commits bisect-clean.Tracked in #7.
🤖 Generated with Claude Code