GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — allow affinity mask wider than 32 processors by HuzaifaChaudary · Pull Request #3242 · dotnet/BenchmarkDotNet Conversation
|
| check | result |
|---|---|
| build | succeeded |
| unit tests | 1073 total 1065 passed 0 failed 8 skipped |
| exporter tests | 51 of 51 |
| analyzer tests | 20234 of 20234 |
net10.0 on macos arm64.
i did not touch cpu groups. this only widens what the cli can express up to the 64 that FixAffinity already supports.
closes #3231
Sorry, something went wrong.
There was an error while loading. Please reload this page.
the affinity cli option was parsed as int so a mask with any bit above 32 could not be passed at all even though the job stores it as IntPtr and FixAffinity already handles a 64 bit mask parsing it as long also means the perfonar model must hold long or the value gets truncated on the way out
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This PR widens the --affinity CLI option to accept masks beyond 32 bits, aligning the console entry point with the rest of the affinity pipeline (which already uses IntPtr and masks up to 64 bits).
Changes:
CommandLineOptions.Affinity from int? to long? so higher-bit masks can be parsed from the CLI.EnvironmentMode.ToPerfonar() / BdnEnvironment) to avoid truncation/overflow when affinity exceeds int.Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/BenchmarkDotNet.Tests/Perfonar/PerfonarTests.cs | Updates test helper signature to accept long? affinity for Perfonar output generation. |
| tests/BenchmarkDotNet.Tests/ConfigParserTests.cs | Adds regression tests validating CLI affinity parsing for small and >32-bit masks. |
| src/BenchmarkDotNet/Models/BdnEnvironment.cs | Widens internal Perfonar environment model affinity from int? to long? to prevent truncation/overflow. |
| src/BenchmarkDotNet/Jobs/EnvironmentMode.cs | Updates affinity projection to Perfonar to use long instead of int. |
| src/BenchmarkDotNet/ConsoleArguments/CommandLineOptions.cs | Widens CLI option type for --affinity from int? to long?. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@dotnet-policy-service agree |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
new IntPtr(1L << 40) throws OverflowException where IntPtr is four bytes, so the test i added would fail on a 32 bit run rather than prove anything. added a Platform64BitOnly requirement so it skips there, using the same FactEnvSpecific mechanism the other platform bound tests already use also added a test for the top bit. the 64th cpu is the last one FixAffinity handles without cpu groups and its mask only fits in a signed long as the negative value, so this pins down that it still reaches the right IntPtr
a mask is not a signed number and the 64th cpu needed to be written as -9223372036854775808 to reach it. now it is written the way the mask reads the perfonar model stays long. perfolizers LightJsonSerializer throws Unsupported type: System.UInt64 so making that half unsigned breaks PerfonarTableTest at runtime. the value is only carried there so a signed long holds the same bits and nothing is lost conversion to IntPtr goes through new IntPtr(unchecked((long)value)) which is the same shape FixAffinity already uses
the option is now unsigned so a value above int.MaxValue can reach new IntPtr(long) which throws on a 32 bit process instead of truncating. that made ConfigParser.Parse fail with an unhandled OverflowException rather than a normal option error. the conversion now goes through TryConvertAffinity which takes the pointer size. on 8 bytes it keeps the full 64 bit mask as before. on 4 bytes it takes the low 32 bits so a full 32 processor mask still works and it reports failure for anything wider so Validate can print an error.
|
follow up on the first copilot comment. i only fixed the test half of it and left the production half in place. copilot said the overflow hits there is a second case that a plain reject would get wrong. a full 32 processor mask is so the conversion goes through one helper that takes the pointer size: internal static bool TryConvertAffinity(ulong mask, int pointerSize, out IntPtr affinity) { if (pointerSize >= 8) { affinity = new IntPtr(unchecked((long)mask)); return true; } affinity = new IntPtr(unchecked((int)mask)); return mask <= uint.MaxValue; }
passing the pointer size in is what makes the 32 bit path testable on a 64 bit machine. three theories in
with the helper body swapped back to the old unguarded put back it is 142 of 142 with 3 unrelated skips. ran what
net10.0 on macos arm64. one more thing while i was in here. i wanted to back up my own claim about leaving and called so the perfonar model does have to stay signed until perfolizer grows a |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks @HuzaifaChaudary
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Failed to setting CPU affinity over 32-processor via cli arg
There was an error while loading. Please reload this page.