Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with Backport.System.Threading.Lock package #4450

Open
rockfordlhotka opened this issue Jan 21, 2025 · 4 comments
Open

Fix issues with Backport.System.Threading.Lock package #4450

rockfordlhotka opened this issue Jan 21, 2025 · 4 comments

Comments

@rockfordlhotka
Copy link
Member

MarkCiliaVincenti/Backport.System.Threading.Lock#6

It looks like we either

  1. Go through all the projects and fix all the references/usage of the library
    • Remove the offending lines from Build.Build.props
    • For projects that actually use the library, keep it and add necessary lines to csproj
    • For projects that don't use the library, but just reference it today due to the viral mistake, remove the reference entirely
  2. Go through all the projects and remove all usage of the library

Right now I'm leaning toward option 2, as I'm not convinced the value of the library is worth the ongoing effort.

@StefanOssendorf
Copy link
Contributor

If we go route 2. How will we handle the locks?
The new Lock object does seem to have performance improvements we should not miss out - I think.

@rockfordlhotka
Copy link
Member Author

If we go route 2. How will we handle the locks? The new Lock object does seem to have performance improvements we should not miss out - I think.

That is a good point, though I'd like to see some hard data about how much different the performance improvements actually make.

I must confess that I put in option 2 due to frustration, as the Backport package dependency seems to cause random build issues over time and that is frustrating when it happens while someone is trying to work on an actual CSLA issue.

@StefanOssendorf
Copy link
Contributor

I understand that :)
Here's a post from the .Net blog: https://devblogs.microsoft.com/dotnet/performance-improvements-in-net-9/#threading
It's "only" a difference of ~0.5ns but I think with this kind of stuff it stacks up when used in hot path scenarios.
I don't have an overview when or where we use lock extensivly. So if it's not used in hot path scenarios we could stick to the old style for now.

@Bowman74
Copy link
Contributor

Bowman74 commented Feb 1, 2025

As an interesting aside, from what I can tell reading the background on System.Threading.Lock, the motivation was to give developers more control over the locking process and not necessarily performance. Looks like MS got an extra bonus with the new design. As with all new language features, their use can be problematic in libraries like CSLA which still target and compile against earlier versions.

I guess it is possible to avoid a dependency is for CSLA to create its own Locking abstraction class that contains all the required #if NET9_0_OR_GREATER type code to handle differences in the locking syntax when compiled in different versions of dot net. I don't know if it is a good idea or a bad idea, but it is an idea that I believe has been used before. The CSLA usage of locking looks pretty simple so the primary benefit of the new locking type would seem to be to grab that performance boost for people on dot net 9+.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

3 participants