Auto merge of #14632 - Veykril:lru-macro, r=lnicola
internal: Increase LRU cache size for parse_expansion and macro_expand queries
This commit is contained in:
commit
5750d81e30
@ -53,7 +53,7 @@ pub struct FileRange {
|
|||||||
pub range: TextRange,
|
pub range: TextRange,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const DEFAULT_LRU_CAP: usize = 128;
|
pub const DEFAULT_PARSE_LRU_CAP: usize = 128;
|
||||||
|
|
||||||
pub trait FileLoader {
|
pub trait FileLoader {
|
||||||
/// Text of the file.
|
/// Text of the file.
|
||||||
|
@ -115,6 +115,7 @@ pub(crate) fn from_source(node: &SyntaxNode) -> AstIdMap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
res.arena.shrink_to_fit();
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,29 +149,33 @@ pub fn enable_proc_attr_macros(&mut self) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_parse_query_lru_capacity(&mut self, lru_capacity: Option<usize>) {
|
pub fn update_parse_query_lru_capacity(&mut self, lru_capacity: Option<usize>) {
|
||||||
let lru_capacity = lru_capacity.unwrap_or(base_db::DEFAULT_LRU_CAP);
|
let lru_capacity = lru_capacity.unwrap_or(base_db::DEFAULT_PARSE_LRU_CAP);
|
||||||
base_db::ParseQuery.in_db_mut(self).set_lru_capacity(lru_capacity);
|
base_db::ParseQuery.in_db_mut(self).set_lru_capacity(lru_capacity);
|
||||||
hir::db::ParseMacroExpansionQuery.in_db_mut(self).set_lru_capacity(lru_capacity);
|
// macro expansions are usually rather small, so we can afford to keep more of them alive
|
||||||
hir::db::MacroExpandQuery.in_db_mut(self).set_lru_capacity(lru_capacity);
|
hir::db::ParseMacroExpansionQuery.in_db_mut(self).set_lru_capacity(4 * lru_capacity);
|
||||||
|
hir::db::MacroExpandQuery.in_db_mut(self).set_lru_capacity(4 * lru_capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_lru_capacities(&mut self, lru_capacities: &FxHashMap<Box<str>, usize>) {
|
pub fn update_lru_capacities(&mut self, lru_capacities: &FxHashMap<Box<str>, usize>) {
|
||||||
use hir::db as hir_db;
|
use hir::db as hir_db;
|
||||||
|
|
||||||
base_db::ParseQuery.in_db_mut(self).set_lru_capacity(
|
base_db::ParseQuery.in_db_mut(self).set_lru_capacity(
|
||||||
lru_capacities.get(stringify!(ParseQuery)).copied().unwrap_or(base_db::DEFAULT_LRU_CAP),
|
lru_capacities
|
||||||
|
.get(stringify!(ParseQuery))
|
||||||
|
.copied()
|
||||||
|
.unwrap_or(base_db::DEFAULT_PARSE_LRU_CAP),
|
||||||
);
|
);
|
||||||
hir_db::ParseMacroExpansionQuery.in_db_mut(self).set_lru_capacity(
|
hir_db::ParseMacroExpansionQuery.in_db_mut(self).set_lru_capacity(
|
||||||
lru_capacities
|
lru_capacities
|
||||||
.get(stringify!(ParseMacroExpansionQuery))
|
.get(stringify!(ParseMacroExpansionQuery))
|
||||||
.copied()
|
.copied()
|
||||||
.unwrap_or(base_db::DEFAULT_LRU_CAP),
|
.unwrap_or(4 * base_db::DEFAULT_PARSE_LRU_CAP),
|
||||||
);
|
);
|
||||||
hir_db::MacroExpandQuery.in_db_mut(self).set_lru_capacity(
|
hir_db::MacroExpandQuery.in_db_mut(self).set_lru_capacity(
|
||||||
lru_capacities
|
lru_capacities
|
||||||
.get(stringify!(MacroExpandQuery))
|
.get(stringify!(MacroExpandQuery))
|
||||||
.copied()
|
.copied()
|
||||||
.unwrap_or(base_db::DEFAULT_LRU_CAP),
|
.unwrap_or(4 * base_db::DEFAULT_PARSE_LRU_CAP),
|
||||||
);
|
);
|
||||||
|
|
||||||
macro_rules! update_lru_capacity_per_query {
|
macro_rules! update_lru_capacity_per_query {
|
||||||
|
Loading…
Reference in New Issue
Block a user