GitHub issue #11793 in cline/cline, created 2026-06-24 by dan-huminology and titled "apply_patch fuzzy matcher is O(n²) per hunk — pegs CPU, spikes RAM, times out on ~15 KB files", reports that in Cline CLI 3.0.29 on Linux, apply_patch can saturate one CPU core at ~100% for the full 30s default timeout and cause multi-GB RSS spikes when applying a large *** Update File hunk to a normal source file (~15 KB, ~500 lines). The report attributes this to synchronous JavaScript in the patch parser's fuzzy context matcher: findContext() in apply-patch-parser.ts falls back to fuzzy match at 66% similarity or higher when exact and trimmed matches fail, and calculateSimilarity() calls levenshteinDistance(), which allocates a full DP matrix; for a ~15 KB whole-file hunk the report estimates one Levenshtein matrix at about 225M cells, about 1 to 2 GB RAM per call, with up to about 464 line positions scanned, all on Node's main thread. Reproduction: use a TypeScript test file of about 15,229 bytes and 464 lines, ask the agent to rewrite most or all of the file via *** Update File, and observe the cline Node process at about 100% CPU on one core, RSS swinging from 2 GB to 11 GB or more, and stdout flat until the call fails after about 30s with "apply_patch timed out after 30000ms". The report proposes six mitigations, including capping fuzzy matching above a size threshold, matching line by line first, and failing fast when exact and trim passes fail.
Verbatim Excerpts from Cited Records
“`apply_patch` can saturate **one CPU core at ~100%** for the full **30s default timeout** and cause **multi-GB RSS spikes** when applying a large `*** Update File` hunk to a normal source file (~15 KB, ~500 lines). This is not inference — it's synchronous JavaScript in the patch parser's fuzzy context matcher.”
“The failure mode looks like a hung agent: stdout goes quiet, memory bounces under swap pressure, then:”
“For a **~15 KB** whole-file hunk (n ≈ m ≈ 15,000 chars):”
“Applying a patch to a **tens-of-KB** file should complete in **milliseconds** (read file, locate context, write file).”
·
cline/cline (issue 11793 opening body, Expected behavior section)
·
2026-06-24T17:39:32Z
·GitHub Issue ↗
Counter-record: Issue closed 2026-11-27T09:32:04Z by linear-code[bot] with state_reason not_planned; the issue carries the stale label (applied 2026-08-27 by github-actions[bot] after 60 days with no activity); no closing comment appears in the thread and no fix was confirmed there, so the close reads as a triage/cleanup decision, not a fix, not a duplicate marking, and not a retraction of the report. 9 comments read in total. dhruvil-codes (2026-06-24) found the O(n²) analysis plausible, investigated a bounded fuzzy-match approach, verified on 2026-06-27 that the issue still reproduces on CLI release 3.0.31, and opened proposed fix PR #11915 adding a guard against oversized Levenshtein comparisons; no merge or maintainer acceptance of that PR appears in the surveyed thread. gbrennon (2026-06-24) confirmed the issue and sent it to the team. linear-code[bot] linked the report to CLINE-2537 at filing (2026-06-24). The claim documents only the original report, not a verified current state. Precedent: closed-state issues have been published before when the close is not a fix, duplicate, or retraction, e.g. C196 (#13267, closed by linear-code[bot] not_planned), C178 (#11693, closed by linear-code[bot] stale), C131.
Falsification probe: If GitHub issue #11793 is deleted without archive, if the author edits the opening body so the quoted sentences no longer match verbatim, or if the author posts a retraction of the report, this claim drops to Withdrawn.
Audit verification: Verified 100% continuous verbatim substring against official GitHub REST API by
scripts/verify_claim_verbatim.py.