132 points · by pabs3 · 3y ago · 62 comments
(see: https://www.stride3d.net/blog/xenko-has-been-renamed-to-stri...)
Then it has been renamed as xenko for some reason.
Once it has been open sourced in 2018, we wanted to make it part of the .NET foundation but we didn't have the trademark rights for it. Or more like, Silicon Studios was taking a lot of time answering to give us the trademark. We voted to change the name and allowing us to be part of the foundation.
Does anyone know if it supports Mac?
A Stride project is just a normal visual studio solution, so you can build the solution on other platforms too, if you don't use the asset compiler, which is also a windows only application.
I have a prototype where I intentionally invoke GC after every frame. My reasoning is that some amount of GC will eventually need to occur, so why not do it as frequently as possible and at the exact moment where we can compensate with other measures, such as the frame scheduler & time step abstractions.
Even with heavy allocation (i.e. deserializing the scene graph from a wire protocol before every frame), this approach seems to keep GC pauses bounded to ~1-5 milliseconds in my implementations.
If I did not explicitly call GC when I thought best, the runtime would decide to run a 100-1000 ms collection at its convenience and the entire experience would become worthless to human perception.
Missing a VSync in mobile means that the refresh rate will switch to 30hz for a brief moment, there is no in-between (ie; 54 FPS or something like that) which is pretty noticeable.
The only "great strategy" is to have zero alloc (or close) while gameplay is running and if you want to go the extra miles, disable GC completely and call it only in some appropriate moment (level loading, bringing up the menu, etc.).
But it's not very complicated to write a simple IL analyzer, using Mono.Cecil to go over the raw IL, instead of using Roslyn. The idea is to look for the newobj or box IL opcodes, but also to recurse to called methods (when meeting the callX opcodes), by finding using Cecil where the call leads us, and loading that method.
This could be used after compilation instead of during compilation, but it can be used without actually running the code, so it's a sort of static analysis.
I threw together a simple demo, that has some bugs but is generic enough and should work. It's not very efficient though.
See here :
https://dotnetfiddle.net/EyuYSh
(It can also be run from there since dotnetfiddle supports nugets).
And also in godbolt:
https://godbolt.org/z/P3rK1voKP
(it doesn't run there since Godbolt apparently doesn't support nugets)
It's self contained and will run as a console application by just copying and pasting the code into an IDE. You need to add Mono.Cecil as a nuget package though.
As a Stride user you have to follow similar guide lines in your scripts to avoid pressure on the garbage collector. But that's not so difficult as soon as you get the hang of it.
But it's a very modular engine, you can change parts of it to better accommodate your needs, I'm currently finishing implementing my "no-allocation" ECS library and will 100% try to integrate it into my fork.
.NET platform is server focused, it does a lot at runtime, including recompiling bunch of functions
It was a huge problem before Unity had the IL2CPP target, you had to deal with the slow cold start and you also had to manually call your hot functions to avoid getting them recompiled during gameplay, wich would cause ton of micro-stutters
Hence people prefer languages like LUA for their scripting needs, even for Unity [1], great perf for interpreted and you can ship it on consoles/mobile platform that forbid JIT
Now that .net has a dedicated AOT compiler, things could improve, but i doubt this engine supports NativeAOT
Things were different for Unity games using the Boehm collector though, since it's a conservative non-generational collector that as a result is very slow to collect and collects more frequently. That's why you saw a lot of frequent pauses in Unity games (my understanding is they no longer use Boehm).
The game I'm currently working on GCs maybe 1-2 times per minute and the pauses are short enough that it doesn't drop frames, despite the fact that it frequently allocates strings and uses 'async Task' extensively. If you tune the collector settings you can control this even more, and you also have the option to manually force GCs to happen while the game is waiting for vsync, which hides them further.
Visual Studio has a built in allocation profiler that can help if you're looking to optimize your games for fewer GCs, and to make tracing faster what you want to do is avoid having any reference types in your struct arrays (use handles instead), which will let the GC skip tracing your big arrays of structs entirely. So for example the big tables of draw calls I use refer to textures by numeric handle instead of reference, which means I can have a 50mb table without making GCs slower.
Using handles instead of references also means that copying the struct doesn't require write barriers, which will boost your overall perf a bit.
First of all, there is the runtime they are actually using.
Then the language version.
Finally, how well the devs know how to do low level optimisations.
Instead, heavy optimisation in C# is usually "high level but knowing the runtime in great detail" optimisation. Stuff like knowing the hairy details of the GC implementation (eg by reading Pro .NET Memory Management and/or the single 30,000 line C++ file that contains the GC implementation [1]) and using this knowledge to write ordinary C# code in such a way that the GC can handle its usage patterns very efficiently, or doing things like object pooling that try to cut the GC out of the picture altogether.
Essentially, it's knowing what you want the machine to do and figuring out a way to trick the runtime into doing that instead of what it wants to do. I find it massively frustrating and after doing it for a few years I moved back to languages that try to do what you tell them to do instead of the other way round. Some people seem to thrive on it, though, and manage to get impressive results - see, eg. Marc Gravell's blog.
[1] https://github.com/dotnet/runtime/blob/main/src/coreclr/gc/g...
Apparently it going great.
.NET is nowadays a very different beast that the .NET Framework. Maui is not the relevant factor. The modernization of the runtime, portability and the language itself changed it lot.
Give it another try. You will be surprised. But do not start with Maui :)
They are ones of the main contributors to low level improvements in .NET and C# since version 7, alongside the team's own learnings in Midori and .NET Native.
Imho the main improvements lately for gamedevs are greater portability, Span<T>/Memory<T>'s (access and manage memory more freely), stack-allocs (enabled by the former) and vector math intrinsics (Add to it that C# code was never as reliant on GC perfection as Java by being more pragmatic and with support for proper generics saving a ton of memory allocs).
Personally, I feel like .NET Core and embracing cross-platform was exactly what the ecosystem needed. Albeit not quite 1:1 with the older versions of the framework (the Mono project tried that approach, with mixed results), things like Kestrel instead of IIS didn't feel like a high cost to pay. Plus, I think that the C# language itself is reasonably nice.
It's a bit curious how C# seems to be more popular in gamedev than Java, both of the languages and runtimes not being that different from one another. For whatever reason projects like jMonkeyEngine or LWJGL don't get the same popularity as Unity or even Godot.
And both Unity and Godot only use C# on the surface, under the hood it's mostly C++ (although apparently in Unity this has started and parts are being rewritten in their low level C# dialect using the Burst compiler).
In this case .net core doesn't have WCF support. The framework is more rich for something like a game engine.
I would be curious your aversion to c# in general though, I hear a lot of people saying it's bad but not explaining what they're trying to use it for etc. It's just a tool.
2. Visual Studio product slow & clunky to drive, makes me want to cry, esp when VSCode so good. SO GOOD.
3. WPF (never again, ever, not once, ever never fucking ever)
4. NuGet sucks shit through a crazy straw. Hosting your own private packages is basically sadism with a whip hiding behind a door marked “peace&quiet”.
5. Online documentation & community support is consistently SEO’d to be a bunch of articles generated out of India with immature/ridiculous CSS choices. This was circa 2017.
Aside from that, it’s a great language.
1. I don't see this as an "issue" more a taste. You're not forced into a way, but the compiler has a preference. Usually it's the path of least resistance.
2. You can use whatever IDE you like , actually I'm proud to say I use vim exclusively and while i agree vs is heavy and strange. You're not tied to it.
3. Gaming engine will need something. If you don't like this one.. you should see some others, they're not far off. I agree, it could be improved but nothing to do with the language as a whole.
4. Why? I host my own very easily. Company I work for hosts quite a significant amount all fed from build pipelines. So you don't like it.. feel free to share experiences.. love to hear.
5. I don't know what to say about that in relation to the language. Some of the best articles I've learned from have been indian. I don't know why it matters where there from to be fair. Infact my time in a company suit purchased from Microsoft was exclusively supported extremely well by the previous engineers who were primarily indian. So I don't buy the stereotype.
Aside from that it's a great language so you should have nothing else? Nothing about it's garbage collection, state management, compile state issues. Just general nonsense?