How does ZRAM impact heavy load?

Just to better understand my system. ZRAM moves some swap disk over to a portion of the ram. Let's take a specific scenario I went through and see how it would behave.

I have 16GB of ram. I developed a Vapoursynth video editing script to denoise 5K videos footage. To run it and re-encode with 16GB of ram, I need to downscale the video for some of the passes to barely fit into my ram. If I set it just a bit higher, the performance goes down to a crawl as it scratches onto the disk.

Now, with ZRAM, there is less ram available, but there is faster swap available........ so what will happen with the exact same script?

I guess one way to find out is to run it, but I haven't set that up yet.

ZRAM is RAM compression, which does not involve the SSD or heaven forbid the HDD. It is not even new, Android is best known using ZRAM.

Swapping using the storage device is orders of magnitude slower.

In my system, here is the reading:

I have 16GB real RAM with 2GB shared video. Checking the overall "free" memory, it reads as around 23.9GiB

1 Like

So it will in fact increase the available RAM, to a degree that depends on the compressability of the content?

Video content... well... since it's RAW, there's memory padding, there's blank frames, there are patterns. Ya I guess it can compress. Particularly if the data is reset to '0' before use.

So I should expect the script to run easier, at the expense of a slight CPU cost?

I guess I'd have to try to find out how it behaves.

Discaimer: I'm just guessing and do not really know.

I would expect an improvement, but how big is hard to tell as it depends on many factors.

Most important should be how much data can be swapped and hence get compressed in ZRAM, and how good does it compress with the selected algorithm.
This indicates 2:1 compression, some report even 4:1 (do they brag? I don't know), but could also be lower in practice.

In my case, the few times I looked at RAM usage I seen roughly half the installed memory used for ZRAM but I failed to understand the compression ratio. It means jack though, as I have much less installed memory (3.8 GB) and a much lower and different workload.

I guess the best way to know is indeed to try, and see how much less downscaling you can get away with. It would be interesting to see how much ZRAM helps with such a workload, considering it's both CPU and memory heavy.

I know too little to advise anything, but I'd also expect some further improvement fine-tuning the size and compression algorithm for the machine and workload, but that's way beyond my knowledge. There's something about it on the Arch wiki -- of course. Interestingly, it can be configured without having to reboot.

My bet is it would allow for somewhere between 1.1 and 1.4 times the resolution before swapping to disk, and possibly degrade more gracefully when close to the edge.
Figures pulled out of thin air, taking a wild guess that (averaging compression ratio and ZRAM usage ratio) it would double how much data fits in memory.

Though I suspect you already knew this much.

1 Like

It might help in the case that I'm stretching the RAM to its limit before the computer burst in flames (if I accidentally open another script preview, it stutters and then hard resets). Not mentioning the heat because the GPU runs at full spin too... to output a mere 0.7fps.

In cases that aren't so extreme but CPU-intensive, then what is the CPU cost of ZRAM? Let's say you're encoding 8K video footage with x265. ZRAM takes some CPU; but also makes more memory available for cache. Video cache is important for video processing.

I'd be curious of that encoding test with or without ZRAM. I'm sure some have done such benchmarks somewhere?

It is the RAM that is compressed, not the content. I'm not exactly sure what voodoo ZRAM does in the background. The real advantage of this is the "swap" happens in the RAM instead of the slow storage device such as the SSD/HDD/EMMC.

Android is the OS that is very well known for using ZRAM system.

Yes, it should.

This would indeed be the easiest way to get a clear answer. :wink:

:question:

That is like saying “It is the filesystem that is compressed, not the files” :nerd_face:

4 Likes

It is the RAM that is compressed, not the content

You lost me right there. Only thing I can think of; I heard some alien races have spaceships that look smaller from the outside, say, 100m wide, but when you walk inside, the ship is actually a lot bigger. Is what what you’re referring to?

1 Like

We only allow comparisons in connection with cars.
Politics, religion and spaceships are forbidden.
Car sample
How many people fit in a car with the help of ZRAM :smiley:

7 Likes

How zram is made:

1 Like

For others coming by this thread, the answer is here. 1.1fps with zram, 2.4fps without.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.