Skip to content

QUICStreamID: use strong type for stream IDs in frames - #362

Open
rpaulo wants to merge 1 commit into
apple:mainfrom
rpaulo:stream-id-cleanups
Open

rpaulo wants to merge 1 commit into
apple:mainfrom
rpaulo:stream-id-cleanups

Conversation

@rpaulo

@rpaulo rpaulo commented Nov 19, 2026

Copy link
Copy Markdown
Contributor
  • Replace raw UInt64 stream IDs with QUICStreamID across frame types, send items, shorthand log entries, and signposts
  • Add QUICStreamID(uncheckedValue:) for IDs decoded from variable-length integers and remove now-unused helpers
  • Drop redundant per-frame stream ID validation since decoded values are always in range
  • Interpolate raw .value in os.Logger messages to avoid <private> redaction of the custom type

@rpaulo rpaulo added the 🔨 semver/patch No public API change. label Nov 19, 2026

@agnosticdev agnosticdev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In general this looks fine. This was originally done for performance reasons but since we do not use dictionaries anymore to interact with streams (thank goodness!) we can go back to the QUICStreamID type. I checked and this does not regress performance.
Curious if there was another reason you wanted to do this other for cosmetic purposes? Did an issue come up?

@rpaulo

rpaulo commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

In general this looks fine. This was originally done for performance reasons but since we do not use dictionaries anymore to interact with streams (thank goodness!) we can go back to the QUICStreamID type. I checked and this does not regress performance. Curious if there was another reason you wanted to do this other for cosmetic purposes? Did an issue come up?

All stream IDs, stream or datagram, should have their own type for type safety and to restrict the limits.

@rpaulo

rpaulo commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

/benchmark

@github-actions

Copy link
Copy Markdown

Benchmark results

e6e1f96e506b (this change) against 1361f626bdf4 (merge base), Swift 6.4.1, workflow run. Counts are the heap allocations and the retain and release calls made by a short fixed workload under valgrind.

Tool Allocations ARC traffic
QUICTransfer −0.07% ➖ −0.03% ➖
QUICStreamLoad −0.64% ➖ −0.88% 🟢
IPUDPTransfer +0.00% ➖ +0.00% ➖

🟢 lower, 🔴 higher, ➖ no change: a change must exceed 0.25% and 3 times the variation between repeats of either build.

QUICTransfer
base head Δ repeat spread
Allocations 425 k 424 k −0.07% 0.13% ➖
ARC traffic 2.15 M 2.15 M −0.03% 0.08% ➖

Allocations: base 424250, 424552, 424815; head 424240, 424259, 424541
ARC traffic: base 2150487, 2151473, 2152155; head 2150868, 2150626, 2151557

QUICStreamLoad
base head Δ repeat spread
Allocations 361 k 358 k −0.64% 0.31% ➖
ARC traffic 2.19 M 2.17 M −0.88% 0.14% 🟢

Allocations: base 360524, 360278, 360627; head 357745, 358872, 358230
ARC traffic: base 2186558, 2185781, 2186698; head 2165478, 2167210, 2168445

IPUDPTransfer
base head Δ repeat spread
Allocations 904 k 904 k +0.00% 0.00% ➖
ARC traffic 4.57 M 4.57 M +0.00% 0.00% ➖

Allocations: base 904234, 904234, 904234; head 904234, 904238, 904238
ARC traffic: base 4570638, 4570638, 4570636; head 4570637, 4570668, 4570668

@rpaulo
rpaulo force-pushed the stream-id-cleanups branch from e6e1f96 to 71537e1 Compare November 19, 2026 20:19
@rpaulo
rpaulo enabled auto-merge November 19, 2026 20:19
- Replace raw `UInt64` stream IDs with `QUICStreamID` across frame types,
  send items, shorthand log entries, and signposts
- Add `QUICStreamID(uncheckedValue:)` for IDs decoded from variable-length
  integers and remove now-unused helpers
- Drop redundant per-frame stream ID validation since decoded values are
  always in range
- Interpolate raw `.value` in os.Logger messages to avoid `<private>`
  redaction of the custom type
@rpaulo
rpaulo force-pushed the stream-id-cleanups branch from 71537e1 to a4073dd Compare December 2, 2026 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants