Skip to content

Commit 9adedfe

Browse files
committed
Avoid intermittent failures in traceid generation tests
1 parent cd14fa7 commit 9adedfe

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

ddprof-lib/src/test/cpp/stress_callTraceStorage.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,21 +1673,17 @@ TEST_F(StressTestSuite, InstanceIdTraceIdStressTest) {
16731673
std::vector<std::thread> workers;
16741674
for (int t = 0; t < NUM_THREADS; ++t) {
16751675
workers.emplace_back([&, t]() {
1676-
std::mt19937 gen(std::random_device{}() + t);
1677-
// No longer need storage distribution since we use single instance
1678-
std::uniform_int_distribution<uint32_t> bci_dis(1, 100000);
1679-
std::uniform_int_distribution<uintptr_t> method_dis(0x10000, 0xFFFFFF);
1680-
16811676
for (int op = 0; op < OPERATIONS_PER_THREAD && !test_failed.load(); ++op) {
16821677
try {
16831678
// Use the single shared storage instance
16841679
CallTraceStorage* storage = storage_instance;
1685-
1686-
// Create a unique frame to avoid hash collisions masking trace ID issues
1680+
1681+
// Create a DETERMINISTIC unique frame - no randomness
1682+
// Each (thread, operation) pair generates a unique frame
16871683
ASGCT_CallFrame frame;
1688-
frame.bci = bci_dis(gen) + t * 1000000 + op; // Ensure uniqueness
1689-
frame.method_id = reinterpret_cast<jmethodID>(method_dis(gen) + t * 0x1000000);
1690-
1684+
frame.bci = t * 1000000 + op; // Deterministic: thread_id * 1M + op_index
1685+
frame.method_id = reinterpret_cast<jmethodID>(0x10000000ULL + (u64)t * 10000000ULL + (u64)op);
1686+
16911687
// Calculate stack trace hash for analysis (simplified hash of frame data)
16921688
u64 stack_hash = (u64)frame.bci ^ ((u64)frame.method_id << 32);
16931689

0 commit comments

Comments
 (0)