Maintained engine: the first completion in a just-opened module importer waits for its first preamble

Aperta
#50 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
15/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Attiva
Stack tecnologico
cpp

Direzione di ricerca

The first-completion wait comes from patch 0008, which switches code completion to TUScheduler::Stale in modules mode, so start from that change and the StaleOrAbsent path it replaces. The issue describes three possible improvements, and the work requires choosing one, either a bounded wait of about 800 ms, a persistent validation memo, or prioritizing the edited file in the prime pool. Done means a decision recorded on the issue, and any change verified against the ux-xlings U5 typing checks.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement

Symptom

With the maintained engine (mcppls-clangd 0.0.12, 23.1.0-mcppls.0), completion in a module importer that was just opened waits for the file's first preamble. That takes several seconds on a real project. For example, in xlings src/core/xself/doctor.cpp the first build of about 100 prerequisite modules takes about 3.3 s locally and longer on CI runners. Until the preamble exists, each completion runs past the server's 1 s budget and mcppls's own engine answers it. After that, completion answers in 35–390 ms.

Stock clangd 23.1 answers at once in that window, from its fallback without a preamble. That fallback leaves out imported declarations, and after ., -> or :: it is empty (the 0.0.11 "popup never came" report).

Cause

This is intended engine behavior. In modules mode, mcppls-clangd's code completion runs on TUScheduler::Stale instead of StaleOrAbsent (patch 0008, the "first module completion" change of UP-25), so a first completion waits for the first preamble instead of giving an import-blind answer.

Measured locally on the same workspace, warm cache, 40 s of 10 Hz typing (ux-xlings U5):

completions during the first preamble after it
stock 23.1 7–16 ms (fallback) p95 ≈ 0.2 s
mcppls-clangd 0.0.12 1.4–6.3 s (past the 1 s budget, answered by mcppls) 35–390 ms

Decision for 0.0.12

The wait on first open is accepted. The ux typing checks now report it as their own "first-open" measurement and hold p95 and engine share to the unchanged budgets for the completions after the engine's first answer.

To improve later

  1. A bounded wait: wait for the first preamble up to a budget (about 800 ms), then answer as upstream does and let the semantic answer follow.
  2. A faster first preamble on a warm cache: the BMIs are all reused, and the time goes to validating each prerequisite again. A validation memo that persists across processes, keyed by the same exact inputs, would remove most of it.
  3. Priority for the edited file: at startup, prime units' prerequisite work shares the bounded build pool with the file being typed in. The focused file should go first.
Lingua principale
C++
Stelle
25
Fork
2
Merge medio
21h 5m
PR unite (30g)
13

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Sunrisepeak/mcpp-language-server

Tutte le issue di Sunrisepeak/mcpp-language-server

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.