Skip to content

Commit 1efaa73

Browse files
authored
Modify a SmallVec inline size for UseList to be slightly larger. (#93)
This PR updates the `UseList` type alias to a `SmallVec` with 4 `Use`s (which are 4 bytes each) rather than 2, because we get 16 bytes of space "for free" in a `SmallVec` on a 64-bit machine. This PR improves the compilation performance of Cranelift by 1% on SpiderMonkey.wasm (measured on a Linux desktop with pinned CPU frequency, and pinned to one core). It's worth noting also that before making these changes, I explored whether it would be possible to put the lists of uses and liveranges in single large backing `Vec`s; the basic reason why we can't do this is that during liverange construction, we append to many lists concurrently. One could use a linked-list arrangement, and in fact RA2 did this early in its development; the separate `SmallVec`s were better for performance overall because the cache locality wins when we traverse the lists many times. It may still be worth investigating use of an arena to allocate the vecs rather than the default heap allocator.
1 parent 6394913 commit 1efaa73

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ repository = "https://github.com/bytecodealliance/regalloc2"
1212

1313
[dependencies]
1414
log = { version = "0.4.8", default-features = false }
15-
smallvec = "1.6.1"
15+
smallvec = { version = "1.6.1", features = ["union"] }
1616
fxhash = "0.2.1"
1717
slice-group-by = "0.3.0"
1818

src/ion/data_structures.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ pub struct LiveRangeListEntry {
101101
}
102102

103103
pub type LiveRangeList = SmallVec<[LiveRangeListEntry; 4]>;
104-
pub type UseList = SmallVec<[Use; 2]>;
104+
pub type UseList = SmallVec<[Use; 4]>;
105105

106106
#[derive(Clone, Debug)]
107107
pub struct LiveRange {

0 commit comments

Comments
 (0)