119 points · by wheresvic4 · 6y ago · 45 comments
The broad consensus was that it was the .NET runtime's spin implementation at fault, both because of the suboptimal use of the PAUSE instruction itself and because of the overall design that had excessive spinning in a few spots. Effectively, IIRC, they were putting the "pause" instruction on the hot path where they needed to exit the loop synchronously, and that's just wrong. Basically no one sane would look at a change log that said "exit latency from pause will now be similar to a pipeline stall" and done anything but shrug.
It's since been addressed in .NET, as far as I know. And I'm not aware of any other affected code.
(The implementation might be different on .Net Framework)
I've learned to walk in the opposite direction of .Net now.
At least verify the testable facts you're relying before assuming bad faith!
The only redeeming quality of your inane comment is how neatly it proves my point.
I'm losing more neurons than I am patience these days.
PAUSE used to have a fixed quite short latency.
It now has a variable latency. I would hazard a guess that the latency strongly depends what the other cores on the machine are doing, and the other thread on the same core.
Specifically, I would guess intel saw pause being used in spinlocks, and seeing a lot of power and time on functional units being wasted on locks that spin a lot. They decided to deliberately slow down a spinlock's spinning to use less power, and less of other functional units, and in doing so will free up functional units for the computations on the other hyper-thread and power/thermal headroom for other cores in the same CPU.
By doing so, the thought is that overall, the computation should complete sooner.
If both hyperthreads on a core execute pause, I'd expect the latency to go to very low again.
Yet that reasoning didn't work in this case... The only explanation I can think of is that while some threads are executing pause instructions, other threads are executing other kinds of spinlock's without pause instructions. Those other spinlock's end up spinning faster now they have more functional units, but still making no forward progress.
The overall result is the computation isn't sped up, and you still pay a latency penalty to notice the computation is done, hence slower overall.
Futex-based spinlocks do what, 1000 spin cycles before actually futex(2)ing?
If the holder of the lock got preempted you could be spinning for a very long time.
You might want to read https://webkit.org/blog/6161/locking-in-webkit/ about how Chrome implements high performance locks.
I fixed a friend’s site recently this month that still had a Google Plus link on it.
But I feel your first part is a legit question. As a Linux user I can't answer for myself (only reason to use Windows are games and SigmaStudio).
However, a lot of our customers in the embedded world seem to prefer Windows. Not sure that's because their IDEs are Windows only or just because they're used to it or because management forces them or because other reasons...
Until very recently (2016+), a lot of us were assuming Microsoft was still committed to maintaining CE as an OS for things like handheld RFID scanners, train conductor ticket machines, etc - because all the companies that had CE-based applications didn’t want to have to rewrite them for Android or iOS. And the reason they were using CE in the first place was because Linux was not a viable option for SH3/ARM/MIPS-based low-power GUI/screen-driven devices - back in 2001-2010. Microsoft made CE integration and deployment easy with their Platform Builder tools - building your own Linux district for an embedded application is a job in itself.
Now that NT runs well on ARM, and that SH3 and MIPS are dead in the handheld space, Microsoft is pitching NT as a replacement for CE in certain use-cases - but no-one is pretending Windows 10 “IoT” or LTSB is suitable for batter-powered devices. And the mismanagement of the Windows Phone 10 platform especially leaves MS in an awkward situation where they can’t serve the best customers you can get: large enterprises looking for a long-term supported platform - who have no problem with MS’ relative lock-in; who now have to switch to non-phone Android handhelds and switch from .NET on CE to JVM on Linux - and they won’t want to do this again for a long time (decades?) - Microsoft did untold long-term damage to their viability as an enterprise solutions provider by abandoning CE. Smh.
(Okay, Android is one option - another is QNX (other platforms like VxWorks aren’t really used for LoB applications). I wager most devs would prefer Android over QNX out of familiarity though - especially as I imagine most devs under 30 (35?) today have dabbled with writing their own smartphone app.
I actually meant most of our customers are running Windows on their workstations, on which they develop embedded systems. Due to selection bias (our target audience are "safety critical embedded" devs), they can not use Windows CE (or for that matter Linux) as a product platform. I'd literally expect people to die if they did ;-)
And yeah, it's more like 35. Android/iOS isn't that new anymore ;)
Desktops, embedded devices and servers.