Skip to content

fix: Prepare ThreadPool for .Net11+ - #3351

Merged
xen2 merged 1 commit into
stride3d:masterfrom
Eideren:tp11
Sep 13, 2026
Merged

xen2 merged 1 commit into
stride3d:masterfrom
Eideren:tp11

Conversation

@Eideren

@Eideren Eideren commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

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

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My change requires a change to the documentation.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have built and run the editor to try this change out.

@Eideren Eideren added the area-Core Issue of the engine unrelated to other defined areas label Aug 11, 2026
{
// 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")!;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Ethereal77 Ethereal77 Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Kryptos-FR Kryptos-FR Aug 12, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did the tests no fail in such case? Or is it not part of tests triggered by PR changes?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AOT does support reflection, it doesn't support generating new IL on the fly, so no generics like Type.MakeGenericType() basically

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Core Issue of the engine unrelated to other defined areas

Projects

None yet

Development

Successfully merging this pull request may close these issues.

regression: LowLevelLifoSemaphore change in signature in dotnet11

7 participants