http: use intrusive lists in ConnectionsList - #65296
Open
mcollina wants to merge 1 commit into
Open
Conversation
Collaborator
|
Review requested:
|
mcollina
force-pushed
the
http-connectionslist-intrusive
branch
from
August 15, 2026 04:07
e7c6580 to
41044a2
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #65296 +/- ##
==========================================
- Coverage 90.30% 90.12% -0.19%
==========================================
Files 759 752 -7
Lines 248294 251826 +3532
Branches 46860 47356 +496
==========================================
+ Hits 224220 226954 +2734
- Misses 15516 16225 +709
- Partials 8558 8647 +89
🚀 New features to boost your workflow:
|
ronag
approved these changes
Aug 15, 2026
ronag
reviewed
Aug 15, 2026
Collaborator
Collaborator
ShogunPanda
approved these changes
Aug 17, 2026
Collaborator
Commit Queue failed- Loading data for nodejs/node/pull/65296 ✔ Done loading data for nodejs/node/pull/65296 ----------------------------------- PR info ------------------------------------ Title http: use intrusive lists in ConnectionsList (#65296) Author Matteo Collina <matteo.collina@gmail.com> (@mcollina) Branch mcollina:http-connectionslist-intrusive -> nodejs:main Labels c++, http_parser, author ready, needs-ci, commit-queue Commits 1 - http: use intrusive lists in ConnectionsList Committers 1 - Matteo Collina <hello@matteocollina.com> PR-URL: https://github.com/nodejs/node/pull/65296 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/65296 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> -------------------------------------------------------------------------------- ℹ This PR was created on Sat, 15 Aug 2026 04:05:15 GMT ✔ Approvals: 2 ✔ - Robert Nagy (@ronag) (TSC): https://github.com/nodejs/node/pull/65296#pullrequestreview-4943029706 ✔ - Paolo Insogna (@ShogunPanda) (TSC): https://github.com/nodejs/node/pull/65296#pullrequestreview-4949195971 ✘ 3 GitHub CI job(s) failed: ✘ - format-cpp: FAILURE (https://github.com/nodejs/node/actions/runs/31863623606/job/94961040997) ✘ - lint-commit-message: FAILURE (https://github.com/nodejs/node/actions/runs/31863623617/job/94961006361) ✘ - test-macOS: FAILURE (https://github.com/nodejs/node/actions/runs/31863623630/job/94961038864) ℹ Last Full PR CI on 2026-08-16T15:24:03Z: https://ci.nodejs.org/job/node-test-pull-request/75886/ - Querying data for job/node-test-pull-request/75886/ ✔ Build data downloaded - Querying failures of job/node-test-commit/90616/ ✔ Data downloaded ✘ 2 failure(s) on the last Jenkins CI run -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/32009841931 |
Collaborator
jasnell
approved these changes
Aug 17, 2026
mcollina
force-pushed
the
http-connectionslist-intrusive
branch
from
August 17, 2026 15:45
41044a2 to
340ded7
Compare
Every HTTP message was performing multiple erase and insert operations on two std::set instances ordered by a mutating key, showing up as ~2% of CPU cycles in a hello-world server profile due to red-black tree rebalancing and node allocations. Replace both sets with intrusive doubly-linked lists. Membership in the list of all connections no longer changes per message, and updating the active connections list is now O(1) with no allocations. Appending to the tail keeps the active list ordered by last_message_start_ because uv_hrtime() is monotonic. Signed-off-by: Matteo Collina <hello@matteocollina.com>
mcollina
force-pushed
the
http-connectionslist-intrusive
branch
from
August 17, 2026 16:16
340ded7 to
0cc64e0
Compare
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.
Every HTTP message was performing multiple erase and insert operations on the two
std::setinstances inConnectionsList, which are ordered by a key (last_message_start_) that mutates on every message. In a hello-world server profile this showed up as ~2.2% of total CPU cycles spent in red-black tree rebalancing plus tree-node allocations, all on the per-request hot path.This PR replaces both sets with intrusive doubly-linked lists:
Remove()is idempotent and the destructor unlinks automatically, which also removes the old "Pop from the lists BEFORE resetting last_message_start_" footgun.on_message_begin/on_message_completeis gone entirely.last_message_start_becauseuv_hrtime()is monotonic, soexpired()semantics are unchanged. The arrays returned byall()/idle()/active()are now in insertion order instead of comparator order; none of their consumers depend on ordering.Benchmark results (Linux, i7-7700, server and benchmarker pinned to separate cores):
A separate interleaved wrk A/B (hello-world server,
-t2 -c50, 5 alternating pairs) shows +4.9% (26,599 → 27,914 req/s), with the patched binary winning every pair. A perf profile of the patched binary confirms the_Rb_treesymbols are gone and malloc traffic in the parser path is roughly halved.This PR was prepared with the help of AI assistance.