|
52 | 52 |
|
53 | 53 | using namespace std; |
54 | 54 |
|
| 55 | +// TEMPORARY diagnostics for the rust-on-linux CI failure. |
| 56 | +static std::atomic<size_t> g_dbg_sigprof{0}; |
| 57 | +static std::atomic<size_t> g_dbg_no_state{0}; |
| 58 | +static std::atomic<size_t> g_dbg_records{0}; |
| 59 | +static std::atomic<size_t> g_dbg_samples{0}; |
| 60 | +static std::atomic<size_t> g_dbg_matched{0}; |
| 61 | + |
55 | 62 | // Diagnostic counters for delay application (macOS debugging) |
56 | 63 | #ifdef __APPLE__ |
57 | 64 | static std::atomic<size_t> g_delays_applied{0}; |
@@ -511,6 +518,12 @@ void profiler::log_samples(ofstream& output, size_t start_time) { |
511 | 518 | */ |
512 | 519 | void profiler::shutdown() { |
513 | 520 | if(_shutdown_run.test_and_set() == false) { |
| 521 | + if(getenv("COZ_DEBUG_SAMPLES")) { |
| 522 | + fprintf(stderr, |
| 523 | + "[coz-dbg] sigprof=%zu no_state=%zu perf_records=%zu samples=%zu matched=%zu\n", |
| 524 | + g_dbg_sigprof.load(), g_dbg_no_state.load(), g_dbg_records.load(), |
| 525 | + g_dbg_samples.load(), g_dbg_matched.load()); |
| 526 | + } |
514 | 527 | #ifdef __APPLE__ |
515 | 528 | // Stop the macOS sampling thread first so no more samples are produced |
516 | 529 | // and no more pthread_kill() calls happen from apply_pending_delays() |
@@ -718,10 +731,13 @@ void profiler::add_delays(thread_state* state) { |
718 | 731 |
|
719 | 732 | void profiler::process_samples(thread_state* state) { |
720 | 733 | for(perf_event::record r : state->sampler) { |
| 734 | + g_dbg_records.fetch_add(1, std::memory_order_relaxed); |
721 | 735 | if(r.is_sample()) { |
| 736 | + g_dbg_samples.fetch_add(1, std::memory_order_relaxed); |
722 | 737 | // Find and match the line that contains this sample |
723 | 738 | std::pair<line*, bool> sampled_line = match_line(r); |
724 | 739 | if(sampled_line.first) { |
| 740 | + g_dbg_matched.fetch_add(1, std::memory_order_relaxed); |
725 | 741 | sampled_line.first->add_sample(); |
726 | 742 | } |
727 | 743 |
|
@@ -855,8 +871,10 @@ void* profiler::start_profiler_thread(void* arg) { |
855 | 871 | } |
856 | 872 |
|
857 | 873 | void profiler::samples_ready(int signum, siginfo_t* info, void* p) { |
| 874 | + g_dbg_sigprof.fetch_add(1, std::memory_order_relaxed); |
858 | 875 | thread_state* state = get_instance().get_thread_state(); |
859 | 876 | if (!state) { |
| 877 | + g_dbg_no_state.fetch_add(1, std::memory_order_relaxed); |
860 | 878 | return; |
861 | 879 | } |
862 | 880 | if (state->check_in_use()) { |
|
0 commit comments