http: use intrusive lists in ConnectionsList · nodejs/node@7e9204f · GitHub
Skip to content

Commit 7e9204f

Browse files
mcollinaaduh95
authored andcommitted
http: use intrusive lists in ConnectionsList
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> PR-URL: #65296 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 4de7e63 commit 7e9204f

1 file changed

Lines changed: 82 additions & 71 deletions

File tree

src/node_http_parser.cc

Lines changed: 82 additions & 71 deletions

0 commit comments

Comments
 (0)