-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMItenet-performancePerformance related issuePerformance related issue
Milestone
Description
I noticed that various Thread Statics helpers constantly pop up in native traces in micro and macro benchmarks, e.g. Platform-JSON TE benchmark:

A simple demo:
while (true)
{
var arr = ArrayPool<int>.Shared.Rent(10000);
ArrayPool<int>.Shared.Return(arr);
}when it spins it spends most of the time in JIT_GetSharedGCThreadStaticBaseDynamicClass:

where it just early outs:

if only we had a dedicated register (I think we can afford one at least on arm) which always pointed to current thread we could avoid that kind of overhead. Something like this (pseudocode):
if (!CTreg->tlsInited)
initTls();
var field = CTreg->field;
making TLS access super cheap. As a bonus it might help with some pinvoke/safepoints routine?
Thoughts?
cc @jkotas
category:cq
theme:runtime
skill-level:intermediate
cost:small
impact:medium
Vadimyan, NN---, DankanTsar, holydel, AnarchyMob and 2 more
Metadata
Metadata
Assignees
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMItenet-performancePerformance related issuePerformance related issue