Reuse transactions across repeated TSP type queries - #4702
Open
Punisheroot wants to merge 1 commit into
Open
Conversation
Contributor
|
This pull request has been imported. If you are a Meta employee, you can view this in D117845472. (Because this pull request was imported automatically, there will not be any future comments.) |
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
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.
Summary
Fixes #4312.
Reuse the existing revision-aware
TransactionManagerfor TSP type queries instead of creating and discarding a fresh transaction for every request.This applies to:
getDeclaredTypegetComputedTypegetExpectedTyperesolveImportBoth the main TSP connection and auxiliary IPC connections now retain transaction data across requests. The retained transaction is automatically replaced when the committed
Staterevision changes.Repeated type queries against imported but unopened modules previously started from a fresh transaction each time. Consequently, distinct
getComputedTyperequests for the same module and snapshot repeatedly ran the module's solve work.With this change:
Performance evidence
The regression test records transaction telemetry for two different ranges in the same unopened imported module:
step_answers_count > 0;step_answers_count == 0;run_todo_count == 0.In the synthetic test logs, the first query took approximately
0.09s, while the second was reported as0.00sat the current logging precision.This does not reproduce the full Django/Pylance benchmark from the issue, but it verifies that the repeated solve responsible for the reported regression is eliminated within the same connection and snapshot.
Correctness
The regression test also modifies the imported file and advances the snapshot. The following query:
Transaction reuse is scoped per TSP connection; separate auxiliary connections may each perform their own initial solve.
Test Plan
pyreflypackage: 8195 passed, 5 ignoredgit diff --checkpassed