Re:Zig self hosted compiler is now capable of building itself
by dralley on Saturday April 16, 2022 @01:29PM
(#31054210)
In the past they've talked about the speed and memory improvements they've gotten from using MultiArrayList in the compiler, storing tags separately from the unions themselves. If you have a union with a size of 16 bytes and you add a tag to that which is 1 byte, a lot of space is wasted due to padding. If you keep the tags in a separate array, both arrays are individually densely packed. Less memory wasted due to padding == less memory use overall and better utilization of cache.
But in terms of the implementation, this means working with untagged unions, because the tags are maintained externally.
But in terms of the implementation, this means working with untagged unions, because the tags are maintained externally.