Repository navigation
fix: Prepare ThreadPool for .Net11+ - #3351
Conversation
| { | ||
| // The semaphore Dotnet uses for its own threadpool is more efficient than what's publicly available, | ||
| // but sadly it is internal - we'll hijack it through reflection | ||
| Type lifoType = Type.GetType("System.Threading.LowLevelLifoSemaphore")!; |
There was a problem hiding this comment.
Can we copy/paste the code instead?
Reflection doesn't necessarily work on all platforms and it certainly won't if we ever support Native AOT.
There was a problem hiding this comment.
If we end up copying it, I'd wait for the final release of .NET 11, or else we are obligued to watch if they ever change it, correct bugs, redesign it, etc. (which may very well happen since it's still in preview)
Edit: ...or at least the RC
There was a problem hiding this comment.
Can we copy/paste the code instead? Reflection doesn't necessarily work on all platforms and it certainly won't if we ever support Native AOT.
FYI, we do support Native AOT already since PR #3204 (not only for iOS but also desktop).
It's even tested regularly.
There was a problem hiding this comment.
How did the tests no fail in such case? Or is it not part of tests triggered by PR changes?
There was a problem hiding this comment.
AOT does support reflection, it doesn't support generating new IL on the fly, so no generics like Type.MakeGenericType() basically
There was a problem hiding this comment.
you could make your game use (multitarget?) .NET 11 and it would use the new code.
Unless users are compiling their own engine packages, this wouldn't work because Stride.Core solo-targets .NET 10. Bumping their game to .NET 11 would still reference .NET 10 engine code (and therefore still hit the error that this pull request is trying to fix).
Are we actually planning to upgrade to .NET 11? We used to only to LTS.
I think we should. .NET 10 and 11 both reach end of support at the same time (November 14, 2028).
"Customers can choose Long Term Support (LTS) releases or Standard Term Support (STS) releases. The quality of all releases is the same. The only difference is the length of support. LTS releases get free support and patches for three years. STS releases get free support and patches for two years."
https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core
There was a problem hiding this comment.
No, but you could make your game use (multitarget?) .NET 11 and it would use the new code.
That does mean that the engine core would need to support multi-targeting.
I wouldn't jump to .NET 11 in general, though. Those who want .NET 11 features can target .NET 11, and we can use .NET 11 code branches as a test bed for engine development that adopts new features that would be guaranteed LTS support in the next release. Microsoft guarantees LTS stability for even-numbered releases; Stride should match this cadence, but could trail certain features in a .NET 11-specific build. There's like a lot of build machinery behind the scenes that needs to be fixed to support this, but I do see a path forward.
There was a problem hiding this comment.
@xen2 feel free to merge. @ds5678's suggestion would have been great in a context where we don't have to maintain a fallback, better to leave it as is. The rest of the discussion is out of scope, @sasvdw @ds5678 @VaclavElias feel free to continue in a dedicated discussion.
There was a problem hiding this comment.
The rest of the discussion is out of scope, feel free to continue in a dedicated discussion.
I've updated #2696 with my recent thoughts.
@ds5678's suggestion would have been great in a context where we don't have to maintain a fallback
If #2696 is accepted, there wouldn't need to be a fallback. Stride would adopt .NET 11 in November.
There was a problem hiding this comment.
@ds5678 The fallback will stay regardless, it is setup to avoid breaking the engine if we don't keep up with the internals of dotnet, or if dotnet does not support that particular synchronization mechanism on other platforms.
PR Details
See #3326
Very minor changes to the dispatcher as well to make the logic a bit more readable and reduce the cruft.
Related Issue
fixes #3326
Types of changes
Checklist