mblock_map on 32-bit targets should be a compact bitset
Currently, on 32-bit targets, mblock_map
is defined as a StgWord8
array, with each byte representing a boolean for the corresponding mblock. This is easy to implement but wastes a lot of space. It should be possible to use a compact bitset (implemented by StgWord64
array) to represent mblock_map
, with the following pros:
- No waste in space. This can be significant when we want to fine tune the mblock size for certain targets
-
getFirstMBlock
andgetNextMBlock
can get a nice speedup, a single memory load with actz
instruction can check 64 mblock map entries at once.
Potential cons:
-
HEAP_ALLOCED()
takes more instructions since some bitwise operations are needed to calculate the correct index, and also to mask irrelevant bits. And it's a hot path in the RTS codebase.
Should we change mblock_map
implementation? Opening a tracking ticket here and waiting for discussion with other folks familiar with RTS.