@@ -53,6 +53,8 @@ PMR_NS::memory_resource* default_stack_resource = nullptr;
53
53
size_t default_stack_size = 64 * 1024 ;
54
54
uint64_t g_tsc_cycles_per_ms = 0 ;
55
55
56
+ __thread FiberInterface::TL FiberInterface::tl;
57
+
56
58
// Per thread initialization structure.
57
59
struct TL_FiberInitializer {
58
60
TL_FiberInitializer* next = nullptr ;
@@ -63,7 +65,6 @@ struct TL_FiberInitializer {
63
65
// Per-thread scheduler instance.
64
66
// Allows overriding the main dispatch loop
65
67
Scheduler* sched;
66
- uint64_t epoch = 0 ;
67
68
uint64_t switch_delay_cycles = 0 ; // switch delay in cycles.
68
69
69
70
// Tracks fiber runtimes that took longer than 1ms.
@@ -379,7 +380,7 @@ FiberInterface* FiberInterface::SwitchSetup() {
379
380
// When a kernel suspends we may get a negative delta because TSC is reset.
380
381
// We ignore such cases (and they are very rare).
381
382
if (tsc > cpu_tsc_) {
382
- ++fb_initializer .epoch ;
383
+ ++tl .epoch ;
383
384
DCHECK_GE (tsc, to_suspend->cpu_tsc_ );
384
385
fb_initializer.switch_delay_cycles += (tsc - cpu_tsc_);
385
386
@@ -437,10 +438,6 @@ void SetCustomDispatcher(DispatchPolicy* policy) {
437
438
fb_init.sched ->AttachCustomPolicy (policy);
438
439
}
439
440
440
- uint64_t FiberSwitchEpoch () noexcept {
441
- return detail::FbInitializer ().epoch ;
442
- }
443
-
444
441
uint64_t FiberSwitchDelayUsec () noexcept {
445
442
// in nanoseconds, so lets convert from cycles
446
443
return detail::FbInitializer ().switch_delay_cycles * 1000 / detail::g_tsc_cycles_per_ms;
0 commit comments