@@ -149,29 +149,33 @@ impl RootDatabase {
149149 }
150150
151151 pub fn update_parse_query_lru_capacity ( & mut self , lru_capacity : Option < usize > ) {
152- let lru_capacity = lru_capacity. unwrap_or ( base_db:: DEFAULT_LRU_CAP ) ;
152+ let lru_capacity = lru_capacity. unwrap_or ( base_db:: DEFAULT_PARSE_LRU_CAP ) ;
153153 base_db:: ParseQuery . in_db_mut ( self ) . set_lru_capacity ( lru_capacity) ;
154- hir:: db:: ParseMacroExpansionQuery . in_db_mut ( self ) . set_lru_capacity ( lru_capacity) ;
155- hir:: db:: MacroExpandQuery . in_db_mut ( self ) . set_lru_capacity ( lru_capacity) ;
154+ // macro expansions are usually rather small, so we can afford to keep more of them alive
155+ hir:: db:: ParseMacroExpansionQuery . in_db_mut ( self ) . set_lru_capacity ( 4 * lru_capacity) ;
156+ hir:: db:: MacroExpandQuery . in_db_mut ( self ) . set_lru_capacity ( 4 * lru_capacity) ;
156157 }
157158
158159 pub fn update_lru_capacities ( & mut self , lru_capacities : & FxHashMap < Box < str > , usize > ) {
159160 use hir:: db as hir_db;
160161
161162 base_db:: ParseQuery . in_db_mut ( self ) . set_lru_capacity (
162- lru_capacities. get ( stringify ! ( ParseQuery ) ) . copied ( ) . unwrap_or ( base_db:: DEFAULT_LRU_CAP ) ,
163+ lru_capacities
164+ . get ( stringify ! ( ParseQuery ) )
165+ . copied ( )
166+ . unwrap_or ( base_db:: DEFAULT_PARSE_LRU_CAP ) ,
163167 ) ;
164168 hir_db:: ParseMacroExpansionQuery . in_db_mut ( self ) . set_lru_capacity (
165169 lru_capacities
166170 . get ( stringify ! ( ParseMacroExpansionQuery ) )
167171 . copied ( )
168- . unwrap_or ( base_db:: DEFAULT_LRU_CAP ) ,
172+ . unwrap_or ( 4 * base_db:: DEFAULT_PARSE_LRU_CAP ) ,
169173 ) ;
170174 hir_db:: MacroExpandQuery . in_db_mut ( self ) . set_lru_capacity (
171175 lru_capacities
172176 . get ( stringify ! ( MacroExpandQuery ) )
173177 . copied ( )
174- . unwrap_or ( base_db:: DEFAULT_LRU_CAP ) ,
178+ . unwrap_or ( 4 * base_db:: DEFAULT_PARSE_LRU_CAP ) ,
175179 ) ;
176180
177181 macro_rules! update_lru_capacity_per_query {
0 commit comments