Article: The Lost Art of Structure Packing
FinalEvilution
FinalEvilution at gmail.com
Mon Nov 2 08:36:56 UTC 2026
On Monday, 2 November 2026 at 01:18:51 UTC, Lance Bachmeier wrote:
> On Monday, 2 November 2026 at 00:29:56 UTC, Richard (Rikki)
> Andrew Cattermole wrote:
>> I found this rather nice article about padding in structs, it
>> also applies to D.
>>
>> http://www.catb.org/esr/structure-packing/
>
> Thanks for the reference. Claude recently used padding to
> increase my parallel random number generation speedup on 16
> processes from 4x to 11x when using std.parallelism. I was
> unaware that it could be so powerful. The article may provide
> some insight.
I'd like to recommend "Cpu Caches and Why You Care" by Scott
Meyers
https://youtu.be/WDIkqP4JbkE
to you, since you seem to be interested in performance.
More compact data structures reduce cache pressure and memory
bandwidth
which is probably where your performance improvement came from.
If your random number generation is a big bottleneck you could try
rewriting it using SIMD (Single instruction, multiple data)
intrinsics.
I've been using https://code.dlang.org/packages/intel-intrinsics
to
write a very simple image codec and I've managed to get some
really
good performance with it. Results may vary.
More information about the Digitalmars-d
mailing list