Bitmasks instead of boolean[] for vector masks
Philippe Marschall
kustos at gmx.net
Sun Dec 8 20:04:40 UTC 2024
Hello
I was trying out the Vector API and was surprised by the amount of
boolean[] allocations the code made. The code is here [1].
With JDK 23 on an AMD Ryzen 7 PRO 5750GE (preferred size 256 bit)
allocations were:
- about 1 million ByteVector.ByteMasks with a shallow size of 18 MB
- about 2 million boolean[] with a shallow size of 100 MB, suggesting
for every ByteMask two boolean[] are allocated
- 125k ByteVector with a shallow size of 2 MB
I wanted to ask whether in the past any considerations where given to
replace the boolean[] with bitmasks, for example an int or long. Certain
mask operations could then become simple integer operations, for example
#eq(), #not(), #anyTrue(), #allTrue(), #toLong(), #and(), #or(), #xor()
and so forth.
I have no idea about the impact this would have on the rest of the
system like the compiler and native code.
[1]
https://github.com/marschall/is-latin1/blob/master/src/main/java/com/github/marschall/islatin1/IsLatin1.java#L63
Regards
Philippe
More information about the core-libs-dev
mailing list