-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Fall back to CpuId if failed to get cache size from OS #24989
Conversation
It's possible for GetLogicalProcessorCacheSizeFromOS() to fail; this happens on alpine linux where it compiles to just `return 0;`. As a fallback, we can get the cache size from CpuId. Previously that was specific to x86; this PR preserves the behavior that we never call GetLogicalProcessorCacheSizeFromOS on x86. CpuId only works on x86 and amd64; on other systems we may still return 0 from here. Then GC defaults to a cache size of only 0.25MB. Note: Removed the code in an `#ifdef _WIN64` that was nested inside of `#if defined (_TARGET_X86_)`. Presuming that is dead code.
} | ||
#endif // _TARGET_X86_ | ||
|
||
// fix this if/when AMD does multicore or SMT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is very obsolete. I was just about to ask about AMD support. I've found the following CPUID specification from AMD that contains all the necessary info here: https://www.amd.com/system/files/TechDocs/25481.pdf
Edit: Please ignore this comment, I've missed the code above that already handles the AMD.
|
||
if (maxSize) | ||
PAL_TRY(Param *, pParam, ¶m) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the attached PAL_EXCEPT_FILTER
is using DefaultCatchFilter
, the parameter type has to be derived from DefaultCatchFilterParam
. The DefaultCatchFilter
casts the parameter * to DefaultCatchFilterParam*
and reads the pv
field out of it.
The DefaultCatchFilter
is used to swallow hardware exceptions that can stem from the CPUID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This typo was in #24989 so would be a new regression in 3.0. In an x86 build, it causes us to not get the cache size correct, leading us to use a smaller default cache size and do more GCs. Tested with GCPerfSim and this PR reduces TotalNumberGCs by 33% using an x86 build.
This typo was in dotnet#24989 so would be a new regression in 3.0. In an x86 build, it causes us to not get the cache size correct, leading us to use a smaller default cache size and do more GCs. Tested with GCPerfSim and this PR reduces TotalNumberGCs by 33% using an x86 build.
This typo was in dotnet#24989 so would be a new regression in 3.0. In an x86 build, it causes us to not get the cache size correct, leading us to use a smaller default cache size and do more GCs. Tested with GCPerfSim and this PR reduces TotalNumberGCs by 33% using an x86 build.
This typo was in #24989 so would be a new regression in 3.0. In an x86 build, it causes us to not get the cache size correct, leading us to use a smaller default cache size and do more GCs. Tested with GCPerfSim and this PR reduces TotalNumberGCs by 33% using an x86 build.
…r#24989) * Fall back to CpuId if failed to get cache size from OS It's possible for GetLogicalProcessorCacheSizeFromOS() to fail; this happens on alpine linux where it compiles to just `return 0;`. As a fallback, we can get the cache size from CpuId. Previously that was specific to x86; this PR preserves the behavior that we never call GetLogicalProcessorCacheSizeFromOS on x86. CpuId only works on x86 and amd64; on other systems we may still return 0 from here. Then GC defaults to a cache size of only 0.25MB. Note: Removed the code in an `#ifdef _WIN64` that was nested inside of `#if defined (_TARGET_X86_)`. Presuming that is dead code. * Fix exception handler Commit migrated from dotnet/coreclr@6d29903
This typo was in dotnet/coreclr#24989 so would be a new regression in 3.0. In an x86 build, it causes us to not get the cache size correct, leading us to use a smaller default cache size and do more GCs. Tested with GCPerfSim and this PR reduces TotalNumberGCs by 33% using an x86 build. Commit migrated from dotnet/coreclr@ba39a15
It's possible for GetLogicalProcessorCacheSizeFromOS() to fail;
this happens on alpine linux where it compiles to just
return 0;
.As a fallback, we can get the cache size from CpuId. Previously that
was specific to x86; this PR preserves the behavior that we never call
GetLogicalProcessorCacheSizeFromOS on x86.
CpuId only works on x86 and amd64; on other systems we may still return
0 from here. Then GC defaults to a cache size of only 0.25MB.
Fix #16071