3
3
use std:: sync:: Arc ;
4
4
5
5
use base_db:: {
6
- salsa:: { Database , Durability , SweepStrategy } ,
6
+ salsa:: { Database , Durability } ,
7
7
Change , SourceRootId ,
8
8
} ;
9
9
use profile:: { memory_usage, Bytes } ;
@@ -38,32 +38,6 @@ impl RootDatabase {
38
38
change. apply ( self ) ;
39
39
}
40
40
41
- pub fn collect_garbage ( & mut self ) {
42
- if cfg ! ( target_arch = "wasm32" ) {
43
- return ;
44
- }
45
-
46
- let _p = profile:: span ( "RootDatabase::collect_garbage" ) ;
47
-
48
- let sweep = SweepStrategy :: default ( ) . discard_values ( ) . sweep_all_revisions ( ) ;
49
-
50
- base_db:: ParseQuery . in_db ( self ) . sweep ( sweep) ;
51
- hir:: db:: ParseMacroExpansionQuery . in_db ( self ) . sweep ( sweep) ;
52
-
53
- // Macros do take significant space, but less then the syntax trees
54
- // self.query(hir::db::MacroDefQuery).sweep(sweep);
55
- // self.query(hir::db::MacroArgTextQuery).sweep(sweep);
56
- // self.query(hir::db::MacroExpandQuery).sweep(sweep);
57
-
58
- hir:: db:: AstIdMapQuery . in_db ( self ) . sweep ( sweep) ;
59
-
60
- hir:: db:: BodyWithSourceMapQuery . in_db ( self ) . sweep ( sweep) ;
61
-
62
- hir:: db:: ExprScopesQuery . in_db ( self ) . sweep ( sweep) ;
63
- hir:: db:: InferQueryQuery . in_db ( self ) . sweep ( sweep) ;
64
- hir:: db:: BodyQuery . in_db ( self ) . sweep ( sweep) ;
65
- }
66
-
67
41
// Feature: Memory Usage
68
42
//
69
43
// Clears rust-analyzer's internal database and prints memory usage statistics.
@@ -76,32 +50,17 @@ impl RootDatabase {
76
50
// image::https://user-images.githubusercontent.com/48062697/113065592-08559f00-91b1-11eb-8c96-64b88068ec02.gif[]
77
51
pub fn per_query_memory_usage ( & mut self ) -> Vec < ( String , Bytes ) > {
78
52
let mut acc: Vec < ( String , Bytes ) > = vec ! [ ] ;
79
- let sweep = SweepStrategy :: default ( ) . discard_values ( ) . sweep_all_revisions ( ) ;
80
- macro_rules! sweep_each_query {
53
+ macro_rules! purge_each_query {
81
54
( $( $q: path) * ) => { $(
82
- let before = memory_usage( ) . allocated;
83
- $q. in_db( self ) . sweep( sweep) ;
84
- let after = memory_usage( ) . allocated;
85
- let q: $q = Default :: default ( ) ;
86
- let name = format!( "{:?}" , q) ;
87
- acc. push( ( name, before - after) ) ;
88
-
89
- let before = memory_usage( ) . allocated;
90
- $q. in_db( self ) . sweep( sweep. discard_everything( ) ) ;
91
- let after = memory_usage( ) . allocated;
92
- let q: $q = Default :: default ( ) ;
93
- let name = format!( "{:?} (deps)" , q) ;
94
- acc. push( ( name, before - after) ) ;
95
-
96
55
let before = memory_usage( ) . allocated;
97
56
$q. in_db( self ) . purge( ) ;
98
57
let after = memory_usage( ) . allocated;
99
58
let q: $q = Default :: default ( ) ;
100
- let name = format!( "{:?} (purge) " , q) ;
59
+ let name = format!( "{:?}" , q) ;
101
60
acc. push( ( name, before - after) ) ;
102
61
) * }
103
62
}
104
- sweep_each_query ! [
63
+ purge_each_query ! [
105
64
// SourceDatabase
106
65
base_db:: ParseQuery
107
66
base_db:: CrateGraphQuery
@@ -119,6 +78,7 @@ impl RootDatabase {
119
78
hir:: db:: ParseMacroExpansionQuery
120
79
hir:: db:: MacroExpandQuery
121
80
hir:: db:: HygieneFrameQuery
81
+ hir:: db:: InternMacroQuery
122
82
123
83
// DefDatabase
124
84
hir:: db:: FileItemTreeQuery
@@ -174,6 +134,7 @@ impl RootDatabase {
174
134
hir:: db:: InternClosureQuery
175
135
hir:: db:: AssociatedTyValueQuery
176
136
hir:: db:: TraitSolveQueryQuery
137
+ hir:: db:: InternTypeParamIdQuery
177
138
178
139
// SymbolsDatabase
179
140
crate :: symbol_index:: FileSymbolsQuery
@@ -183,17 +144,6 @@ impl RootDatabase {
183
144
184
145
// LineIndexDatabase
185
146
crate :: LineIndexQuery
186
- ] ;
187
-
188
- // To collect interned data, we need to bump the revision counter by performing a synthetic
189
- // write.
190
- // We do this after collecting the non-interned queries to correctly attribute memory used
191
- // by interned data.
192
- self . salsa_runtime_mut ( ) . synthetic_write ( Durability :: HIGH ) ;
193
-
194
- sweep_each_query ! [
195
- // AstDatabase
196
- hir:: db:: InternMacroQuery
197
147
198
148
// InternDatabase
199
149
hir:: db:: InternFunctionQuery
@@ -205,9 +155,6 @@ impl RootDatabase {
205
155
hir:: db:: InternTraitQuery
206
156
hir:: db:: InternTypeAliasQuery
207
157
hir:: db:: InternImplQuery
208
-
209
- // HirDatabase
210
- hir:: db:: InternTypeParamIdQuery
211
158
] ;
212
159
213
160
acc. sort_by_key ( |it| std:: cmp:: Reverse ( it. 1 ) ) ;
0 commit comments