Skip to content

Fix language-feature edge cases and speed up member preparation - #826

Open
renkun-ken wants to merge 16 commits into
masterfrom
codex/usage-responsiveness-review
Open

renkun-ken wants to merge 16 commits into
masterfrom
codex/usage-responsiveness-review

Conversation

@renkun-ken

@renkun-ken renkun-ken commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Repeated saves can restart expensive member metadata preparation before it finishes, while several completion, navigation and workspace lifecycle edge cases leave editor results incorrect or stale. This PR coalesces member refreshes, reduces preparation and editing costs, and fixes those usage cases.

Changes

  • Match registry closures through an indexed namespace function lookup, verifying exact identity and retaining the first matching binding, including copied closures and syntax-key collisions. Evict unprotected cache entries directly from the oldest end without collecting every key; LRU order, byte/entry limits, protected-entry behavior and support for older collection APIs remain unchanged.
  • Reuse and promote queued member work when its complete request context is unchanged. Running work finishes once, then one fresh validation captures the latest metadata for all saves received during preparation. Changed document, workspace, package or library contexts replace obsolete work; stale callbacks cannot apply results or schedule another refresh.
  • Report total, queued and running task time using the elapsed clock. Running time includes process startup, result transfer and callbacks. Redact common credential environment variables from the debug session header.
  • Handle namespace-qualified literal default helpers and missing arguments in argument-value completion, and escape suggested string literals correctly. Preserve quoted symbol identity and full multiline Unicode ranges in definitions, references, highlights and rename; quote nonsyntactic replacement names and exclude shadowed local calls from function CodeLens counts.
  • Decode raw strings and escaped class, slot and member names without evaluating declarations. Discover static source() calls inside computed callees, including immediately invoked anonymous functions, and refresh older workspace-index caches so unchanged files recover these dependencies.
  • Restart pending parses and refresh diagnostics when documents move between workspace folders. Restore saved package content after closing an unsaved buffer with workspace indexing disabled.
  • Keep string and numeric JSON-RPC IDs distinct across cancellation, background formatting and response callbacks, while treating equivalent integer and double IDs alike.
  • Remove repeated default-argument copying and rename edit accumulation, invalidate pending disk snapshots once per edit, and reuse one UTF-8 byte index per CLI diagnostic batch.

Performance

Three serial local passes on R 4.6.1/macOS arm64 produced these medians. The usage workloads compare cf116dd with this branch:

Operation Before (ms) After (ms)
Extract 10,000 literal defaults 850 1
Construct 10,000 rename edits 213 31
Convert 500 diagnostics across 5,000 lines 646 15

Fresh member workers with Polars 2.0.0 compare bb8eb83 with the member preparation changes:

Worker workload Before (ms) After (ms)
Cold member preparation 10,529 7,156
Restore an existing disk model 3,771 1,763
Validate an already-known model 3,564 1,512

The usage rows isolate extraction, edit construction and diagnostic conversion. Worker rows include fresh process/server loading, namespace preparation and metadata transfer, and exclude scheduling, document parsing and editor rendering. All workloads use neutral fixtures and validate results; timing varies with hardware and load. Reproduction scripts and measurement boundaries are documented in inst/benchmarks/README.md.

Validation

  • Full local R CMD check --as-cran --no-manual on R 4.6.1/macOS arm64: 0 errors, 0 warnings, 14,733 passing assertions and 23 skips.
  • Targeted cache, preparation, refresh/coalescing, readiness and lifecycle regressions also passed serially.
  • The existing NOTE for global-environment assignments in R/index_worker.R remains.

Regression coverage checks quoted and raw literals, Unicode/UTF-16 ranges, lexical scope, workspace moves and closes, typed request IDs, static source discovery, namespace identity equivalence and collisions, LRU/legacy cache behavior, save coalescing, stale callbacks and timing boundaries. Member-refresh regressions use inert sessions, and automated tests assert behavior without elapsed-time thresholds.

@renkun-ken
renkun-ken requested a review from eitsupi October 30, 2026 19:09
@renkun-ken renkun-ken changed the title Fix language-feature edge cases and improve responsiveness Fix language-feature edge cases and speed up member preparation Oct 31, 2026
@renkun-ken
renkun-ken requested a review from randy3k October 31, 2026 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant