Skip to content

Commit abc8b7f

Browse files
committed
async-profiler#1686: Clarify table allocation logic in CallTraceStorage
1 parent 4ea8e5b commit abc8b7f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/callTraceStorage.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,12 @@ u32 CallTraceStorage::put(int num_frames, ASGCT_CallFrame* frames, u64 counter)
245245
continue;
246246
}
247247

248-
// Increment the table size, and if the load factor exceeds 0.75, reserve a new table
248+
// Increment the table size, and if the load factor exceeds 0.75, reserve a new table.
249+
// This condition can be hit only once per table, so the below allocation is race-free.
249250
if (table->incSize() == capacity * 3 / 4) {
250251
LongHashTable* new_table = LongHashTable::allocate(table, capacity * 2);
251252
if (new_table != NULL) {
252-
__sync_bool_compare_and_swap(&_current_table, table, new_table);
253+
__atomic_store_n(&_current_table, new_table, __ATOMIC_RELEASE);
253254
}
254255
}
255256

0 commit comments

Comments
 (0)