Fix(memorization) issue 710 py lsp memoization#732
Open
LA-10 wants to merge 3 commits into
Open
Conversation
added 3 commits
July 1, 2026 08:02
Signed-off-by: LA-10 <lashuha@uwaterloo.com>
Signed-off-by: LA-10 <lashuha@uwaterloo.com>
Signed-off-by: LA-10 <lashuha@uwaterloo.com>
Owner
|
Huge thanks for opening this PR and for the work you put into it. The maintainer shop is currently full, so this may sit for a bit before it gets a proper review. We will come back to this as soon as possible with real feedback; I wanted to make sure it did not sit unacknowledged in the meantime. |
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 does this PR do?
Fixes #710 index_repository hangs during the definitions pass on Python files with deeply chained method calls, consuming 800+ s and ~1.4 GB with no progress.
py_eval_expr_type (internal/cbm/lsp/py_lsp.c) recursively evaluates expression types with no memoization. Chained calls cause the same sub-chains to be re-evaluated at every level roughly O(2^N) in chain depth
Memoize py_eval_expr_type, keyed by node start byte. Each sub-expression is typed once, collapsing chain evaluation to O(depth). The original body is renamed _uncached and wrapped by a thin memoizing entry results identical, only redundant recomputation removed. Cache is arena-allocated per file (freed automatically).
Added pylsp_issue710_deep_call_chain_no_hang to tests/test_py_lsp.c a ~40-link chain that hangs on the old code and passes on the fix.
Checklist
git commit -s) — required, CI rejectsunsigned commits (DCO, see CONTRIBUTING.md)
make -f Makefile.cbm test)make -f Makefile.cbm lint-ci)