Skip to content

quic: apply multiple quic performance and packet handling improvements#63267

Open
jasnell wants to merge 13 commits into
nodejs:mainfrom
jasnell:jasnell/quic-backend-improvements
Open

quic: apply multiple quic performance and packet handling improvements#63267
jasnell wants to merge 13 commits into
nodejs:mainfrom
jasnell:jasnell/quic-backend-improvements

Conversation

@jasnell
Copy link
Copy Markdown
Member

@jasnell jasnell commented May 12, 2026

A number of planned backend changes and improvements in the packet handling. Yields a net performance improvement of around 10% higher rps. Sets us up to be able to better leverage libuv/libuv#5116 if/when that lands (@santigimeno @saghul fyi) which will provide an even larger perf boost. Fixes a bug while we're at it.

@nodejs/quic

jasnell added 8 commits May 12, 2026 09:16
Signed-off-by: James M Snell <jasnell@gmail.com>
Use a uv_check_t on BindingData to process outbound
pending packet send, and use TrySend for actually sending
packets when possible. Results in an 8% improvement in
req/s and ~24% improvement in p95 latency.

Also sets us up better for future improvements in
libuv if the changes proposed in libuv/libuv#5116
are accepted.

Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode:Opus 4.6
Signed-off-by: James M Snell <jasnell@gmail.com>
Improves overall performance and sets us up for eventual
support for GRO/GSO batching in libuv in the future.

Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode:Opus 4.6
Set up for when libuv eventually supports ECN marking.
Pass the ECN marking stuff into ngtcp2.

Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode:Opus 4.6
Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode:Opus 4.6
Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode:Opus 4.6
Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode:Opus 4.6
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/quic

@jasnell jasnell requested review from Qard and pimterry May 12, 2026 18:52
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels May 12, 2026
@jasnell jasnell changed the title meta: add additional gitignore entries quic: apply multiple quic performance and packet handling improvements May 12, 2026
Signed-off-by: James M Snell <jasnell@gmail.com>
@nodejs-github-bot

This comment was marked as outdated.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.04%. Comparing base (6009d93) to head (e55f7c7).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #63267      +/-   ##
==========================================
- Coverage   90.06%   90.04%   -0.03%     
==========================================
  Files         714      714              
  Lines      225242   225250       +8     
  Branches    42575    42581       +6     
==========================================
- Hits       202856   202818      -38     
- Misses      14172    14221      +49     
+ Partials     8214     8211       -3     
Files with missing lines Coverage Δ
lib/internal/quic/quic.js 100.00% <100.00%> (ø)
lib/internal/quic/state.js 100.00% <100.00%> (ø)
lib/internal/quic/stats.js 100.00% <100.00%> (ø)
src/aliased_struct-inl.h 90.90% <ø> (ø)
src/aliased_struct.h 100.00% <ø> (ø)

... and 35 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nodejs-github-bot

This comment was marked as outdated.

jasnell added 2 commits May 12, 2026 20:54
Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode:Opus 4.6
Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode:Opus 4.6
@jasnell jasnell force-pushed the jasnell/quic-backend-improvements branch from e921c66 to ef9e8da Compare May 13, 2026 03:54
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

jasnell added 2 commits May 13, 2026 06:17
Every stream, session, and endpoint creates aliased
structs for stats and state. These were creating
v8::ArrayBuffer allocations and views for each instance,
which is expensive. This adds a new arena mechanism
for AliasedStructs that allocates in pages and allows
Streams and Sessions to share the same underlying
ArrayBuffer for their stats and state. Since these
are never exposed to users, this is safe and results
in a significant reduction in allocation counts.

Each arena maintains a freelist of pages, where each
page is a max of 16KB bytes. Pages are lazily allocated
and freed as needed. Each slot in the arena corresponds
to a single struct instance, and the slot index is
used to calculate the byte offset within the page for
that struct's view.

The perf improvement is modest but measurable. The
key benefit is in reduced memory fragmentation and GC
overhead.

Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode:Opus 4.6
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants