jameysharp opened issue #5804:
Feature
The
EntitySet
type declared incranelift/entity/src/set.rs
is a fairly standard implementation of a bit-set. However, it uses 8-bit chunks in theEntitySet::elems
storage vector. It should use a size closer to the width of a machine word.Benefit
Using a larger size should give a small performance improvement.
Implementation
I'd prefer if
elems
were aVec<usize>
. Then the number of bits in each element is:const BITS: usize = core::mem::size_of::<usize>() * 8
All the places which use the constant
8
should instead refer toBITS
, and7
should be replaced withBITS - 1
.If someone wants to tackle this, it would also be great if you could add doc-tests for the methods on this type while you're there. If you do, you may be able to remove the existing tests as they should be redundant with reasonably comprehensive doc-tests.
Alternatives
We can always leave this alone; it's not terrible as-is.
jameysharp labeled issue #5804:
Feature
The
EntitySet
type declared incranelift/entity/src/set.rs
is a fairly standard implementation of a bit-set. However, it uses 8-bit chunks in theEntitySet::elems
storage vector. It should use a size closer to the width of a machine word.Benefit
Using a larger size should give a small performance improvement.
Implementation
I'd prefer if
elems
were aVec<usize>
. Then the number of bits in each element is:const BITS: usize = core::mem::size_of::<usize>() * 8
All the places which use the constant
8
should instead refer toBITS
, and7
should be replaced withBITS - 1
.If someone wants to tackle this, it would also be great if you could add doc-tests for the methods on this type while you're there. If you do, you may be able to remove the existing tests as they should be redundant with reasonably comprehensive doc-tests.
Alternatives
We can always leave this alone; it's not terrible as-is.
jameysharp labeled issue #5804:
Feature
The
EntitySet
type declared incranelift/entity/src/set.rs
is a fairly standard implementation of a bit-set. However, it uses 8-bit chunks in theEntitySet::elems
storage vector. It should use a size closer to the width of a machine word.Benefit
Using a larger size should give a small performance improvement.
Implementation
I'd prefer if
elems
were aVec<usize>
. Then the number of bits in each element is:const BITS: usize = core::mem::size_of::<usize>() * 8
All the places which use the constant
8
should instead refer toBITS
, and7
should be replaced withBITS - 1
.If someone wants to tackle this, it would also be great if you could add doc-tests for the methods on this type while you're there. If you do, you may be able to remove the existing tests as they should be redundant with reasonably comprehensive doc-tests.
Alternatives
We can always leave this alone; it's not terrible as-is.
maekawatoshiki commented on issue #5804:
Hi, I want to work on this.
jameysharp closed issue #5804:
Feature
The
EntitySet
type declared incranelift/entity/src/set.rs
is a fairly standard implementation of a bit-set. However, it uses 8-bit chunks in theEntitySet::elems
storage vector. It should use a size closer to the width of a machine word.Benefit
Using a larger size should give a small performance improvement.
Implementation
I'd prefer if
elems
were aVec<usize>
. Then the number of bits in each element is:const BITS: usize = core::mem::size_of::<usize>() * 8
All the places which use the constant
8
should instead refer toBITS
, and7
should be replaced withBITS - 1
.If someone wants to tackle this, it would also be great if you could add doc-tests for the methods on this type while you're there. If you do, you may be able to remove the existing tests as they should be redundant with reasonably comprehensive doc-tests.
Alternatives
We can always leave this alone; it's not terrible as-is.
Last updated: Dec 23 2024 at 12:05 UTC