jameysharp opened issue #5804:
Feature
The
EntitySettype declared incranelift/entity/src/set.rsis a fairly standard implementation of a bit-set. However, it uses 8-bit chunks in theEntitySet::elemsstorage 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
elemswere aVec<usize>. Then the number of bits in each element is:const BITS: usize = core::mem::size_of::<usize>() * 8All the places which use the constant
8should instead refer toBITS, and7should 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
EntitySettype declared incranelift/entity/src/set.rsis a fairly standard implementation of a bit-set. However, it uses 8-bit chunks in theEntitySet::elemsstorage 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
elemswere aVec<usize>. Then the number of bits in each element is:const BITS: usize = core::mem::size_of::<usize>() * 8All the places which use the constant
8should instead refer toBITS, and7should 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
EntitySettype declared incranelift/entity/src/set.rsis a fairly standard implementation of a bit-set. However, it uses 8-bit chunks in theEntitySet::elemsstorage 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
elemswere aVec<usize>. Then the number of bits in each element is:const BITS: usize = core::mem::size_of::<usize>() * 8All the places which use the constant
8should instead refer toBITS, and7should 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
EntitySettype declared incranelift/entity/src/set.rsis a fairly standard implementation of a bit-set. However, it uses 8-bit chunks in theEntitySet::elemsstorage 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
elemswere aVec<usize>. Then the number of bits in each element is:const BITS: usize = core::mem::size_of::<usize>() * 8All the places which use the constant
8should instead refer toBITS, and7should 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 06 2025 at 06:05 UTC