[ty] Consolidate AST ID reverse lookup#25455
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 91.94%. The percentage of expected errors that received a diagnostic held steady at 87.09%. The number of fully passing files held steady at 92/134. |
Memory usage reportSummary
Significant changesClick to expand detailed breakdownflake8
trio
sphinx
prefect
|
|
Merging this PR will not alter performance
Comparing Footnotes
|
7356b26 to
d9dea8c
Compare
6d36bcd to
1d200ff
Compare
1d200ff to
401708c
Compare
| } | ||
| } | ||
|
|
||
| uses_map.shrink_to_fit(); |
There was a problem hiding this comment.
Have you considered using a FrozenMap here?
| use_id | ||
| } | ||
|
|
||
| pub(super) fn try_use_id(&self, key: impl Into<ExpressionNodeKey>) -> Option<ScopedUseId> { |
There was a problem hiding this comment.
Did you review all call sites that this is indeed the uncommon case? Should we rename the method to try_find_use_id to make it more explicit that its complexity is O(n). Do you know what the perf impact of using a BTreeMap is? Should we change this in a separate PR to better understand the perf implications?
There was a problem hiding this comment.
Good call... Moving out...
There was a problem hiding this comment.
Not really convinced that either of these are worth it:
| } | ||
| } | ||
|
|
||
| fn ast_ids<'db>(db: &'db dyn Db, scope: ScopeId) -> &'db AstIds { |
There was a problem hiding this comment.
Should the api be changed to pass file instead?
401708c to
7744e38
Compare
7744e38 to
6dc341d
Compare
6dc341d to
8c28fb0
Compare
Summary
Consolidates the per-scope AST ID reverse lookup maps into a single file-level map. IDs are still assigned per scope, preserving stable outer-scope IDs while reducing retained map overhead.