Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions iocore/eventsystem/I_Thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class Thread
protected:
Thread();

static thread_local ink_hrtime cur_time;
static ink_hrtime cur_time;
};

extern Thread *this_thread();
Expand All @@ -189,5 +189,12 @@ Thread::get_hrtime()
TS_INLINE ink_hrtime
Thread::get_hrtime_updated()
{
return cur_time = ink_get_hrtime_internal();
ink_hrtime now = ink_get_hrtime_internal();
if (now > cur_time) {
// Thread::cur_time is used frequently in most threads. By avoiding unnecessary writes of it, locks of its cache line
// in (all) per-core caches are reduced. This should reduce CPU core stalls.
//
cur_time = now;
}
return cur_time;
}
2 changes: 1 addition & 1 deletion iocore/eventsystem/Thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
// Common Interface impl //
///////////////////////////////////////////////

thread_local ink_hrtime Thread::cur_time = ink_get_hrtime_internal();
ink_hrtime Thread::cur_time = ink_get_hrtime_internal();
thread_local Thread *Thread::this_thread_ptr;

Thread::Thread()
Expand Down