Repository navigation
cw-pause: fix O(N^2) list traversal in cw_pause_flush - #22968
MegaManSec wants to merge 1 commit into
Conversation
Switch the pause buffer list from prepend-at-head to append-at-tail and add a tail pointer to cw_pause_ctx. cw_pause_flush can now consume nodes from the head in O(1) per node instead of re-scanning from the head on every outer iteration.
|
Analysis of PR #22968 at 86e1f075: Test ../../tests/http/test_21_resolve.py::TestResolve::test_21_08_dnsd_aaaa[DoH] failed, which has NOT been flaky recently, so there could be a real issue in this PR. Note that this test has failed in 2 different CI jobs (the link just goes to one of them). Test ../../tests/http/test_21_resolve.py::TestResolve::test_21_09_dnsd_a_delay[DoH] failed, which has NOT been flaky recently, so there could be a real issue in this PR. Note that this test has failed in 2 different CI jobs (the link just goes to one of them). Test ../../tests/http/test_21_resolve.py::TestResolve::test_21_10_dnsd_aaaa_delay[DoH] failed, which has NOT been flaky recently, so there could be a real issue in this PR. Note that this test has failed in 2 different CI jobs (the link just goes to one of them). Test ../../tests/http/test_21_resolve.py::TestResolve::test_21_13_dnsd_nxdomain_cached[DoH] failed, which has NOT been flaky recently, so there could be a real issue in this PR. Note that this test has failed in 2 different CI jobs (the link just goes to one of them). Generated by Testclutch |
There was a problem hiding this comment.
🟢 Approval recommended
The queue invariants and write ordering are preserved while eliminating repeated list traversal.
Pull request overview
Optimizes paused client-write buffering by replacing quadratic list traversal with FIFO head/tail operations.
Changes:
- Adds and maintains a tail pointer.
- Appends buffered writes at the tail and flushes from the head in O(1) per node.
File summaries
| File | Description |
|---|---|
lib/cw-pause.c |
Implements efficient FIFO buffering and flushing. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Switch the pause buffer list from prepend-at-head to append-at-tail and add a
tailpointer tocw_pause_ctx.cw_pause_flushcan now consume nodes from the head in O(1) per node instead of re-scanning from the head on every outer iteration.The same fix was applied to
cw-out.cin 89ca8fe butcw-pause.cwas missed. With many buffered nodes (e.g. from an adversarial HTTP/2 server interleaving HEADERS/DATA frames while aCURL_WRITEFUNC_PAUSEcallback is active), the old code performed O(N²) work on unpause.