Hacker News new | ask | show | jobs
by simonask 13 days ago
I hate this. We have a whole operating system doing its absolute best to prioritize hardware resources. Don't be out here throttling yourself.

Especially for something like compiling shaders. It literally never happens unless the user is about to go play a game, which is going to consume most resources anyway. To the user, there's nothing more important running right now.

6 comments

But why use that metric. The OS already has support for this.

Why not just re-nice the process or whatever equivalent for the threads that do the compiling? Tell the kernel what’s going on, it will handle it for you.

Don’t hack your own solution.

> To the user, there's nothing more important running right now.

One special case: game streamers would likely rather the game stutters than the stream encoding stutters. (Especially as long as the capture of their own face+voice remains smooth.)

My motherboard crashes when I peg all the cores. Presumably it can't maintain the core voltage under load. Vendors need to guard against these scenarios by being extra cautious because it's a hard problem to diagnose that they'll get blamed for.
Your computer is unstable and broken. I would try swapping PSU or troubleshooting that issue. This is not normal and no, this is not the job of anyone else to solve or consider.
Yeah I had this problem and it ended up being the PSU. I tried a lot of different bios and driver versions swapped cpu, memory, then eventually upgraded motherboard with new cpu and memory (all these are the suggestions from people who had the same bios code on forums) and it kept coming back… then finally replaced of the PSU which actually fixed it.

Don’t be like me! Replace the PSU! Do the math on how much your system could possibly need and then double it!

Checking the voltage and specifically which voltage the automatic overclock mode of the board applies though could also be worth the time, before replacing the psu otherwise.

And doubling the wattage isn't necessary, just be comfortably higher on the 12v line and get a good one.

Guarding against that seems like a bad idea, but even then just use a couple less threads than physical cores. Don't get too clever.

You in particular should probably disable a couple cores until your hardware stops being defective. Have you looked into updates and voltage droop compensation settings?

That sounds like a faulty motherboard. Return it.
Users don't care that it's a problem with the motherboard. They have a working computer, they buy a game and it doesn't work, they blame and return the game.

Users can be unreasonable, but in this case I agree - if I reported an issue to a vendor and their response was "return your motherboard" I wouldn't work with that vendor again.

> in this case I agree - if I reported an issue to a vendor and their response was "return your motherboard" I wouldn't work with that vendor again.

Why would you say this? If the problem is your motherboard is in fact broken (or you have used a high-end CPU on a motherboard not rated to power it), and the vendor correctly diagnoses it despite it not being their problem, you think this is bad? You want them to change their software, making it worse for everyone who doesn't have broken hardware, just to make your broken hardware work?

Sometimes if such an issue affects a common hardware configuration it can make sense from a capitalistic sense to "make it work" for more users but if that's the case that implies you would know what the hardware configuration involves and test accordingly so the workaround would not have negative effects on users who don't need it, and either way that's not the situation we're talking about here where the user has already acknowledged that their hardware is wonky.

>everyone who doesn't have broken hardware

To be fair, such people don't seem to exist in real life. Between i586 and zen3, I have never owned a machine that boots the current kernel tip without there being one or more notes about some workaround in force, to deal with some detected broken-ness of hardware or firmware embedded therein.

I covered that though. Known design defects in specific pieces of hardware can be documented, detected, and handled. The user that set off this specific subthread and the user I replied to both took a position that software developers should throttle EVERYONE just because they or someone might have defective or incompatible hardware that can't handle being maxed out.

It certainly isn't a bad idea for developers of software that's likely to max out someone's system to provide options for throttling it, both for those who know they have bad hardware to work around those issues and for those who just aren't in a hurry and would rather trade a slower render/compile/whatever for a system that remains more responsive as an interactive user. It'd be insane and idiotic however to throttle by default.

We can't form the world around literal bad hardware. That's completely insane. The world would fall apart.

> I wouldn't work with that vendor again.

Possibly rightly so, if it's bad motherboard hardware. Could also be a bad power supply, bad ram, bad CPU, user misconfiguration, etc. It's a complex system, where everything has to NOT be bad for it to be deterministic.

There's a necessary level of competence required with self built systems, or any other task in human life that you're not paying someone else to do for you. That's fine. Go buy a MacBook or a pre built system if that threshold of competence can't be met. That's why they exist, for people that can't or don't want to bother.

It doesn't matter what's "fair". It matters what people do.

https://devblogs.microsoft.com/oldnewthing/20080206-00/?p=23...

Haha, that really depends. If you look at it from the viewpoint of a failsafe, like brakes in lifts that activate without central control, backup parachutes, etc. Then it makes some sense for resource intensive software to guard against weird edge cases like this. It's just that they measured the wrong thing.
We don't use elevator brakes or backup parachutes as an excuse to let the primary fail under normal load. Those are for emergencies.

I think the elevator analogy to this bug is that the elevator goes too fast and triggers the brakes if you input target floors more than 8 apart. You don't fix that by having the user or user software be more careful about button placement, you fix the hardware/firmware.

Those have nothing to do with the required assumption of determinism in the hardware that software must enjoy.

You're examples are flawed. Those are to safely halt operation on failure. What you're suggesting with the software is to limp along pretending everything is ok.

The proper test, more in line with your others, would be to catch failure and halt operation. Since, in your case c the human isn't competent enough for that, it would maybe be a self test initiated by the operating system, then a refusal to continue when the hardware problem is identified, emulating all the periodic inspections that are part of all the proper operation of all the physical systems your mentioned.

Sounds like they don't have a working computer. Computer users occasionally do things that end up pegging all cores, so I'm pretty sure that someone in that case would know their computer has some kind of issue.
They'd probably be quite happy not to work with somebody that makes their broken hardware everybody else's problem, though.

Expecting software to deal with a user that can't be bothered to fix a pretty fundamental flaw with their machine is unreasonable.

Why aren't you storing all your variables with reed solomon encoding in case you have a user with bad ram?
Disable turbo boost in the bios
That seems like a you problem - undervolt your cpu.
It’s just reality that motherboards can malfunction or degrade in peculiar ways that a manufacturer’s quick boot up checks cant always catch. No matter the reliability claims.

If they want to cater to customers who foolishly reject reality and take every claim from manufacturer’s at face value… then foolishly misaimed blaming seems expected?

But if they just roll over and swallow the foolish blaming without even challenging customers to double check, then they are also facilitating more nonsense.

"I have a faulty hardware so everyone in the world should take care not to trip my hardware. Also I don't care about anyone else."
Especially on Linux, the default throttling just doesn't work very well.
> 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.

> 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.

I'm actually ok with a blocking progress bar. The whole async approach falls apart once it starts degrading performance.