quic: add aliased struct arenas · nodejs/node@5e38946 · GitHub
Skip to content

Commit 5e38946

Browse files
jasnelladuh95
authored andcommitted
quic: add aliased struct arenas
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 PR-URL: #63267 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 9543043 commit 5e38946

9 files changed

Lines changed: 744 additions & 245 deletions

File tree

lib/internal/quic/quic.js

Lines changed: 8 additions & 4 deletions

lib/internal/quic/state.js

Lines changed: 67 additions & 53 deletions
Large diffs are not rendered by default.

lib/internal/quic/stats.js

Lines changed: 78 additions & 57 deletions

0 commit comments

Comments
 (0)