Repository navigation
Reduce member completion, hover and signature-help latency - #793
renkun-ken merged 11 commits into
Conversation
5020ef8 to
9de91f6
Compare
9de91f6 to
2303aaf
Compare
eitsupi
left a comment
There was a problem hiding this comment.
Review by ChatGPT
I found two potential regressions that remain in the latest revision:
-
Argument-less
library()/require()calls:member_package_scope_required()accessesitem$expr[[2L]]without checking the call length. Both functions allow calls without arguments, so ordinary completion, hover, or signature help may fail. Please handle these calls and add regression tests. -
Truncation before shadow filtering:
scope_completion()now applies the candidate limit beforekeep_source(). When a name appears in both symbol and function candidates but one is subsequently filtered out (e.g., an enclosing function shadowed by a method-local variable), it can consume a slot and exclude another valid candidate. Please apply the limit after filtering, or replenish the candidates, and add a regression test.
Both issues should be addressed before merging.
Completion, hover and signature help repeatedly replayed unrelated local assignments, re-inferred receivers and processed package defaults/delegation. Parse debounce also delayed completion after ordinary typing. This PR avoids that work while retaining static inference, structural-edit handling and production inference limits (250 ms / 20,000 nodes).
Changes
library()/require()and replenish scope candidates after shadow filtering.Benchmarks
Installed R 4.6.1/macOS arm64 measurements with production request budgets. Pairwise comparisons use the same fixture and clear the relevant caches; results from different fixture/revision pairs should not be compared directly.
Source/scope indexes versus the first performance implementation (
2303aaf), 1,000 locals, 15 sequential samples:Serialized parse size grows about 2–3%; the 1,000-binding index occupies about 0.5 MiB and is charged to the parse-cache budget.
Dependency capture and completion shape inference versus
9ce3a8b, alternating 25 requests per implementation, 1,000 locals:Full completion responses agree. Separate allocation profiling reduces cold R6 completion traffic from 68.6 MB to 17.1 MB; serialized parse size and full parse medians are unchanged.
Bounded package return preparation versus
7e3e7cd, separate installed R sessions, alternating 20 requests per implementation, Polars 1.16.0 long-chain fixture. Metadata is decoded before timing. Cold invocation clears both invocation and document receiver caches; warm invocation clears only the receiver cache.Cold p95 falls from 221.1 / 242.1 / 194.2 ms to 147.4 / 148.2 / 115.4 ms respectively. Responses agree after excluding the expected completion metadata-generation identifier change. Separate allocation profiling reduces cold completion traffic from 20.57 MB to 11.27 MB (three samples, median); only diagnostic profiling extends its deadline, and profiling is excluded from timed samples.
Polars worker preparation takes 4.824 / 5.768 seconds in this run. Summaries increase from 22 to 227, their object size from 64,096 to 660,352 bytes, and the serialized package snapshot from 4,913,841 to 5,067,466 bytes. Preparation remains outside the request path.
Validation
All 10 GitHub checks pass on
aff6874: Linux/macOS/Windows R CMD checks, lint, stable/development S7 and all four coverage shards.git diff --checkpasses.The PR includes production code and tests only. Benchmark scripts, CSV files and plans remain local.