Merge pull request #20882 from ChayimFriedman2/accurate-mem-report

internal: Clear next-solver cache before reporting memory usage in analysis-stats
This commit is contained in:
Chayim Refael Friedman 2025-10-21 20:07:50 +00:00 committed by GitHub
commit fe17c400de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 0 deletions

View file

@ -2,6 +2,7 @@
use std::{fmt, ops::ControlFlow};
pub use tls_cache::clear_tls_solver_cache;
pub use tls_db::{attach_db, attach_db_allow_change, with_attached_db};
use base_db::Crate;
@ -2239,4 +2240,12 @@ mod tls_cache {
})
})
}
/// Clears the thread-local trait solver cache.
///
/// Should be called before getting memory usage estimations, as the solver cache
/// is per-revision and usually should be excluded from estimations.
pub fn clear_tls_solver_cache() {
GLOBAL_CACHE.with_borrow_mut(|handle| *handle = None);
}
}

View file

@ -171,6 +171,7 @@ pub use {
method_resolution::TyFingerprint,
mir::{MirEvalError, MirLowerError},
next_solver::abi::Safety,
next_solver::clear_tls_solver_cache,
},
intern::{Symbol, sym},
};

View file

@ -345,6 +345,8 @@ impl flags::AnalysisStats {
self.run_term_search(&workspace, db, &vfs, &file_ids, verbosity);
}
hir::clear_tls_solver_cache();
let db = host.raw_database_mut();
db.trigger_lru_eviction();