-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
As noted in 4f1c7df, turns out it's trivial enough I could well have done that in the first place after validating that was the issue, rather than add nohash and keep indexmap. This is a highly cut down implementation to just the operations necessary for `atom_to_re` and `propagate_match`. The gain in runtime are near 10% which is nothing to sneeze at. Though with almost 20% less instructions (!!!) that means the IPC has taken a dive and is now a hair below 3. I still have essentially no idea what that means, but I think it bears noting anyway. ``` 42.63 real 42.49 user 0.02 sys 145833984 maximum resident set size 0 average shared memory size 0 average unshared data size 0 average unshared stack size 9015 page reclaims 6 page faults 0 swaps 0 block input operations 0 block output operations 0 messages sent 0 messages received 0 signals received 0 voluntary context switches 118 involuntary context switches 408805706973 instructions retired 137020670968 cycles elapsed 140592576 peak memory footprint ```
- Loading branch information
Showing
4 changed files
with
72 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
pub struct IntSet { | ||
sparse: Vec<usize>, | ||
dense: Vec<usize>, | ||
} | ||
|
||
impl IntSet { | ||
pub fn new(capacity: usize) -> Self { | ||
Self { | ||
sparse: vec![usize::MAX;capacity], | ||
dense: Vec::with_capacity(capacity), | ||
} | ||
} | ||
|
||
pub fn insert(&mut self, value: usize) -> bool { | ||
let idx = self.sparse[value]; | ||
if self.dense.get(idx) != Some(&value) { | ||
self.sparse[value] = self.dense.len(); | ||
self.dense.push(value); | ||
true | ||
} else { | ||
false | ||
} | ||
} | ||
|
||
pub fn len(&self) -> usize { | ||
self.dense.len() | ||
} | ||
|
||
pub fn into_vec(self) -> Vec<usize> { | ||
self.dense | ||
} | ||
} | ||
|
||
impl std::ops::Index<usize> for IntSet { | ||
type Output = usize; | ||
|
||
fn index(&self, index: usize) -> &Self::Output { | ||
self.dense.index(index) | ||
} | ||
} | ||
|
||
impl std::iter::Extend<usize> for IntSet { | ||
fn extend<T: IntoIterator<Item = usize>>(&mut self, iter: T) { | ||
for val in iter { | ||
self.insert(val); | ||
} | ||
} | ||
} | ||
|
||
impl <'a> std::iter::Extend<&'a usize> for IntSet { | ||
fn extend<T: IntoIterator<Item = &'a usize>>(&mut self, iter: T) { | ||
for val in iter { | ||
self.insert(*val); | ||
} | ||
} | ||
} |
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