data_packing

as we've shown in other examples in the cal, and in several
spots in the course notes, getting good cache behavior is
essential to getting good application performance. one technique
for maximizing cache efficiency is by packing data tightly within
the data structures created by the user. this technique is known
as data packing.

data packing is essential to understand for several reasons:

 1) packed data fits more tightly in cache, and therefore
    has a better chance of being in-cache when required.
 2) packed data utilizes less memory overall.
 3) data packs differently across platforms, so it's key
    to understand what is best for your users, and which
    data structures are most commonly traversed, to
    address both 1) and 2).

this example shows a variety of structures, and ways in which
they can be packed. the example further shows how to determine
the size of a word on a particular platform.

some platforms don't require structures or classes to end on
word boundaries, but most platforms do require certain data
elements to be word-aligned.

this example shows how some structures can be packed to best
fit in memory. the key element in packing data in structures
you create is to put like-sized elements together.



