Repository navigation
perf: recover scripts.zip load regression - #1079
Conversation
Use no-flow inference when indexed assignment analysis only needs the member owner, and avoid expanding non-variadic unions when selecting the first result slot. Assisted-by: Codex
Finish broad non-unknown assignment RHS types directly instead of querying the previous flow type and then discarding it. Assisted-by: Codex
When flow replay can resolve the direct IndexRef dependency, the replay overlay already lets no-flow inference return that expression without walking its prefix/key dependencies. Keep those fallback dependencies queued only for direct misses. Assisted-by: Codex
Code Review SummaryIssues Found:
Recommendations:
Positive Aspects:
|
There was a problem hiding this comment.
Code Review
This pull request improves Lua type inference by refining how unresolved prefixes and index expressions are handled. Key changes include implementing a fallback mechanism in set_index_expr_owner and try_resolve_member to ensure retries for nested unresolved prefixes, optimizing flow replay queries with short-circuiting for resolved index expressions, and improving the handling of union types in multi-return scenarios. Additionally, it optimizes assignment processing in the flow type engine by avoiding unnecessary antecedent queries for broad RHS types. A new test case was added to verify the fix for nested unresolved prefixes. I have no feedback to provide.
Avoid routing `A & A` through the union intersection arms. This preserves the existing result while skipping pairwise union work in flow narrowing. Assisted-by: Codex
Problem
The
scripts.zipworkload regressed heavily after0.21.0. On currentupstream/main, loading the extractedscripts/workspace is about 3.28x slower than0.21.0.This PR targets the hot paths from that workload without changing the broader inference result model:
Performance
Benchmark command shape:
The project is the extracted
scripts/directory fromhttps://github.com/user-attachments/files/27706685/scripts.zip. Times are mean ± 95% CI from releaseemmylua_lsbuilds.Against current
upstream/main:That is a 77.0% total load-time improvement and a 79.3% index-time improvement, or about 4.35x faster total load time on this workload.
Relative to
0.21.0:This closes the previous 0.21.0 gap for this workload. The branch is about 22.8% faster than
0.21.0in total load time and about 25.4% faster in index time. RSS is listed for completeness; against currentupstream/main, this branch is lower RSS in this run.Tests
cargo test -p emmylua_code_analysis cargo build --release -p emmylua_ls target/debug/emmylua_perf compare --baseline upstream/main --head HEAD --project /tmp/emmylua-scripts/scripts --iterations 5 --no-fetch target/debug/emmylua_perf compare --baseline 0.21.0 --head HEAD --project /tmp/emmylua-scripts/scripts --iterations 5 --no-fetch