Add LayoutInterner to LayoutCache

Adds a thread-local interner of layouts to LayoutCache, and updates all
references appropriately.

This is a bit suboptimal for single-threaded workloads that will look at
creating layout caches again, like the REPL, but I think that's okay for
now - since the global interner will be uncontested for those workloads, it
should still be plenty fast to access the interner, even behind a lock.
This commit is contained in:
Ayaz Hafiz 2022-08-31 12:03:30 -05:00
parent 9d170be5c7
commit c5466810a4
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
19 changed files with 177 additions and 86 deletions

View file

@ -510,7 +510,7 @@ fn start_phase<'a>(
IdentIds::default(),
Subs::default(),
ProcsBase::default(),
LayoutCache::new(state.target_info),
LayoutCache::new(state.layout_interner.fork(), state.target_info),
ModuleTiming::new(Instant::now()),
)
} else if state.make_specializations_pass.current_pass() == 1 {
@ -2486,10 +2486,9 @@ fn update<'a>(
if state.goal_phase() > Phase::SolveTypes
|| matches!(state.exec_mode, ExecutionMode::ExecutableIfCheck)
{
let layout_cache = state
.layout_caches
.pop()
.unwrap_or_else(|| LayoutCache::new(state.target_info));
let layout_cache = state.layout_caches.pop().unwrap_or_else(|| {
LayoutCache::new(state.layout_interner.fork(), state.target_info)
});
let typechecked = TypeCheckedModule {
module_id,