File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Load diff This file was deleted.
Original file line number Diff line number Diff line change 1616
1717#include < assert.h>
1818
19- #include " branch_hints .h"
19+ #include " arch_dd .h"
2020#include " context.h"
2121#include " counters.h"
2222#include " engine.h"
Original file line number Diff line number Diff line change 2020// - These methods assume slot_id comes from registerThread() (undefined behavior otherwise)
2121
2222#include " threadFilter.h"
23- #include " branch_hints .h"
23+ #include " arch_dd .h"
2424
25+ #include < cassert>
2526#include < cstdlib>
27+ #include < cstdio>
2628#include < thread>
2729#include < algorithm>
2830#include < cstring>
@@ -181,10 +183,17 @@ void ThreadFilter::remove(SlotID slot_id) {
181183 int chunk_idx = slot_id >> kChunkShift ;
182184 int slot_idx = slot_id & kChunkMask ;
183185
186+ if (unlikely (chunk_idx >= kMaxChunks )) {
187+ assert (false && " Invalid slot_id in ThreadFilter::remove - should not happen after wall clock fix" );
188+ return ;
189+ }
190+
184191 ChunkStorage* chunk = _chunks[chunk_idx].load (std::memory_order_relaxed);
185- if (likely (chunk ! = nullptr )) {
186- chunk-> slots [slot_idx]. value . store (- 1 , std::memory_order_release) ;
192+ if (unlikely (chunk = = nullptr )) {
193+ return ;
187194 }
195+
196+ chunk->slots [slot_idx].value .store (-1 , std::memory_order_release);
188197}
189198
190199void ThreadFilter::unregisterThread (SlotID slot_id) {
Original file line number Diff line number Diff line change 1919
2020#include < atomic>
2121#include < unordered_set>
22- #include " branch_hints .h"
22+ #include " arch_dd .h"
2323
2424// Simple fixed size thread ID table
2525class ThreadIdTable {
Original file line number Diff line number Diff line change 2121#include " os.h"
2222#include " profiler.h"
2323#include " reservoirSampler.h"
24+ #include " thread.h"
2425#include " threadFilter.h"
2526#include " threadState.h"
2627#include " tsc.h"
@@ -67,7 +68,15 @@ class BaseWallClock : public Engine {
6768 threads.reserve (reservoirSize);
6869 int self = OS::threadId ();
6970 ThreadFilter* thread_filter = Profiler::instance ()->threadFilter ();
70- thread_filter->remove (self);
71+
72+ // We don't want to profile ourselves in wall time
73+ ProfiledThread* current = ProfiledThread::current ();
74+ if (current != nullptr ) {
75+ int slot_id = current->filterSlotId ();
76+ if (slot_id != -1 ) {
77+ thread_filter->remove (slot_id);
78+ }
79+ }
7180
7281 u64 startTime = TSC::ticks ();
7382 WallClockEpochEvent epoch (startTime);
Load diff This file was deleted.
You can’t perform that action at this time.
0 commit comments