Skip to content

dynhds: grow header array geometrically - #22910

Closed
MegaManSec wants to merge 1 commit into
curl:masterfrom
MegaManSec:worktree-agent-aa310a8b8c867e28d
Closed

MegaManSec wants to merge 1 commit into
curl:masterfrom
MegaManSec:worktree-agent-aa310a8b8c867e28d

Conversation

@MegaManSec

@MegaManSec MegaManSec commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Curl_dynhds_add() grew its pointer array by a fixed 16 slots per resize. Appending N headers therefore repeatedly copied the existing pointers, resulting in O(N²) aggregate work.

Grow the array geometrically instead. Appends are now amortized O(1), while the existing max_entries cap continues to limit the allocation when configured.

@MegaManSec MegaManSec changed the title dynhds: grow header array geometrically, cap tunnel header count dynhds: grow header array geometrically Sep 11, 2026
Curl_dynhds_add grew its pointer array by a fixed 16 slots per resize, copying every existing pointer each time and doing O(n^2) aggregate work across n inserts. Grow geometrically instead for amortized O(1) appends.
@MegaManSec
MegaManSec force-pushed the worktree-agent-aa310a8b8c867e28d branch from 343d8d3 to d24b8d5 Compare September 11, 2026 06:44

@bagder bagder left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reasonable!

@bagder bagder closed this in 5fb7e61 Sep 11, 2026
@bagder

bagder commented Sep 11, 2026

Copy link
Copy Markdown
Member

Thanks!

@MegaManSec
MegaManSec deleted the worktree-agent-aa310a8b8c867e28d branch September 14, 2026 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants