• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

llnl / dftracer-utils / 23567641224

25 Mar 2026 10:35PM UTC coverage: 51.022% (+0.8%) from 50.205%
23567641224

push

github

rayandrew
feat(comparator): inject trace metadata into root SUMMARY rows

Add build_metadata_metrics() that creates MetricComparison entries
for files, processes, threads, time_pipeline (makespan), time_io
(total I/O time), and total_bytes. These are prepended to the root
SUMMARY so they appear in the tree table with full columnar
comparison (baseline | variant | delta | pct | sig).

time_pipeline and time_io group under a "time" parent node in the
tree via the existing underscore-prefix grouping logic.

22043 of 55983 branches covered (39.37%)

Branch coverage included in aggregate %.

53 of 55 new or added lines in 4 files covered. (96.36%)

205 existing lines in 17 files now uncovered.

19365 of 25174 relevant lines covered (76.92%)

439576.57 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

57.31
/src/dftracer/utils/core/runtime.cpp
1
#include <dftracer/utils/core/common/logging.h>
2
#include <dftracer/utils/core/common/platform_compat.h>
3
#include <dftracer/utils/core/runtime.h>
4

5
#include <algorithm>
6
#include <stdexcept>
7
#include <thread>
8

9
namespace dftracer::utils {
10

11
Runtime::Runtime(std::size_t threads)
438✔
12
    : threads_(threads == 0 ? dftracer_utils_hardware_concurrency() : threads) {
438!
13
    ExecutorConfig config;
292!
14
    config.num_threads = threads_;
292✔
15
    executor_ = std::make_unique<Executor>(config);
292!
16
    executor_->start();
292!
17

18
    watchdog_ = std::make_unique<Watchdog>();
292!
19
    watchdog_->set_executor(executor_.get());
292!
20
}
292✔
21

22
Runtime::Runtime(const ExecutorConfig& config, bool enable_watchdog)
×
23
    : threads_(config.num_threads == 0 ? dftracer_utils_hardware_concurrency()
×
24
                                       : config.num_threads) {
×
25
    executor_ = std::make_unique<Executor>(config);
×
UNCOV
26
    executor_->start();
×
27

28
    if (enable_watchdog) {
×
29
        watchdog_ = std::make_unique<Watchdog>();
×
UNCOV
30
        watchdog_->set_executor(executor_.get());
×
31
    }
UNCOV
32
}
×
33

34
Runtime::Runtime(const ExecutorConfig& config,
525✔
35
                 std::unique_ptr<Watchdog> watchdog)
175✔
36
    : threads_(config.num_threads == 0 ? dftracer_utils_hardware_concurrency()
350!
37
                                       : config.num_threads) {
694✔
38
    executor_ = std::make_unique<Executor>(config);
350!
39
    executor_->start();
350!
40

41
    watchdog_ = std::move(watchdog);
350✔
42
    if (watchdog_) {
350✔
43
        watchdog_->set_executor(executor_.get());
182!
44
    }
91✔
45
}
350✔
46

47
Runtime::~Runtime() { shutdown(); }
963!
48

49
TaskHandle Runtime::submit(coro::CoroTask<void> task, std::string name) {
462✔
50
    if (shutdown_called_.load(std::memory_order_acquire)) {
462✔
51
        throw std::runtime_error("Runtime is shut down");
4!
52
    }
53
    if (name.empty()) {
458✔
54
        name = "task-" + std::to_string(task_name_counter_++);
6!
55
    }
3✔
56

57
    auto promise = std::make_shared<std::promise<void>>();
458!
58
    auto future = promise->get_future().share();
458!
59
    auto tid = std::make_shared<std::atomic<TaskIndex>>(-1);
458!
60

61
    auto wrapper =
229✔
62
        [](coro::CoroTask<void> t, std::shared_ptr<std::promise<void>> p,
1,826!
63
           Executor* exec,
64
           std::shared_ptr<std::atomic<TaskIndex>> task_id) -> coro::Coro {
229!
65
        try {
66
            co_await std::move(t);
1,139!
67
            exec->mark_coro_completed(task_id->load(std::memory_order_acquire));
226!
68
        } catch (...) {
229✔
69
            exec->mark_coro_completed(task_id->load(std::memory_order_acquire));
3!
70
            p->set_exception(std::current_exception());
3!
71
            co_return;
3✔
72
        }
3!
73
        p->set_value();
226!
74
    };
913!
75

76
    auto coro = wrapper(std::move(task), promise, executor_.get(), tid);
687!
77
    TaskIndex id = executor_->enqueue_tracked(std::move(coro), name, tid);
458!
78

79
    {
80
        std::lock_guard<std::mutex> lock(futures_mutex_);
458!
81
        cleanup_completed_futures();
458!
82
        outstanding_futures_.push_back(future);
458!
83
    }
458✔
84

85
    return TaskHandle{future, id, std::move(name)};
687!
86
}
458✔
87

88
void Runtime::wait_all() {
154✔
89
    std::vector<std::shared_future<void>> futures;
154✔
90
    {
91
        std::lock_guard<std::mutex> lock(futures_mutex_);
154!
92
        futures = std::move(outstanding_futures_);
154✔
93
        outstanding_futures_.clear();
154✔
94
    }
154✔
95
    for (auto& f : futures) {
185✔
96
        f.wait();
31!
97
    }
98
}
154✔
99

100
void Runtime::cleanup_completed_futures() {
668✔
101
    outstanding_futures_.erase(
1,336!
102
        std::remove_if(outstanding_futures_.begin(), outstanding_futures_.end(),
668!
103
                       [](const std::shared_future<void>& f) {
540✔
104
                           return f.wait_for(std::chrono::seconds(0)) ==
540!
105
                                  std::future_status::ready;
267✔
106
                       }),
107
        outstanding_futures_.end());
668✔
108
}
668✔
109

110
ExecutorProgress Runtime::get_progress() const {
38✔
111
    return executor_->get_progress();
38✔
112
}
113

114
bool Runtime::is_responsive() const { return executor_->is_responsive(); }
4✔
115

116
void Runtime::set_global_timeout(std::chrono::milliseconds timeout) {
×
117
    if (!watchdog_) {
×
UNCOV
118
        throw std::runtime_error(
×
119
            "Cannot set timeout: Runtime created without watchdog");
120
    }
121
    watchdog_->set_global_timeout(timeout);
×
UNCOV
122
}
×
123

124
void Runtime::set_default_task_timeout(std::chrono::milliseconds timeout) {
×
125
    if (!watchdog_) {
×
UNCOV
126
        throw std::runtime_error(
×
127
            "Cannot set timeout: Runtime created without watchdog");
128
    }
129
    watchdog_->set_default_task_timeout(timeout);
×
UNCOV
130
}
×
131

132
void Runtime::shutdown() {
1,218✔
133
    bool expected = false;
1,218✔
134
    if (!shutdown_called_.compare_exchange_strong(expected, true)) return;
1,218✔
135
    if (watchdog_) watchdog_->stop();
642!
136
    if (executor_) executor_->shutdown();
642!
137
}
609✔
138

139
std::size_t Runtime::threads() const { return threads_; }
18✔
140

141
}  // namespace dftracer::utils
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc