AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Low 25 Bitcoin

libplugin: remove redundant destructor which causes exponential slowdown on large numbers of requests.

Public commit record

What the developer wrote

Authored by Rusty Russell

73/100 · Adequate
libplugin: remove redundant destructor which causes exponential slowdown on large numbers of requests.

Note that we create a destructor on the command to reset request->cmd
pointer if the cmd is freed (so we know not to call the callback).
But attaching hundreds of thousands of them is slow: it's a
single-linked list, which is iterated in several places.

But that's redundant: the request is now allocated off the cmd, so freeing the command
will free the request anyway.

Hacking in something to print progress to a file, here's the number of
requests processed every 10 seconds before and after:

Before:
$ while sleep 10; do wc -l /tmp/bkpr-progress; done
181529 /tmp/bkpr-progress
195994 /tmp/bkpr-progress
207083 /tmp/bkpr-progress
226336 /tmp/bkpr-progress
234319 /tmp/bkpr-progress
241514 /tmp/bkpr-progress
247421 /tmp/bkpr-progress
255292 /tmp/bkpr-progress
261367 /tmp/bkpr-progress
269085 /tmp/bkpr-progress
276953 /tmp/bkpr-progress
282233 /tmp/bkpr-progress
286193 /tmp/bkpr-progress
290930 /tmp/bkpr-progress
295276 /tmp/bkpr-progress
301086 /tmp/bkpr-progress

After:
169505 /tmp/bkpr-progress
196010 /tmp/bkpr-progress
219370 /tmp/bkpr-progress
235671 /tmp/bkpr-progress
244242 /tmp/bkpr-progress
255362 /tmp/bkpr-progress
265636 /tmp/bkpr-progress
276966 /tmp/bkpr-progress
284451 /tmp/bkpr-progress
288836 /tmp/bkpr-progress
296578 /tmp/bkpr-progress
304571 /tmp/bkpr-progress

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit fixes a performance bug, not a security vulnerability. It removes an unnecessary cleanup step that was attached to every outgoing plugin request. On large numbers of requests, that extra step created a very long internal list and slowed everything down dramatically. The fix simply relies on normal memory cleanup instead.

Recommended action

Treat as a routine performance fix. No security patch urgency, but operators running plugins that issue very large numbers of RPC requests (e.g., bookkeeping) should upgrade to avoid slowdowns. No workaround needed.

Security signals we found

01

Performance degradation / denial-of-service potential from O(n^2) destructor-list behavior under high request volume

02

No memory corruption, type confusion, authentication bypass, or cryptographic weakness present in diff

03

Redundant lifecycle management removed; behavior is functionally equivalent because request is child of cmd

Risk score

Why this scored 25/100

Our methodology →
Potential impact 5/30
Exploitability 0/25
Stealth signal 3/15
Affected reach 5/15
Confidence 8/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.