Dice Question Streamline Icon: https://streamlinehq.com

Performance impact of packing on alignment and padding

Ascertain the performance impact of packing struct members into bitfields, which alters native alignment and padding and introduces implicit bit-shift and masking operations on access.

Information Square Streamline Icon: https://streamlinehq.com

Background

The proposed C++ annotations pack booleans, enums, and bounded-range integers into a shared bitfield to reduce memory footprint and potentially improve cache utilization.

While packing can decrease bandwidth usage, it also removes native alignment and requires conversion operations on every access. The authors explicitly note that the net performance effect is not known a priori.

References

Yet, it is not clear a priori what performance impact the padding has.

An extension of C++ with memory-centric specifications for HPC to reduce memory footprints and streamline MPI development (2406.06095 - Radtke et al., 10 Jun 2024) in Section 3.1 (Memory compactification), Impact paragraph