System Hang Prevention is killing my encoding!

It seems that no matter the format, it creates 4GB files in 9m segments; for 30fps 5K or for 60fps 2.7K. GoPro h265 has bugs causing decoding errors, so now I switched back to h264.

ok so they are not raw files they are gopro files?
what output size quality are you after ?
you say h264, h265 to be able to view on say youtube?
edit why do you think it creates 4gb file of only 9min,s?

it will be for YouTube. Still tweaking the way I configure it. I want above 1K... but 2.7K is only 60fps not 30fps, and that's not suitable indoors with low light. Otherwise it's 1K or 4K in 30fps. It just encodes at standard bitrate no matter the settings it seems; with an option to increase bitrate even further. Fine.. just need to re-encode them afterwards. Then as I'm doing the montage, there seems to be 1 or 2 frames off when switching video compared to the separate audio track...

Then it has wrong VUI tag saying it's TV-range when it's PC-range, video time doesn't account for time zone, h265 encodes with errors...

Kind of getting off-topic.

try davice resolve it will do what you want it to do and quicker ?

For a "memory leak" performance over time went from 1.0fps to 1.3fps, as memory usage reduced (leaked?) slightly over time.

Not necessary.

With zram disabled, I get 2.7fps with same settings, but it gets killed pretty quick. It looks like there is no swap at all!!!

OK how do I put back some normal swap?

Do you already have a swap partition? swapon it.
Otherwise, assuming there is free space on some drive, you can create a partition there, set the swap partition flag, mkswap it (careful with the device name!) then swapon it.
On next reboot systemd should find it and use it.
swapon by itself will report the swap devices in use.

P.S. sorry to see that zram did not help, so much for my "I would definitely expect"...

1 Like

No swap partition by default on Garuda.

Performance with or without zram is 1.1fps vs 2.6fps. That means zram isn't suitable for heavy work like video encoding. Which; ironically, is among the only things that require 16GB or 32GB of ram.

Off to creating a swap partition then...

I always create one anyways, old habits die hard. :wink:

You may want to read this thread for some other ideas:


This all indicates that whatever you're doing is using more RAM than you have available. There's no way to solve this other than using less RAM, or buying more RAM.

Adding swap won't solve the problem, just make it take longer to fail.

This would likely be the best place to spend time looking.


Yup, 2.4fps sustained load, 100% CPU usage. That's more what I'd expect. It takes all available ram for 5K video; and it takes all available ram for 2.7K video too. 5 more clips should take a bit more than 4h each, which means it will be done in 20 hours. Learning the Linux way: scrap the GUI, create a batch file and queue them up.

I could create a script zram-off to disable it and enable swap. When I'm not doing heavy encoding, for everything else, is it really helping? Including when I pass 8GB to Windows for gaming.

Thanks for the advice of disabling copy-on-write and compression for Win10 VM. I was just thinking though; one advantage of having Win10 within Linux is that snapshots not only save my Linux but also rollback Windows. Got an idea how taxing these 2 features really are on performance?

For those who are curious why it's taking so much memory. It's because I'm running 3 different denoisers and feeding them into each other. BM3D (running on GPU) is particularly heavy on RAM! But in retrospect; normal usage of BM3D requires 2 passes, and I'm doing just 1 pass of it. This script is actually lighter than doing dual-pass BM3D, and gives much better quality!

As I'm typing this; I'm seeing how responsive zen kernel really is under load.


I'm thinking of the pros and cons of zram. It is not suitable for heavy computation (which is what high ram is generally for), but may work well for cache. Is 16GB system cache really useful? On a system with 16GB+, it never really uses much swap anyway. Then on top of extra CPU usage (and perhaps cpu cache bottlenecks?), it will also bring higher memory latency. By how much? For gaming, if it goes into the zram space, we could see a lower minimum framerate due to higher memory latency.

Which brings the question. With 16GB+ of RAM, in what cases do zram benefit?

I take your point, and it is an interesting question. One thing to bear in mind is, as you pointed out, the task you were using to test the impact of zram had a very stable memory demand. You were able to dial in on a relatively precise workload and squeeze every MB of juice out of the RAM.

