Repository navigation
perf(relay): avoid allocating String in MessageClass::from_frame - #1395
tirthraj01 wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: e78db58 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. Walkthrough
Change: Refactor Merge Risk:
|
Confidence Score: 5/5
[Low impact] The PR appears safe to merge.
|
Fixes #1385
Summary
StringinMessageClass::from_frame(crates/nostream-relay/src/limits.rs) with a stack[u8; 8]buffer and byte slice match (&word[..len]), keeping all existing parser behavior identical.a_frame_whose_prefix_is_not_ascii_is_classified_without_panickingincrates/nostream-relay/tests/limits.rs.Measured Effect
8bytes) per classified inbound frame (7 allocations/56 bytesacross the 7 valid frame classes measured viaGlobalAlloc).0allocations (0 bytes) per frame (1 allocation per inbound frame removed).Verification
cargo fmt --all --checkcargo clippy -p nostream-relay --all-targets --all-features -- -D warningscargo clippy -p nostream-relay --lib --bins --all-features -- -D warnings -D clippy::unwrap_used -D clippy::expect_used -D clippy::todo -D clippy::unimplemented -D clippy::paniccargo test -p nostream-relay --lib --test limits --all-features(30unit tests +35limitstests passed)cargo test -p nostream-relay --test handlers an_event_burst_leaves_the_req_window_intact --all-features(1passed)Summary by CodeRabbit