-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #108300 - oli-obk:elsa, r=eholk
Use a lock-free datastructure for source_span follow up to the perf regression in #105462 The main regression is likely the CStore, but let's evaluate the perf impact of this on its own
- Loading branch information
Showing
12 changed files
with
79 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use std::marker::PhantomData; | ||
|
||
use rustc_index::vec::Idx; | ||
|
||
pub struct AppendOnlyVec<I: Idx, T: Copy> { | ||
#[cfg(not(parallel_compiler))] | ||
vec: elsa::vec::FrozenVec<T>, | ||
#[cfg(parallel_compiler)] | ||
vec: elsa::sync::LockFreeFrozenVec<T>, | ||
_marker: PhantomData<fn(&I)>, | ||
} | ||
|
||
impl<I: Idx, T: Copy> AppendOnlyVec<I, T> { | ||
pub fn new() -> Self { | ||
Self { | ||
#[cfg(not(parallel_compiler))] | ||
vec: elsa::vec::FrozenVec::new(), | ||
#[cfg(parallel_compiler)] | ||
vec: elsa::sync::LockFreeFrozenVec::new(), | ||
_marker: PhantomData, | ||
} | ||
} | ||
|
||
pub fn push(&self, val: T) -> I { | ||
#[cfg(not(parallel_compiler))] | ||
let i = self.vec.len(); | ||
#[cfg(not(parallel_compiler))] | ||
self.vec.push(val); | ||
#[cfg(parallel_compiler)] | ||
let i = self.vec.push(val); | ||
I::new(i) | ||
} | ||
|
||
pub fn get(&self, i: I) -> Option<T> { | ||
let i = i.index(); | ||
#[cfg(not(parallel_compiler))] | ||
return self.vec.get_copy(i); | ||
#[cfg(parallel_compiler)] | ||
return self.vec.get(i); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters