aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/cpu_clock
diff options
context:
space:
mode:
authorlukyan <lukyan@yandex-team.com>2024-04-26 02:21:44 +0300
committerlukyan <lukyan@yandex-team.com>2024-04-26 02:41:13 +0300
commit5bbe44ff4e12b6d5496d56ecca97b0c4db340509 (patch)
tree511f2114250a8a3da539995a2da71782c3f82883 /library/cpp/yt/cpu_clock
parent7bde5f1f7732fb9e9103ac1f54fe1de99bdb6be5 (diff)
downloadydb-5bbe44ff4e12b6d5496d56ecca97b0c4db340509.tar.gz
YT-21566: Access thread local variables via noinline functions
970c33b44a7bd166b2716d86d3d2053dcaf05d7d
Diffstat (limited to 'library/cpp/yt/cpu_clock')
-rw-r--r--library/cpp/yt/cpu_clock/clock.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/library/cpp/yt/cpu_clock/clock.cpp b/library/cpp/yt/cpu_clock/clock.cpp
index 0ed65e3b92..22f665e1d3 100644
--- a/library/cpp/yt/cpu_clock/clock.cpp
+++ b/library/cpp/yt/cpu_clock/clock.cpp
@@ -31,18 +31,16 @@ double GetTicksToMicroseconds()
return TicksToMicroseconds;
}
-TCalibrationState GetCalibrationState(TCpuInstant cpuInstant)
+YT_PREVENT_TLS_CACHING TCalibrationState GetCalibrationState(TCpuInstant cpuInstant)
{
- YT_THREAD_LOCAL(TCalibrationState) State;
+ thread_local TCalibrationState State;
- auto& state = GetTlsRef(State);
-
- if (state.CpuInstant + CalibrationCpuPeriod < cpuInstant) {
- state.CpuInstant = cpuInstant;
- state.Instant = TInstant::Now();
+ if (State.CpuInstant + CalibrationCpuPeriod < cpuInstant) {
+ State.CpuInstant = cpuInstant;
+ State.Instant = TInstant::Now();
}
- return state;
+ return State;
}
TCalibrationState GetCalibrationState()