Hacker News new | ask | show | jobs
by embedding-shape 13 days ago
> To the user, there's nothing more important running right now.

Well, to a certain degree. I have a relatively uncommon GPU, and run games on Steam (and Linux), so literally every game does shader compilation for me. Even with a beefy CPU and beefy GPU, if the shader compilation uses more than 16 threads, my computer basically freezes until its done with it, as it's so performance intensive, kind of have to throttle things if I want to be able to use the desktop for the 10 minutes the shader compilation takes sometimes.

Edit: "Do you use Linux? That only happened to me when I was using a dram-less ssd for swap and doing IO heavy operations on the NFS mounted drive"

I do! I do have NFS drives, but not for Steam games or anything else relevant. I'm also not using swap at all. RAM seems fine during this, it's just pegging all cores to 100% usage immediately and stays there, making everything else suffer.

4 comments

> Even with a beefy CPU and beefy GPU, if the shader compilation uses more than 16 threads, my computer basically freezes until its done with it

Strange. This never happens to me on Windows. I only notice that the fans spin up a little because all cores are pegged.

i've only seen the shader compilation on linux.
Do you use Linux? That only happened to me when I was using a dram-less ssd for swap and doing IO heavy operations on the NFS mounted drive, since the system will use ram as a buffer (which pushes things to swap)
My steam machine is netboot diskless nfs only.(probably a mistake, but I have a nice NAS and so leaned hard into it) However, having no swap worries me. for openbsd they document how to swap to nfs. But the linux docs say not to do that. What is the best practice here? swap to an iscsi block?
zram+earlyoom sounds like the right answer there. Compressed ram works as the low memory signal
fedora45/proton/steam user.

What you are describing is not normal. Which GPU? I have not seen this on Nvidia 4060/4070, or AMD 580, 6600, or 9060/9070.

Well, as mentioned, the hardware is relatively uncommon; 9970X + Pro 6000 GPU.
> Even with a beefy CPU and beefy GPU, if the shader compilation uses more than 16 threads, my computer basically freezes

Sounds like a scheduling problem that should be adressed at the OS level.

Seems a deep one if so. I've tried a bunch of alternative schedulers to try to avoid the issue, like Bore and BMQ, but seems to happen regardless. Been like this on previous computers too, fwiw, unless I turn down the concurrency for shader compilation stuff will lag heavily until it finishes.
> tried a bunch of alternative schedulers

1. Have you tried enabling full preemption as well? I run Debian, and before I did that I had lots of stutters from any kind of background load thanks to dynamic preemption.

2. Even then, ZFS was causing stutters until I lowered it's priority as well (spl_taskq_thread_priority=0)

3. On non-ZFS drives, try setting your I/O scheduler to Kyber for NVME or BFQ for everything else. "mq-deadline" isn't great for interactive use on a SATA SSD, even for non-boot drives, and even NVME sometimes stutters under "none" for some people.

> I'm also not using swap at all.

4. zswap (combined with zstd compression, "min_ttl_ms=1000", and "vm.page-cluster=0") and "defer+madvise" memory compaction can help. (Something about the kernel really liking having swap on-hand.)

Steam runs shader compilations at batch policy and nice 19, so without RAM or I/O bottlnecks even gaming shouldn't be too bad (though from personal experience it still induces some stuttering). It's just most distros are tuned horribly for this. (Not to sound flippant, I understand the frustration of "just try this" and it doesn't work, but it's everything I can think of RN.)

Many thanks for all the things to try, definitely will take a closer look and explore what you've mentioned next time it happens! :)
When you do, I forgot to mention I had difficulty getting a couple of settings to stick on reboot. Some had "proper" methods that were bugged, others seemingly needed a startup script anyways, so I just stuck those two groups into one:

    echo zstd > /sys/module/zswap/parameters/compressor
    echo 0 > /sys/module/spl/parameters/spl_taskq_thread_priority
    echo 1000 > /sys/kernel/mm/lru_gen/min_ttl_ms
    echo defer+madvise > /sys/kernel/mm/transparent_hugepage/defrag
...and some quick-n-dirty scripting[1] for ZFS drives.

Fellow HNer 'networked' pointed out[3] that the compressor type was because Debian wasn't loading the zstd module on startup for some reason, so you could fix it that way as well. Dunno your distro, hopefully you don't need these hacky workarounds that continue to annoy me.

[1]https://www.reddit.com/r/zfs/comments/1qerlvn/how_to_only_se...

[context]https://www.reddit.com/r/linuxquestions/comments/1qenr06/id_... and https://wiki.archlinux.org/title/Improving_performance#Kerne...

[3]https://news.ycombinator.com/item?id=47505661

[4]https://openzfs.github.io/openzfs-docs/Performance%20and%20T...

[5]https://wiki.archlinux.org/title/Zswap

You could try cpu pinning or ulimits to limit the program from using one core so there's always one free.

But it's also possible that the problem is in the kernel and the shaders are actually doing some system call that's locking up the kernel. Like maybe there's a bug in your cuda or nvidia driver that's causing the kernel to lock.