@@ -21,7 +21,11 @@ use crate::source::source_text;
2121/// reflected in the changed AST offsets.
2222/// The other reason is that Ruff's AST doesn't implement `Eq` which Salsa requires
2323/// for determining if a query result is unchanged.
24- #[ salsa:: tracked( returns( ref) , no_eq, heap_size=ruff_memory_usage:: heap_size) ]
24+ ///
25+ /// The LRU capacity of 200 was picked without any empirical evidence that it's optimal,
26+ /// instead it's a wild guess that it should be unlikely that incremental changes involve
27+ /// more than 200 modules. Parsed ASTs within the same revision are never evicted by Salsa.
28+ #[ salsa:: tracked( returns( ref) , no_eq, heap_size=ruff_memory_usage:: heap_size, lru=200 ) ]
2529pub fn parsed_module ( db : & dyn Db , file : File ) -> ParsedModule {
2630 let _span = tracing:: trace_span!( "parsed_module" , ?file) . entered ( ) ;
2731
@@ -92,14 +96,9 @@ impl ParsedModule {
9296 self . inner . store ( None ) ;
9397 }
9498
95- /// Returns the pointer address of this [`ParsedModule`].
96- ///
97- /// The pointer uniquely identifies the module within the current Salsa revision,
98- /// regardless of whether particular [`ParsedModuleRef`] instances are garbage collected.
99- pub fn addr ( & self ) -> usize {
100- // Note that the outer `Arc` in `inner` is stable across garbage collection, while the inner
101- // `Arc` within the `ArcSwap` may change.
102- Arc :: as_ptr ( & self . inner ) . addr ( )
99+ /// Returns the file to which this module belongs.
100+ pub fn file ( & self ) -> File {
101+ self . file
103102 }
104103}
105104
0 commit comments