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

llnl / dftracer-utils / 26043728131

18 May 2026 03:37PM UTC coverage: 51.706% (-0.4%) from 52.076%
26043728131

push

github

hariharan-devarajan
feat(perf): performance improvements for parallel reading, indexing, and aggregation

Indexer
- Streaming parse-and-emit worker pipeline with bounded memory usage
- Concurrent SST artifact ingestion with staging support
- Gzip member slicing for parallel indexing
- Lazy decoding for compressed value counts
- Bypass DOM wrapper for indexer hot path (simdjson on_demand)
- Decoupled write workers from parse workers
- --rebuild-summaries flag and optimized root summary rebuild

Aggregator / MPI
- Task-based DAG execution for aggregator pipeline
- Shared staging for multi-node artifact relocation
- Per-node thread scaling to avoid oversubscription
- Unified distributed aggregation tracking, removed manifest consolidation
- Deterministic aggregation and intra-file parallelism

Trace reader / query
- Compiled predicate evaluation for AND-of-EQ queries
- Uniform-match shortcut for AND-of-EQ queries
- Line-range support for work items and checkpoint processing
- Optimized chunk pruning and checkpoint handling

Replay
- Pipelined replay with coroutines and channels
- JsonParser-based trace processing
- Optimized string handling and i/o buffering

Organize / writer / dft
- Parallel slice creation and merging in organize visitor
- Inline indexer in organize
- Gzip member tracking in writer
- Coroutine-based event dispatcher with extracted parse logic
- Batch flushing in organize visitor

Arrow / call_tree
- Optimized arrow conversion
- Arrow IPC support and improved save/load in call_tree

Build / infrastructure
- zlib-ng option, system simdjson fallback
- cgroup v1/v2 memory limit detection
- Auto-computed per-file memory estimates and batch sizes
- CI: perf branch trigger, formatting

Docs
- Rewritten indexer and trace reader API references

35907 of 90345 branches covered (39.74%)

Branch coverage included in aggregate %.

16869 of 21880 new or added lines in 137 files covered. (77.1%)

273 existing lines in 39 files now uncovered.

32021 of 41028 relevant lines covered (78.05%)

13164.29 hits per line

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

23.85
/src/dftracer/utils/python/json.cpp
1
#define PY_SSIZE_T_CLEAN
2
#include <Python.h>
3
#include <dftracer/utils/python/json.h>
4

5
using dftracer::utils::utilities::composites::dft::ArgsValueProxy;
6

7
PyObject *args_value_to_pyobject(const ArgsValue &v) {
360✔
8
    return std::visit(
540!
9
        [](const auto &val) -> PyObject * {
360✔
10
            using T = std::decay_t<decltype(val)>;
11
            if constexpr (std::is_same_v<T, std::monostate>) {
NEW
12
                Py_RETURN_NONE;
×
13
            } else if constexpr (std::is_same_v<T, std::string>) {
14
                return PyUnicode_FromStringAndSize(val.data(), val.size());
160✔
15
            } else if constexpr (std::is_same_v<T, std::uint64_t>) {
16
                return PyLong_FromUnsignedLongLong(val);
200✔
17
            } else if constexpr (std::is_same_v<T, std::int64_t>) {
NEW
18
                return PyLong_FromLongLong(val);
×
19
            } else if constexpr (std::is_same_v<T, double>) {
NEW
20
                return PyFloat_FromDouble(val);
×
21
            } else if constexpr (std::is_same_v<T, bool>) {
NEW
22
                return PyBool_FromLong(val ? 1 : 0);
×
23
            } else {
24
                Py_RETURN_NONE;
25
            }
26
        },
27
        v);
540✔
28
}
29

30
static const ArgsMap &get_map(JsonDictValueObject *self) {
160✔
31
    auto &ev = self->batch->events[self->event_index];
160✔
32
    return self->is_args ? ev.args : ev.top;
160!
33
}
34

