The Int32 type is most effective for common variables, such as loop counters, in both 32-bit and 64-bit applications.
When you process arrays of large data arrays, the read / write efficiency of one value does not matter much, it is important to have access to the data in order to get as few misses in the memory cache as possible. Skipping a memory cache is very expensive compared to accessing cached memory. (In addition, a page error (memory replaced by disk) is very expensive compared to skipping the memory cache.)
To avoid gaps in the cache, you can store data as compact as possible, and when processing data, you can access it as linearly as possible so that the available memory area is as small as possible.
Using Int16 most likely be more efficient than Int32 for any array large enough to span multiple cache blocks, and a cache block is usually only a few kilobytes.
Since your values ββcan be stored in just 12 bits, it can be even more efficient to store each value in 1.5 bytes, although this means more processing data. Reducing 25% of the data size can lead to additional processing.
Guffa source share