You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
area/performance 📈Categorizes an issue or PR as relevant to performancedifficulty/tbdCategorizes an issue for which the difficulty level needs to be defined.kind/enhancementNew feature or requesttriage/untriagedIndicates an issue requires triaging or verification
HasFlag was optimized in .NET Core 2.1 to not box, but apparently, it's not guaranteed that this optimization will always work. See dotnet/runtime#55455 (comment)
We should replace HasFlag calls (especially ones in hot code paths like pointers) with bitwise AND.
Note: It looks like dotnet/runtime#89348 fixes this for .NET 8. So the HasFlag changes in #13309 could be reverted when we move to net8.0/net9.0 a year later.
Or we could just live with the bitwise AND that is known to be performant and not rely on JIT optimizing HasFlag even when we are net8.0+.
Edit: Even for net8.0 it seems that the optimization isn't guaranteed. Let's stick with HasFlag for any hot code paths.
area/performance 📈Categorizes an issue or PR as relevant to performancedifficulty/tbdCategorizes an issue for which the difficulty level needs to be defined.kind/enhancementNew feature or requesttriage/untriagedIndicates an issue requires triaging or verification
Activity
Youssef1313 commentedon Aug 20, 2023
Note: It looks like dotnet/runtime#89348 fixes this for .NET 8. So the
HasFlagchanges in #13309 could be reverted when we move to net8.0/net9.0 a year later.Or we could just live with the bitwise AND that is known to be performant and not rely on JIT optimizing HasFlag even when we are net8.0+.
Edit: Even for net8.0 it seems that the optimization isn't guaranteed. Let's stick with HasFlag for any hot code paths.