35
static void JsonDictValue_dealloc(JsonDictValueObject *self) {
480✔
36
    self->batch.reset();
480✔
37
    Py_TYPE(self)->tp_free((PyObject *)self);
480✔
38
}
480✔
39

NEW
40
static Py_ssize_t JsonDictValue_length(JsonDictValueObject *self) {
×
NEW
41
    const auto &map = get_map(self);
×
NEW
42
    Py_ssize_t count = 0;
×
NEW
43
    map.for_each_member([&](std::string_view, ArgsValueProxy) { ++count; });
×
NEW
44
    if (!self->is_args && get_map(self).exists()) {
×
NEW
45
        auto &ev = self->batch->events[self->event_index];
×
NEW
46
        if (ev.args.exists()) ++count;
×
47
    }
NEW
48
    return count;
×
49
}
50

NEW
51
static PyObject *JsonDictValue_subscript(JsonDictValueObject *self,
×
52
                                         PyObject *key) {
NEW
53
    const char *key_str = PyUnicode_AsUTF8(key);
×
NEW
54
    if (!key_str) return NULL;
×
55

NEW
56
    std::string_view k(key_str);
×
57

NEW
58
    if (!self->is_args && k == "args") {
×
NEW
59
        auto &ev = self->batch->events[self->event_index];
×
NEW
60
        if (!ev.args.exists()) {
×
NEW
61
            Py_RETURN_NONE;
×
62
        }
63
        JsonDictValueObject *obj =
NEW
64
            (JsonDictValueObject *)JsonDictValueType.tp_alloc(
×
65
                &JsonDictValueType, 0);
NEW
66
        if (!obj) return NULL;
×
NEW
67
        new (&obj->batch) std::shared_ptr<JsonDictBatch>(self->batch);
×
NEW
68
        obj->event_index = self->event_index;
×
NEW
69
        obj->is_args = true;
×
NEW
70
        return (PyObject *)obj;
×
71
    }
72

NEW
73
    const auto &map = get_map(self);
×
NEW
74
    auto proxy = map[k];
×
NEW
75
    if (!proxy.exists()) {
×
NEW
76
        PyErr_SetObject(PyExc_KeyError, key);
×
UNCOV
77
        return NULL;
×
78
    }
79

NEW
80
    const auto &raw = map.raw();
×
NEW
81
    auto it = raw.find(k);
×
NEW
82
    if (it == raw.end()) {
×
NEW
83
        PyErr_SetObject(PyExc_KeyError, key);
×
UNCOV
84
        return NULL;
×
85
    }
NEW
86
    return args_value_to_pyobject(it->second);
×
87
}
88

NEW
89
static PyObject *JsonDictValue_keys(JsonDictValueObject *self,
×
90
                                    PyObject *Py_UNUSED(ignored)) {
NEW
91
    PyObject *list = PyList_New(0);
×
NEW
92
    if (!list) return NULL;
×
93

NEW
94
    const auto &map = get_map(self);
×
NEW
95
    map.for_each_member([&](std::string_view k, ArgsValueProxy) {
×
NEW
96
        PyObject *key = PyUnicode_FromStringAndSize(k.data(), k.size());
×
NEW
97
        if (key) {
×
NEW
98
            PyList_Append(list, key);
×
99
            Py_DECREF(key);
100
        }
NEW
101
    });
×
102

NEW
103
    if (!self->is_args) {
×
NEW
104
        auto &ev = self->batch->events[self->event_index];
×
NEW
105
        if (ev.args.exists()) {
×
NEW
106
            PyObject *args_key = PyUnicode_InternFromString("args");
×
NEW
107
            if (args_key) {
×
NEW
108
                PyList_Append(list, args_key);
×
109
                Py_DECREF(args_key);
110
            }
111
        }
112
    }
113

NEW
114
    return list;
×
115
}
116

