-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Conversation
Edit: Ah... my mistake, it isn't cached in the VM layer. How important is detecting changing proc count changes every 30 secs? This particular property is used by e.g. |
The original version of this code was refreshing processor affinity every 30 secs. It is not doing that anymore after several refactorings - in most cases at least. |
Yes, I think it would be best. If there are tests that failing because of that, they should be fixed or deleted. |
cc @kouvel, who changed IsSingleProcessor in https://github.com/dotnet/coreclr/pull/13670/files#diff-683db3e0122bda1b5528859535552c7fR357. This whole PlatformHelper.ProcessorCount thing originated around 10 years ago, when hot-swappable CPUs were the rage and this was done to assist types like Parallel in adapting as the number of cores changed. At this point, I don't think it's worth the trouble. Software architecture has evolved, and scalable services that need to adapt are likely better off being restarted than paying runtime costs trying to adapt. I think it's fine to remove this whole PlatformHelper thing (in both coreclr and corefx) and just change everything to use Environment.ProcessorCount, and then make ProcessorCount fixed on first use. |
We seem to also have ambiguity about what
|
Mono method is interesting with comments on trade offs https://github.com/mono/mono/blob/6dff5fc81321a4fd9dd493e215d4ace543475054/mono/utils/mono-proclib.c#L760-L880 |
In Mono the comments indicate its bypassing Android's power shutdown of CPUs to get the real CPU count:
However then does the same |
@jkotas @AndyAyersMS this was the area I was concerned about (since it will now inline); but I'm not sure how the Jit tests work/run coreclr/tests/src/JIT/Directed/pinvoke/pinvoke-examples.cs Lines 158 to 167 in 030a3ea
|
You can change that test to use Regardless, it is not ideal for JIT tests to depend on CoreLib internals. |
Squashed and rebased to try to give CI a kick |
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
On top of mono/corefx#369 this improves the execution time of `System.Core-xunit` on Linux/ARM64 by 2x, so from: ```console $ make -C mcs/class/System.Core run-xunit-test [...] === TEST EXECUTION SUMMARY === net_4_x_System.Core_xunit-test Total: 48774, Errors: 0, Failed: 0, Skipped: 6, Time: 131.143s ``` to ```console $ make -C mcs/class/System.Core run-xunit-test [...] === TEST EXECUTION SUMMARY === net_4_x_System.Core_xunit-test Total: 48774, Errors: 0, Failed: 0, Skipped: 6, Time: 74.636s ``` This is only relevant for non-netcore. The CoreCLR folks just recently fixed something similar (thanks to Marek sharing this link): dotnet/coreclr#27543
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
On top of mono/corefx#369 this improves the execution time of `System.Core-xunit` on Linux/ARM64 by 2x, so from: ```console $ make -C mcs/class/System.Core run-xunit-test [...] === TEST EXECUTION SUMMARY === net_4_x_System.Core_xunit-test Total: 48774, Errors: 0, Failed: 0, Skipped: 6, Time: 131.143s ``` to ```console $ make -C mcs/class/System.Core run-xunit-test [...] === TEST EXECUTION SUMMARY === net_4_x_System.Core_xunit-test Total: 48774, Errors: 0, Failed: 0, Skipped: 6, Time: 74.636s ``` This is only relevant for non-netcore. The CoreCLR folks just recently fixed something similar (thanks to Marek sharing this link): dotnet/coreclr#27543
/cc @dotnet/coreclr-infra this change has broken pinvoke-examples it was not run during this change because it is an outerloop test |
@AaronRobinsonMSFT will disable the test, @benaadams do you have cycles to fix the test after it is disabled? |
Not sure; I changed the test in this PR to use |
I think the issue is that |
Is a QCall needed or is that merely to simplify the dependency on a new native library? To answer the question specifically, I don't know of a QCall that would satisfy that requirement off the top of my head. Additionally, can someone provide insight into what this test is meant to solve? Perhaps it could be rewritten to more accurately address the need - |
The test was added by @AndyAyersMS --
|
There is a comment in the test: // Test cases showing interaction of inlining and inline pinvoke,
// along with the impact of EH. It doesn't matter much what gets pinvoked, though it seems some adaptation will be needed. |
Oops. Sorry for missing that.
Okay. Given that authoring a simple native project is so cheap, I suggest we create one for this test. Relying on implementation details in the runtime for testing seems like a bad idea. |
I fixed the test - see #27614. |
Edit: Ah... my mistake, it isn't cached in the VM layer. How important is detecting changing proc count changes every 30 secs? (as used by
SpinWait
,SpinLock
andCancellationTokenSource
)e.g.
IsSingleProcessor
is only ever set once and never refreshedIts cached in the vm layer after first access so never changes; so it can be astatic readonly
.I looked at changingEnviorment.ProcessorCount
to bestatic readonly
backed and then changing all the individualstatic readonly
procCount caches to just call it directly.However, that's a bit more complicated as there are Jit tests that rely on it being non-inlinable due to the p/invoke and it would cause complications for the shared source as Mono's p/invoke its the get property not the method that the get property then calls; so loosing the caches would likely cause regressions there./cc @jkotas @stephentoub