Live data from Hacker News

Spectre mitigations murder userspace performance

robert.ocallahan.org

221–230 of 294 posts

Re: Spectre mitigations murder userspace performance

#222
post #14

Earlier quoted context omitted.

I love that this is a toggle like this, having control of my system is why I love Linux. But I must caution desktop users against doing this for performance, it's _much_ better to have some kind of build server somewhere else with this kernel flag than to run it on your desktop. Why? because your desktop executes untrusted and rather arbitrary code pretty often, not just in the form of Javascript but that's the large…

Kind of feels like apps should opt in to (or out of) mitigations individually. Obviously a web browser needs it, but does Clang? VSCode? Zoom? Probably not.

Just require everyone evil to set the evil bit, and everything would be much easier.

Re: Spectre mitigations murder userspace performance

#223
post #220

Earlier quoted context omitted.

I don't know but I can't imagine a highly predictable branch being slower than a TLB flush.

Well consider the fact that checking a table of “ok” programs is a branch and a lookup in of itself.

Yeah that should be really fast, still. Programs could also opt to just tell the OS "hey don't check this system call from me", on each system call, avoiding any lookup.

The impact of TLB flushing, not just the cost of the flush, is really significant - it's going to take a lot of work to be as expensive within the syscall path.

Re: Spectre mitigations murder userspace performance

#225

Earlier quoted context omitted.

If you are pinned to a core, as non burstable instances should be, you are still pretty much vulnerable. Having noisy neighbours will pollute caches and make extracting data harder, but, eventually, everything will leak out. I’ve been thinking what would happen if cores would be pinned to separate security domains - all kernel processes run on one set of cores and user processes on others. I imagine microkernel OSs c…

Isn't the entire memory hierarchy (caches) part of the problem?

Yes. You’d need to split caches by security context too.

Re: Spectre mitigations murder userspace performance

#226
post #220

Earlier quoted context omitted.

I don't know but I can't imagine a highly predictable branch being slower than a TLB flush.

Well consider the fact that checking a table of “ok” programs is a branch and a lookup in of itself.

It would be a branch, but surely it would be a flag on the process struct set when the process started, rather than a lookup each time.

Re: Spectre mitigations murder userspace performance

#227

Earlier quoted context omitted.

Yeah but the next update will probably turn it back on silently...

Unlikely; Windows updates (mostly) only turn things you disabled back on if they're harmful to you.

I have a tablet that was unusable before I installed WuMgr and blocked auto-updates because every 24 hours Windows Update would force-install a broken touchscreen driver. Windows Update is the single most embarrassing, half-assed software project of the 21st century.

Re: Spectre mitigations murder userspace performance

#228
post #160
post #98

Earlier quoted context omitted.

I disagree. There are way too many sites that require javascript that you'll eventually get into the habit of blindly enabling scripts when a site breaks, negating any security benefits.

I used to do this. It broke too often when doing credit card purchases though... it would take multiple attempts to complete a purchase and figure out which domains needed to be enabled. Sometimes the status would be left ambiguous. Once I double-spent, but fortunately it was a cancellable reservation. I suppose you can do better if you just spend at a few key sites.

Simply "enable all" for pesky cases like that.

Re: Spectre mitigations murder userspace performance

#229

I’ve made similar comments in the past but I think we’re just trying to predict too much about what programs are trying to do in hardware. I’d rather have simple hardware that is light on energy requirements and easier to understand. I don’t think software as an industry really has a “this chip isn’t fast enough problem”. Most of the real slowdowns anyone has in day to day performance has more to do with inefficient…

I'll make a deal with you: I'll agree to turn down speculative execution in hardware if

1) you can solve the VLIW scheduling problem, and

2) you transition the entire computing ecosystem to a JIT model.

These are the things we would need to claw back the performance we would lose through disabling speculation. You can look at speculation (I'm handwaving a lot here, bear with me) as the processor hardware dynamically recompiling your program code depending on observed behavior of the program. That's well and good and it gets us a huge performance boost.

You can, in principle, do the same thing in pure software. But every single attempt to do has ended in total algorithmic failure.

The last serious attempt I'm aware of to "drive" a uOP scheduler explicitly in software was Itanium, and that failed, in part, because compilers couldn't take advantage of the processor's instruction level parallelism. There's nothing in math or mathematics or computer science that forbids a magical compiler of the sort the Itanium people wanted to create. But nobody's made one. Your first task in your project of eliminating speculative execution is to solve this algorithmic problem.

But solving problem #1, while necessary, is insufficient. No static ahead-of-time compiler can adjust the compiled code depending on the actual execution history of the program. To really get back to speculative execution par, you have to give your already-magical compiler the ability to recompile code at runtime. That means turning everything into a JIT. Your /bin/ls would actually be LLVM bytecode, not machine code, and some runtime system would be responsible for dynamically generating the machine code and adjusting it depending on execution history. After all, that's what current superscalar CPUs do internally, transparently, all the time. This is problem #2.

Honestly, I think the world we'd create by solving both these problems would be a better world. I really don't like how we can't program the processor's speculation engine and uOP scheduler. I'd love to be able to do that.

But I don't think we can get there from where we are, so we're going to be stuck with speculation and hardware mitigation forever. Please, prove me wrong.

Post reply on HN