NEW
117
static PyObject *JsonDictValue_values(JsonDictValueObject *self,
×
118
                                      PyObject *Py_UNUSED(ignored)) {
NEW
119
    PyObject *list = PyList_New(0);
×
NEW
120
    if (!list) return NULL;
×
121

NEW
122
    const auto &map = get_map(self);
×
NEW
123
    for (const auto &[k, v] : map.raw()) {
×
NEW
124
        PyObject *val = args_value_to_pyobject(v);
×
NEW
125
        if (val) {
×
NEW
126
            PyList_Append(list, val);
×
127
            Py_DECREF(val);
128
        }
129
    }
130

NEW
131
    if (!self->is_args) {
×
NEW
132
        auto &ev = self->batch->events[self->event_index];
×
NEW
133
        if (ev.args.exists()) {
×
134
            JsonDictValueObject *args_obj =
NEW
135
                (JsonDictValueObject *)JsonDictValueType.tp_alloc(
×
136
                    &JsonDictValueType, 0);
NEW
137
            if (args_obj) {
×
NEW
138
                new (&args_obj->batch)
×
NEW
139
                    std::shared_ptr<JsonDictBatch>(self->batch);
×
NEW
140
                args_obj->event_index = self->event_index;
×
NEW
141
                args_obj->is_args = true;
×
NEW
142
                PyList_Append(list, (PyObject *)args_obj);
×
143
                Py_DECREF(args_obj);
144
            }
145
        }
146
    }
147

NEW
148
    return list;
×
149
}
150

NEW
151
static PyObject *JsonDictValue_items(JsonDictValueObject *self,
×
152
                                     PyObject *Py_UNUSED(ignored)) {
NEW
153
    PyObject *list = PyList_New(0);
×
NEW
154
    if (!list) return NULL;
×
155

NEW
156
    const auto &map = get_map(self);
×
NEW
157
    for (const auto &[k, v] : map.raw()) {
×
NEW
158
        PyObject *key = PyUnicode_FromStringAndSize(k.data(), k.size());
×
NEW
159
        PyObject *val = args_value_to_pyobject(v);
×
NEW
160
        if (key && val) {
×
NEW
161
            PyObject *tuple = PyTuple_Pack(2, key, val);
×
NEW
162
            if (tuple) {
×
NEW
163
                PyList_Append(list, tuple);
×
164
                Py_DECREF(tuple);
165
            }
166
        }
NEW
167
        Py_XDECREF(key);
×
NEW
168
        Py_XDECREF(val);
×
169
    }
170

NEW
171
    if (!self->is_args) {
×
NEW
172
        auto &ev = self->batch->events[self->event_index];
×
NEW
173
        if (ev.args.exists()) {
×
NEW
174
            PyObject *args_key = PyUnicode_InternFromString("args");
×
175
            JsonDictValueObject *args_obj =
NEW
176
                (JsonDictValueObject *)JsonDictValueType.tp_alloc(
×
177
                    &JsonDictValueType, 0);
NEW
178
            if (args_key && args_obj) {
×
NEW
179
                new (&args_obj->batch)
×
NEW
180
                    std::shared_ptr<JsonDictBatch>(self->batch);
×
NEW
181
                args_obj->event_index = self->event_index;
×
NEW
182
                args_obj->is_args = true;
×
183
                PyObject *tuple =
NEW
184
                    PyTuple_Pack(2, args_key, (PyObject *)args_obj);
×
NEW
185
                if (tuple) {
×
NEW
186
                    PyList_Append(list, tuple);
×
187
                    Py_DECREF(tuple);
188
                }
189
            }
NEW
190
            Py_XDECREF(args_key);
×
NEW
191
            Py_XDECREF((PyObject *)args_obj);
×
192
        }
193
    }
194

NEW
195
    return list;
×
196
}
197

