CRAM: Efficient Hardware-Based Memory Compression for Bandwidth Enhancement
arxiv.org
arxiv.org
For example, consider an analytical engine going over values in a column of a database to sum it together. To increase the bandwidth, you can consider compressing the values (for example, with some form of Huffman encoding), and you have two options:
1. Decompress the values before passing them onto calculation, then do the calculation. This is what the paper proposes (transparently in HW as the data are being used in the cache).
2. Do the "addition" directly on the compressed values. This requires more logic. (But it doesn't have to be just implemented in software, it could be hardware assisted by some FPGA or something like that.)
So I wonder, instead of compressing the cache, wouldn't it be better to implement the 2nd solution?
The disadvantage of the 1st solution is that since it has to work in the general case, the compression is more likely to be bad in special cases, where the 2nd solution with a specialized compression/processing combo could be superior.
But even in this case, you don't deal with compressed data directly, but decompress only 1 block at a time.
What I mean by "directly" is instead of having to do
y = y + c^-1 (x_i)
where c(x) is the compression function (and c^-1 is its inverse, decompression), we could define a function f such that
z = f(z, x_i)
and final y = c^-1(z). This f would entail both the "+" (operation to be done on the data) and c^-1 (the decompression).
In general, it's non-trivial to come up with f, but I do believe that it would be in many cases a better approach than to use the first method.
Floating-point numbers can be seen as a simple case of this. If we represent numbers in fixed decimal point, then we have a lot of 0s in the numbers (and also lot of digits of very low significance) that we mostly don't need to have there. Therefore, in practice, we use compression - floating-point representation. The operations on FP are more complicated (you have to align the mantissas before you do arithmetic operations), but it's a good trade-off.
Most data requires random access to the middle, which is something compression is usually very bad at doing cheaply. You would have to leave boundary markers which eats into your size and speed advantage.
Updating a record will change its length, requiring you to reallocate and possibly rewrite subsequent values, or even the entire parent data structure. Imagine updating the Z coordinate of the 3rd element in an array of a million objects.
In domains where people need speed they are pretty clever at arranging to not need that.
This smells an awful lot like an impossible infinite compression claim; any real compressor must increase the length of at least some inputs due to the pigeonhole principle.
Their solution is to add a 16-entry table to track "lines that look like they have the compressed-line marker, but are not actually compressed" (and they also store such lines inverted in DRAM, but this seems inessential). They claim 16 entries is enough based on probabilistic arguments, but they should be thinking of storing data generated by an adversarial process; one such process would be to choose 60 incompressible bytes followed by the 4-byte compressed line indicator.
Including just one bit of metadata per cache line of memory is 32MiB, more than the 0.75 bits/line (24MiB) calculated on page 5 for the scheme they would like to replace.
Their next bit of handwavium is that they use "DES" to choose line markers in a way dependent on a secret key which can be changed in case of a LUT overflow. I wasn't immediately able to find a modern figure on how fast hardware "DES" is, but a 2003 paper gives a figure of "21 to 37 cycles of latency" https://www.intopix.com/Ressources/WPs_and_Sc_Pub/intoPIX%20... -- will this fit into the time budget or will it slow memory accesses? (They first say this is off the critical path but then that the marker is per-line, I don't see how both are true)
When the limited table is exhausted, a new key is chosen and all of memory must be updated (so you really don't want to do that) They dismiss this by again appealing to the rarity as "1-in-2^512" but if that's true you might as well just design the chip to blow up when the condition arises. If any timing information about "line appears in LUT" is visible to a program, then it is just 16 * 2^32 instead for an adversarial program (you can tweak line 1 until it needs a LUT entry, which takes just 2^32 writes; then repeat for the next line)
Why even include this sentence when the rest of the post is about the extra state it uses to track collisions?
> Including just one bit of metadata per cache line of memory is 32MiB, more than the 0.75 bits/line (24MiB) calculated on page 5 for the scheme they would like to replace.
Sure? The point of this scheme is to not store any metadata per line of main memory.
> Their next bit of handwavium is that they use "DES" to choose line markers in a way dependent on a secret key which can be changed in case of a LUT overflow. I wasn't immediately able to find a modern figure on how fast hardware "DES" is, but a 2003 paper gives a figure of "21 to 37 cycles of latency" https://www.intopix.com/Ressources/WPs_and_Sc_Pub/intoPIX%20.... -- will this fit into the time budget or will it slow memory accesses? (They first say this is off the critical path but then that the marker is per-line, I don't see how both are true)
21 to 37 cycles is definitely lower latency than accessing memory. And you can easily pipeline it to match the rate of memory accesses.
> When the limited table is exhausted, a new key is chosen and all of memory must be updated (so you really don't want to do that) They dismiss this by again appealing to the rarity as "1-in-2^512" but if that's true you might as well just design the chip to blow up when the condition arises. If any timing information about "line appears in LUT" is visible to a program, then it is just 16 * 2^32 instead for an adversarial program (you can tweak line 1 until it needs a LUT entry, which takes just 2^32 writes; then repeat for the next line)
So an adversarial program can waste CPU? It can already do that.
But more importantly, the LUT only needs to be involved when checking the marker on a memory access. It should be very possible to make it fixed-timing.
I also don't like that there is a claimed speedup figure but it is not clear in a cursory reading and looking at the available tables and graphs what the baseline is? It's all done in emulation (apparently) so it's hard to know if it is amortized because there is no actual time to access or something else, but that could just be my unfamiliarity with that emulator.
The sales pitch is "faster than memcpy." Fetch data from RAM, decompress it in L1,2,3 caches and run operations on the data. Some very nice benchmarks available.
General purpose CPUs are all about latency. Only very specialized problems would benefit from memory compression. On the other Hand compression will increase latency which is counterproductive to any traditional CPU tasks.
Is it bad that I'm looking forward to the end of Moore's law (a little)?
However, there are currently no known sources that support it, and it’s a lossy compression.
Since bandwidth requirements are going up faster than thr bandwidth of cables, one can expect DSC to be common once 8K displays are a thing.
None of this is the case here.
You’re probably thinking about delta color compression.
Also, good compression requires large corpus / large model - thus page-based compression is much more useful in real life. For example Google's ChromeOS uses zram by default since 2013 [1].
If you were to use a 64-bit cache line you're just retrieving one word at a time.
The cache line size is indeed 64 bytes, not bits as caching less than the bus-width wouldn't really make much sense.
No. 64 and 128 (to a lesser extent) bytes are pretty much the only extant cache line sizes these days.
64 bit cache lines would be insane.