Skip to content

Commit 50a8d5f

Browse files
committed
Minor tweaks
1 parent cc02c1e commit 50a8d5f

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

ddprof-lib/src/main/cpp/flightRecorder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class Recording {
164164
public:
165165
Recording(int fd, Arguments &args);
166166
~Recording();
167-
167+
168168
void copyTo(int target_fd);
169169
off_t finishChunk();
170170

ddprof-lib/src/main/cpp/threadFilter.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ bool ThreadFilter::accept(SlotID slot_id) const {
125125
int slot_idx = slot_id & kChunkMask;
126126

127127
if (chunk_idx >= kMaxChunks) return false;
128+
if (slot_idx >= kChunkSize) return false;
129+
128130
ChunkStorage* chunk = _chunks[chunk_idx].load(std::memory_order_relaxed);
129131
if (chunk == nullptr) return false; // Fail-fast if not allocated
130132

@@ -138,6 +140,8 @@ void ThreadFilter::add(int tid, SlotID slot_id) {
138140
int slot_idx = slot_id & kChunkMask;
139141

140142
if (chunk_idx >= kMaxChunks) return;
143+
if (slot_idx >= kChunkSize) return;
144+
141145
ChunkStorage* chunk = _chunks[chunk_idx].load(std::memory_order_relaxed);
142146
if (chunk == nullptr) return; // Fail-fast if not allocated
143147

@@ -152,6 +156,8 @@ void ThreadFilter::remove(SlotID slot_id) {
152156
int slot_idx = slot_id & kChunkMask;
153157

154158
if (chunk_idx >= kMaxChunks) return;
159+
if (slot_idx >= kChunkSize) return;
160+
155161
ChunkStorage* chunk = _chunks[chunk_idx].load(std::memory_order_relaxed);
156162
if (chunk == nullptr) return; // Fail-fast if not allocated
157163

ddprof-lib/src/main/cpp/threadIdTable.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
// Signal-safe thread ID table with fixed size
1414
class ThreadIdTable {
1515
private:
16-
static const int TABLE_SIZE = 256; // Should handle most realistic thread counts
16+
// We have 256 slots per concurrency level (currently 16)
17+
// This should cater for 4096 threads - if it turns out to be too small, we
18+
// can increase it or make it configurable
19+
static const int TABLE_SIZE = 256;
1720
std::atomic<int> table[TABLE_SIZE];
1821

1922
int hash(int tid) const {

0 commit comments

Comments
 (0)