NEW
198
static PyObject *JsonDictValue_get(JsonDictValueObject *self, PyObject *args) {
×
199
    PyObject *key;
NEW
200
    PyObject *default_val = Py_None;
×
NEW
201
    if (!PyArg_ParseTuple(args, "O|O", &key, &default_val)) return NULL;
×
202

NEW
203
    const char *key_str = PyUnicode_AsUTF8(key);
×
NEW
204
    if (!key_str) return NULL;
×
205

NEW
206
    std::string_view k(key_str);
×
207

NEW
208
    if (!self->is_args && k == "args") {
×
NEW
209
        auto &ev = self->batch->events[self->event_index];
×
NEW
210
        if (!ev.args.exists()) {
×
NEW
211
            Py_INCREF(default_val);
×
NEW
212
            return default_val;
×
213
        }
214
        JsonDictValueObject *obj =
NEW
215
            (JsonDictValueObject *)JsonDictValueType.tp_alloc(
×
216
                &JsonDictValueType, 0);
NEW
217
        if (!obj) return NULL;
×
NEW
218
        new (&obj->batch) std::shared_ptr<JsonDictBatch>(self->batch);
×
NEW
219
        obj->event_index = self->event_index;
×
NEW
220
        obj->is_args = true;
×
NEW
221
        return (PyObject *)obj;
×
222
    }
223

NEW
224
    const auto &map = get_map(self);
×
NEW
225
    auto it = map.raw().find(k);
×
NEW
226
    if (it == map.raw().end()) {
×
NEW
227
        Py_INCREF(default_val);
×
NEW
228
        return default_val;
×
229
    }
NEW
230
    return args_value_to_pyobject(it->second);
×
231
}
232

233
static int JsonDictValue_contains(JsonDictValueObject *self, PyObject *key) {
120✔
234
    const char *key_str = PyUnicode_AsUTF8(key);
120!
235
    if (!key_str) return -1;
120✔
236

237
    std::string_view k(key_str);
120✔
238

239
    if (!self->is_args && k == "args") {
120!
NEW
240
        auto &ev = self->batch->events[self->event_index];
×
NEW
241
        return ev.args.exists() ? 1 : 0;
×
242
    }
243

244
    const auto &map = get_map(self);
120✔
245
    return map[k].exists() ? 1 : 0;
120!
246
}
60✔
247

248
static PyObject *JsonDictValue_to_dict(JsonDictValueObject *self,
40✔
249
                                       PyObject *Py_UNUSED(ignored)) {
250
    PyObject *dict = PyDict_New();
40✔
251
    if (!dict) return NULL;
40✔
252

253
    const auto &map = get_map(self);
40✔
254
    for (const auto &[k, v] : map.raw()) {
320✔
255
        PyObject *key = PyUnicode_FromStringAndSize(k.data(), k.size());
420!
256
        PyObject *val = args_value_to_pyobject(v);
280!
257
        if (!key || !val) {
280!
NEW
258
            Py_XDECREF(key);
×
NEW
259
            Py_XDECREF(val);
×
260
            Py_DECREF(dict);
NEW
261
            return NULL;
×
262
        }
263
        PyDict_SetItem(dict, key, val);
280!
264
        Py_DECREF(key);
140✔
265
        Py_DECREF(val);
140✔
266
    }
267

268
    if (!self->is_args) {
40✔
269
        auto &ev = self->batch->events[self->event_index];
40✔
270
        if (ev.args.exists()) {
40✔
271
            PyObject *args_dict = PyDict_New();
40✔
272
            if (!args_dict) {
40✔
273
                Py_DECREF(dict);
274
                return NULL;
×
275
            }
276
            for (const auto &[k, v] : ev.args.raw()) {
120✔
277
                PyObject *key = PyUnicode_FromStringAndSize(k.data(), k.size());
120!
278
                PyObject *val = args_value_to_pyobject(v);
80!
279
                if (!key || !val) {
80!
NEW
280
                    Py_XDECREF(key);
×
NEW
281
                    Py_XDECREF(val);
×
282
                    Py_DECREF(args_dict);
283
                    Py_DECREF(dict);
NEW
284
                    return NULL;
×
285
                }
286
                PyDict_SetItem(args_dict, key, val);
80!
287
                Py_DECREF(key);
40✔
288
                Py_DECREF(val);
40✔
289
            }
290
            PyDict_SetItemString(dict, "args", args_dict);
40✔
291
            Py_DECREF(args_dict);
20✔
292
        }
20✔
293
    }
20✔
294

295
    return dict;
40✔
296
}
20✔
297

