131 points · by jrepinc · 6y ago · 136 comments
You can implement spinlocks in userspace under specific circumstances. You will need to mark your threads as realtime threads[0] and have a fallback to futex if the fast path (spinning) doesn't work out. And even then you need to benchmark on multiple machines and with realistic workloads (not microbenchmarks) to see whether it's actually worth it for your application. It's complex, linus goes into more detail here[1]
[0] http://man7.org/linux/man-pages/man3/pthread_spin_init.3.htm... [1] https://www.realworldtech.com/forum/?threadid=189711&curpost...
Care to elaborate upon this statement?
> "Linux pessimizes for high-performance games atop its kernel."
Games can run at quite a high performance (which feels like a really odd statement) atop the general purpose Linux kernel. Even with the windows-specific APIs being emulated with Wine/Proton.
There are many modern games, including Doom 2016 as I mentioned below) which run beautifully on Linux.
I wouldn't redo the work of people who have literally written books on the topic (https://books.google.com/books?id=1g1mDwAAQBAJ&pg=PA319&lpg=...). Copyright 2019, so if it's not conventional wisdom that spinlocks are the right tool any longer, the "best practices" in game education are still teaching them, and OS's may need to account for the code actually written, not the code they wish were written.
What you can do is make mutexes perfectly adaptive so that they switch to a blocking wait as soon as the lock owner itself gets preempted. I have a proposal to do that here: https://lore.kernel.org/lkml/CAKOZuesa338sc_=w6-wvro25idrSN_...
You should always use waiting primitives when possible instead of just spinning. If you tell the kernel what you're doing, the kernel can help you. If you hide the wait DAG from the kernel, it can't.
If people are learning bad practice from the texts, and the bad practice hits Linux's scheduler asymmetrically hard (relative to other game platforms), one can expect outsized impact on the performance of games atop Linux architectures.
Yes, because that's not the main focus of a general-purpose kernel. Which doesn't mean there aren't ways around it if your objective is running Linux for a specific application.
The real time patches are in the mainline kernel since some time ago, but there are other options for softer RT at the kernel as well.
I got to use that quote at some point. Pure gold.
If you are not Linus, you might come off as a major asshat. Careful.
Wine/proton and the accompanying libraries are pretty f'ing amazing.
I tried the same in 2018 just for fun and I wasn't able to run Skyrim, there was always some minor issues that made the game unplayable, like mouse not working, crashing on certain screens etc. I essentially kept trying older versions of Wine, and eventually found some version that made Skyrim playable (still not as flawless as it felt in 2015, but playable). Idk if it was my mistake, or some archlinux lib weirdness or something else, but I had to try dozens of wine versions to find something that worked. This is fine for me, since I wasn't intending to play Skyrim, I was just trying to run it (for the "WOW" effect), but I imagine people who actually need Windows software might have been frustrated by this.
> I'm not a gamer so I can't tell the difference between 30fps 60 fps etc
It's like driving a car with a rough idle vs. a smooth idle. You can get used to driving a car with a rough idle, and not particularly care. But once you've driven both, you can identify which is which pretty easily, and the rough idle starts to bug you when you know it can be smoother.
Everyone who has played more than one video game knows that some just feel better than others. In one, your character is fluid and nimble, and in another, slow and clunky.
This is the result of many things, but a large portion comes from input lag and frame rate. More advanced users aren't necessarily more perceptive, they're just better at pinpointing what they're reacting to. (And in some cases, conscious of how an experience could be improved.)
This is similar to the study of any type of art. Whereas a casual observer might look at a painting and say "meh, I don't like it", someone who has studied art pedagogically can describe precisely what isn't working for them.
Heck, there are people keeping older PCs around just for that, so you can e.g. run your Skyrim LE with Win7 and an older DirectX release etc.
"Retrogaming" is quickly approaching a very small time delta.
I guess that's the price you have to pay for performance and availability. Games shouldn't be that brittle, but any fast-paced industry is likely to run into those problems, and with high-speed internet patches and a GPU duopoly, fixing it is too easy.
I can only complain about some minor font rendering issues and the lack of child window rendering [0] which is frequently used in programs like these.
Once child window rendering is fixed, I will actually be considering ditching windows entirely and go wine-only.
[0] https://www.winehq.org/pipermail/wine-devel/2019-July/148639...
In the pre Windows Vista Era, the operating system handed control over to the App to draw itself on screen. In Vista they moved to a model, like OSX, where each App drew to a buffer and the OS composited those buffers. That's part of the reason why Vista was hot steaming garbage because they were still working that transition out.
It would be interesting to see the difference in performance between running the native version and the emulated version.
This is the same as Xbox and PSnow, etc. You have to pay for the service via a game pass or pro membership on top of buying the game and possibly the system before you could stream it.
Even in the case of shadow, you'd have to pay for the service to stream games you'd buy and access off your own/their system.
They stream spotify because they don't want to buy songs and after that current song is no longer popular they move on to another one and forget the first song ever existed. They play video games and when they are done they sell them and buy a new one, never wanting to revisit the old one. They spend $50 on the new game and sell it for $15ish. For that mindset of people this is a great product, along with the digital only xbox one.
I am not implying all kids or youth are like this, mine are and a bunch of their friends are. I prefer gog or a physical copy, but then again i don't buy that many games.
> But the issue isn’t bandwidth, really, is it?
No, bandwidth isn't the issue, I believe the op was referring to Latency.
I have 75mbps DSL and the Latency is garbage with 29ms being best case. I get frequent periods of 90+ms latency.
Check out some of the Games Done Quick runs from last summer on Youtube, for example. A lot of the FPS games especially look dreadful. I'm sure Stadia can do better, but there's only so much bandwidth you can throw at this problem before it becomes untenable: https://twitter.com/dada78641/status/1207751665752911872
To me, the main issue with Stadia is not the product itself but the massive amount of extra CO2 that's generated trying to solve all these issues that were already solved decades ago by having your own cpu in your own personal computer in your own house.
There's also a chicken-egg effect that Google's still interested in for secondary reasons. Reverse the question: assume Stadia takes off and becomes the "killer app" of gaming (big assumption, but still). Will local municipalities continue to tolerate crap networks if it means they're left out in the cold on this thing? Google's still interested in improved network infrastructure and has the clout to play incentive games to make that scenario more likely.
https://www.engadget.com/2019/10/10/google-stadia-negative-l...
Local conditions (US for example) are not necessary a showstopper in Japan, South Korea or parts of Europe. Low latency extremely high bandwidth is the new playground.
I mean, you should get 50 Mbit/s from very affordable mobile broadband. If you have ASDL landline, you can get hybrid solution (combined mobile + landline that works as one) and you should get 100 Mbit/s
I've played Destiny, Thumper, Ghost Recon, Tomb-Raider etc on it and only Thumper was tricky when I tried on a pretty crap connection.
Seems a bit dismissive when MS, Sony, Nvidia, and Google etc having built streaming services that consumers have enjoyed.
I'm sure plenty of people in this thread have fiber but Hacker News is not really the target audience for Stadia.
35 megabits per second: 4K, 60 fps, HDR, 5.1 surround sound.
Consumer internet is fine for this in a lot of the developed world.
I don't like Stadia for other reasons but saying that consumer access is not capable because you live in a country that sucks on that part is not really a good argument.
Do you think modern cars are a bad idea as well because there are parts in Africa that doesn't have good roads?
Unless you have fiber, it's not worth it. Some DSL internet still suck today.
You don't need fiber. Feels as good as local play on my 220 Mbps down/15 Mbps up internet.
They control the whole box, it should be more like a console than a regular PC.
Skarupke inaccurately defined this as 'mutex vs. spinlock' and an ongoing debate surrounding this as they are comparable, when in no way are they comparable as in userland you simply cannot use spinlocks.
The Windows scheduler apparently doesn't do this, and handles spinlocks better; whatever that means. But the way it works is that spinlocks should work poorly if you run them poorly. Full manual-control of when running a spinlock in userland, you will be scheduled by other things, and you should know that.
That's what Linux is really about. The ability to do something and not have the system "better-ize" it like Windows does by doing some black magic and running an unknown process alongside your spinlock to make it run better.
A spinlock run in userland SHOULD be scheduled by other things, as Linus says. As Linus implemented in the kernel.
Games often integrates the message loop into their game loop. In their loop, they poll to see if any new message has arrived, and if so handles it. In any case it does it's game thing.
If there's not much to do, because the game is paused when it's minimized for example, this spins much like a spinlock spins. If, in addition, it has some other threads it's synchronizing using spinlocks then yes, it can cause it to burn several cores worth doing nothing.
Better games handles the loop differently while the game is minimized, for example doing the default wait-for-message variant.