Conversely, the memory demand of a game is bound to be more dynamic. Sometimes your machine might call for all 16GB, other times not. The good thing about zram is it might help keep any spill-over off of the swap. That will affect performance more dramatically than using RAM vs zram.

While RAM might perform better than zram in a toe-to-toe test like you had, at the end of the day the two of them would be pretty much neck-and-neck in a race while swap would be an outright dog in comparison.

Another performance consideration. If I run 2 encodings back-to-back, the 2nd run doesn't go as smoothly and does not recover over time. If I add sleep 20 between each run, to give the kernel the time to reset itself and take a breathe before the next dive -- then it runs soft and smooth.

I admit that this 2.7K encoding task could be tweaked to squeeze very MB of juice; but the 5K encoding task also squeezed just as much out of it. Heavy computing will take all ram available as cache and adjust to it.

Other than that. With 4 or 8GB, you'll definitely run on swap. With 16GB, does the swap ever kick in under normal usage? There seems to always be a minimal swap usage of things it considers it doesn't need to access (I think). If swap does kick in, then it will cause some slowdown. When the encodings are done, I could keep an eye on swap usage to see whether it's being used.

It would be nice to see what 1 frame looks like before all the denoising and 1 after


I'm still wondering (not that I'd know how to pull it off, mind you) if nohang could be put to use, something like signalling your code when it's close to an out of memory condition (assuming the code can do anything with the information), and/or maybe ananicy since you report that a sleep to give the system time to recover helps. Perhaps, atop to profile what's going on. On the other hand, those would be more processes taking cpu and memory. Also, I see some zram parameters can be adjusted at runtime, without having to swapoff/swapon.

Plenty of hand waving and wishful thinking from me, I know... :man_shrugging: sometimes I talk too much.

Your situation somewhat reminds me of when I had to compile Firefox from source on very old hardware. I had to disable tmpfs when compiling Firefox or it would fail with "out of space" errors. It wasn't running out of physical space, but space within the tmpfs. I would add lots of swap space on my SSD and a 10,000 rpm drive to give it plenty of expansion room. Then I would shut down all other non-essential processes and start the complilation process then go to bed and it would then complete successfully with tmpfs disabled. After Firefox had finished compiling I would re-enable tmpfs.

I think this may be somewhat analogous to what you are experiencing. Disabling zram and Nohang, and enabling lots of SSD based swap space might just give you enough cushion to finish your task. You can then re-enable swap and Nohang for your everyday computing needs.

The other option is of course to drastically limit the CPU resources your script is using.

Just an old guys take on things, and as always YMMV.

1 Like

It was running very smooth and stable at 2.2fps, half-way through it. Plenty of swap memory available. Open FireDragon and FREEZE. Need to hard reboot. It's the 3rd time it does that.

I wonder how that "cacule" kernel would behave in this situation.

As I stated, I would start the long process before going to bed so that other apps weren't making demands on the ram.

1 Like

I got many questions.

After another freeze for starting the browser; what is causing Linux to freeze? Normally, if it runs out of memory, it kills some applications. Even Windows remains more stable under heavy load.

2nd... if I'm barely able to encode 2.7K clip in h264, I tried my previous encodings of 5K videos into h265. Running the exact same scripts as I ran before at .5-.7fps. Here it brings the computer to a crawl at 0.1fps.

It's losing the race against Windows here... why?

Did you set up a swap partition? When you are running your memory right to the brink and you have no swap, if it goes over you will get a freeze or a crash.

Windows leans heavily on swap. We use Windows at work and a lot of the time when I check, my laptop is holding more in virtual memory than physical memory. It's a pretty crappy laptop and only has 8GB of RAM, and every Microsoft app is super memory hungry (Teams for example can sit on a gig sometimes, just sitting there doing nothing), but yeah--the swap goes deep.

Try setting up a swap partition, or even a just swap file and just see if it helps. You could always get rid of it later if you want to.

1 Like