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
{{ message }}
Repository navigation
gcenv.interlocked's Interlocked use full memory barriers even with 8.1 Atomics #67824
All Interlocked functions from gcenv.interlocked.inl seem to insert full memory barriers, e.g. consider this usage (GC seems to heavily use them under BACKGROUND_GC):
template <typename T>
__forceinline T Interlocked::Increment(T volatile *addend)
{
#ifdef _MSC_VER
static_assert(sizeof(long) == sizeof(T), "Size of long must be the same as size of T");
return_InterlockedIncrement((long*)addend);
#else
T result = __sync_add_and_fetch(addend, 1);
ArmInterlockedOperationBarrier();
return result;
#endif
}
PS: Yes, when we compile CoreCLR for Apple M1 we unintentionally use -mcpu=apple-m1 and use all the new shiny instructions e.g. arm v8.3's ldapr, 8.1 atomics, etc.. (well, makes sense 🤷♂️)
thank you very much for noticing this @EgorBo ! how stressful are tests run with TE infra (I thought they were mostly small perf tests?)? we do have a stress infra for GC.
thank you very much for noticing this @EgorBo ! how stressful are tests run with TE infra (I thought they were mostly small perf tests?)? we do have a stress infra for GC.
I know that @kunalspathak has some progress in a related issue and I personally probably will just remove that explicit memory barrier for OSX-arm64 at least.
@Maoni0 - Do we want to extend #71512 for GC code. When I tried to do something similar for Windows/arm64 in #71169, we didn't see much benefits and hence didn't optimize windows/arm64.
thanks @kunalspathak. unless you believe the linux scenario is different (like the full barrier we are doing is somehow a lot more expensive on linux than on windows), I would say let's not do this for linux either.
Activity
EgorBo commentedon Apr 10, 2022
I removed these barriers and lowered number of
dmb ishfrom 1724 to 71 inlibcoreclr.dylib(GC is included)Will test it on our TE infra
VSadov commentedon Apr 11, 2022
Right. If
-mcpu=apple-m1is guaranteed to use 8.1 atomic instructions, there is no need for the extra membarrier.Also - I think GC has its own copy of Interlocked, separate from what runtime uses. I wonder if Interlocked in the runtime could use the same change.
Maoni0 commentedon Apr 11, 2022
thank you very much for noticing this @EgorBo ! how stressful are tests run with TE infra (I thought they were mostly small perf tests?)? we do have a stress infra for GC.
EgorBo commentedon Apr 11, 2022
Sure, will try the stress infra, thanks!
janvorli commentedon Jun 15, 2022
Is this something that we still want to change for 7.0?
EgorBo commentedon Jun 15, 2022
I know that @kunalspathak has some progress in a related issue and I personally probably will just remove that explicit memory barrier for OSX-arm64 at least.
kunalspathak commentedon Jun 16, 2022
That's right. I am currently working on a prototype to have this removed and hoping to make it to 7.0
kunalspathak commentedon Jul 8, 2022
@Maoni0 - Do we want to extend #71512 for GC code. When I tried to do something similar for Windows/arm64 in #71169, we didn't see much benefits and hence didn't optimize windows/arm64.
Maoni0 commentedon Jul 8, 2022
thanks @kunalspathak. unless you believe the linux scenario is different (like the full barrier we are doing is somehow a lot more expensive on linux than on windows), I would say let's not do this for linux either.
kunalspathak commentedon Jul 8, 2022
Sounds good. I will close this issue then.