298
static PyMappingMethods JsonDictValue_as_mapping = {
299
    (lenfunc)JsonDictValue_length,
300
    (binaryfunc)JsonDictValue_subscript,
301
    NULL,
302
};
303

304
static PySequenceMethods JsonDictValue_as_sequence = {
305
    NULL, NULL, NULL, NULL,
306
    NULL, NULL, NULL, (objobjproc)JsonDictValue_contains,
307
    NULL, NULL,
308
};
309

310
static PyMethodDef JsonDictValue_methods[] = {
311
    {"keys", (PyCFunction)JsonDictValue_keys, METH_NOARGS,
312
     "Return list of keys."},
313
    {"values", (PyCFunction)JsonDictValue_values, METH_NOARGS,
314
     "Return list of values."},
315
    {"items", (PyCFunction)JsonDictValue_items, METH_NOARGS,
316
     "Return list of (key, value) pairs."},
317
    {"get", (PyCFunction)JsonDictValue_get, METH_VARARGS,
318
     "Get value by key with optional default."},
319
    {"to_dict", (PyCFunction)JsonDictValue_to_dict, METH_NOARGS,
320
     "Convert to a regular Python dict."},
321
    {NULL}};
322

323
PyTypeObject JsonDictValueType = {
324
    PyVarObject_HEAD_INIT(NULL, 0) "dftracer_utils_ext.JsonDictValue",
325
    sizeof(JsonDictValueObject),       /* tp_basicsize */
326
    0,                                 /* tp_itemsize */
327
    (destructor)JsonDictValue_dealloc, /* tp_dealloc */
328
    0,                                 /* tp_vectorcall_offset */
329
    0,                                 /* tp_getattr */
330
    0,                                 /* tp_setattr */
331
    0,                                 /* tp_as_async */
332
    0,                                 /* tp_repr */
333
    0,                                 /* tp_as_number */
334
    &JsonDictValue_as_sequence,        /* tp_as_sequence */
335
    &JsonDictValue_as_mapping,         /* tp_as_mapping */
336
    0,                                 /* tp_hash */
337
    0,                                 /* tp_call */
338
    0,                                 /* tp_str */
339
    0,                                 /* tp_getattro */
340
    0,                                 /* tp_setattro */
341
    0,                                 /* tp_as_buffer */
342
    Py_TPFLAGS_DEFAULT,                /* tp_flags */
343
    "Zero-copy wrapper over a parsed DFTracer JSON event.\n"
344
    "Supports dict-like access: event['name'], event['args']['ret'].\n"
345
    "Call .to_dict() to materialize a regular Python dict.",
346
    0,                     /* tp_traverse */
347
    0,                     /* tp_clear */
348
    0,                     /* tp_richcompare */
349
    0,                     /* tp_weaklistoffset */
350
    0,                     /* tp_iter */
351
    0,                     /* tp_iternext */
352
    JsonDictValue_methods, /* tp_methods */
353
};
354

355
int init_json_dict_value(PyObject *m) {
2✔
356
    if (PyType_Ready(&JsonDictValueType) < 0) return -1;
2✔
357
    Py_INCREF(&JsonDictValueType);
1✔
358
    if (PyModule_AddObject(m, "JsonDictValue", (PyObject *)&JsonDictValueType) <
2✔
359
        0) {
360
        Py_DECREF(&JsonDictValueType);
UNCOV
361
        return -1;
×
362
    }
363
    return 0;
2✔
364
}
1✔
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