0.0.11: the completion budget follows the file, so clangd's ~1 s module-importer answers are not cancelled (UP-25) - #41
Merged
Conversation
…nd module completions (UP-25) clangd 23.1 costs 0.95-1.05 s per completion on a file that imports modules, even when the BMIs are long built and cached (issue #24 UP-25: the module context is re-loaded per request; a file without imports in the same project answers in 60 ms). The completion budget of 1 s therefore cancelled the engine's answer right at the line, and after `.`, `->` or `::` the fallback is empty by design -- in the editor this read as completion being slow and sometimes not coming up at all (qt-demo: typing `nlohmann::js`). The budget for completion and signature help is now 1.5 s: clangd's real answer arrives instead of being cancelled at the line, the fallback still bounds the worst case, and hover and go-to-definition keep their budgets. Version 0.0.11.
… answers per file (UP-25) A flat 1.5 s budget failed the UX gate: in the regime the scenarios calibrate -- clangd busy or broken, answering nothing (U16's module rewritten under autosave, U7a's fan-out save) -- every completion rode to the budget, so the fallback came 500 ms later, and ux-xlings and ux-mcpp failed (CI run 37188779178). A flat constant cannot hold both regimes: either the just-past-the-line answers of a module importer are cancelled at 1 s (qt-demo, UP-25), or the fallback of a stuck engine is late everywhere. The budget now follows the file. The workspace records each core-engine completion answer and its latency (EnginePace); two answers in the last ten seconds that all landed past the flat 1 s extend that file's completion and signature-help budget to their slowest plus 500 ms, capped at 2.5 s. qt-demo's importer answers at about 1.05 s, so from the third completion on its answers land instead of being cancelled; an engine that answers rarely or quickly keeps the flat budget, and every calibrated scenario number stays. The flat budget itself is unchanged from 0.0.10. Registered as WA-CLANGD-012.
…and outlives a think pause (PR #41 review) The review of the first adaptive cut found two real holes. Late answers up to ten seconds old were all counted, so a file whose engine answered slowly (a module rebuilding answers in 3-8 s, not never) could hold its own fallback 1.5 s past the flat budget -- the regression the UX gate rejected, in narrower form. And the ten second window cleared on every think pause, so the first two completions after pausing missed again, which is the symptom this fixes. Answers landing beyond cap - margin (2 s) are no longer counted: a busy engine is not a slow-and-steady one, and no budget this file could earn would meet them anyway. The window is sixty seconds, so a pause inside a minute keeps the file's pace; a longer one relearns with the answers C-2 already keeps. Latency is measured from the ask (started), where the budget is counted from, too. Signature help now also records its answers instead of only reading completion's, a closed file's pace is dropped, and the pace ring is walked in place (no per-call allocation). Review-found sync: editors/vscode/package-lock.json to 0.0.11, and the zh-CN troubleshooting page carries the same budget note as the English one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Typing
nlohmann::jsin a module-importing file (qt-demo), completion was slow (~1 s) and sometimes did not come up at all. Root cause measured and split in two:.,->or::the fallback is empty by design, so the popup never came.The change
The budget now follows the file (
EnginePace,src/orchestrator/completion.cppm; wired inworkspace.cpp):routing::answer_budgetreverted to main); hover and go-to-definition keep theirs.An earlier commit here raised the flat budget to 1.5 s; CI's UX gate rejected it with data —
U16-module-autosave: 93 completions p95 1.50 s (every one riding to the budget,ux-xlings+ux-mcppfailed, run 37188779178) — which is the measured proof that no flat constant can hold both regimes. The adaptive design passes the same scenarios unchanged.Registered upstream-defect handling as WA-CLANGD-012 (
src/engine/clangd/workarounds.cpp): upstream, evidence, removeWhen, premise. Version 0.0.11 (mcpp run -p devtools -- version --set).Review pass (1f8083b)
The first adaptive cut had two real holes, found in review and fixed:
cap − margin(2 s) are not counted — a busy engine is not a slow-and-steady one.Also from review: latency is measured from the ask (where the budget is counted from, too); signature help records its answers instead of only reading completion's; a closed file's pace is dropped; the ring is walked in place;
package-lock.jsonsynced to 0.0.11; zh-CN troubleshooting carries the same note as the English page.Test
EnginePacepolicy (flat until two recent past-the-line answers; fast answer among them → flat; stale window → flat; cap) intests/test_completion.cpp; R-7 assertions unchanged at 1000 ms.mcpp build,mcpp test(all suites, 0 failed),check all, and thecompletion-keywordsconformance fixture against the real payload: 0 failures.ux-xlings,ux-mcpp,ux-heavy-headers) — the first design failed them; this one keeps their numbers.