Skip to content

Commit 3b50116

Browse files
committed
fix(profiling): resolve clang-tidy issues
1 parent 429522c commit 3b50116

3 files changed

Lines changed: 17 additions & 11 deletions

File tree

ddtrace/internal/datadog/profiling/stack/fuzz/fuzz_echion_stacks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
5050
tstate.datastack_chunk = reinterpret_cast<_PyStackChunk*>(p2);
5151
#endif
5252
FrameStack fuzz_stack;
53-
unwind_python_stack(echion_sampler, &tstate, fuzz_stack, max_task_frames);
53+
unwind_python_stack(echion_sampler, &tstate, fuzz_stack, max_stack_discovery_depth);
5454
}
5555

5656
g_data = nullptr;

ddtrace/internal/datadog/profiling/stack/fuzz/fuzz_echion_task_unwind.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
3434
auto maybe_task = TaskInfo::create(echion_sampler, reinterpret_cast<TaskObj*>(p0));
3535
if (maybe_task) {
3636
FrameStack stack;
37-
(void)(*maybe_task)->unwind(echion_sampler, stack, using_uvloop);
37+
(void)(*maybe_task)->unwind(echion_sampler, stack, using_uvloop, max_stack_discovery_depth);
3838
}
3939

4040
g_data = nullptr;

ddtrace/internal/datadog/profiling/stack/src/echion/threads.cc

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,9 @@ ThreadInfo::unwind_tasks(EchionSampler& echion, PyThreadState* tstate)
268268
if (auto it = task_coro_stacks.find(task.origin); it != task_coro_stacks.end()) {
269269
const auto& cached = it->second;
270270
const size_t frames_to_push = std::min(cached.frames.size(), max_frames - task_frames.size());
271-
task_frames.insert(task_frames.end(), cached.frames.begin(), cached.frames.begin() + frames_to_push);
271+
task_frames.insert(task_frames.end(),
272+
cached.frames.begin(),
273+
cached.frames.begin() + static_cast<FrameStack::difference_type>(frames_to_push));
272274
if (task.is_on_cpu) {
273275
has_on_cpu_task = true;
274276
on_cpu_task_depth = cached.depth;
@@ -325,7 +327,8 @@ ThreadInfo::unwind_tasks(EchionSampler& echion, PyThreadState* tstate)
325327
size_t task_locations = 0;
326328
const size_t task_to_keep = select_frame_prefix(task_frames, 0, task_frames.size(), max_frames, task_locations);
327329
const bool task_truncated = task_collection_full || task_to_keep < task_frames.size();
328-
task_frames.erase(task_frames.begin() + task_to_keep, task_frames.end());
330+
task_frames.erase(task_frames.begin() + static_cast<FrameStack::difference_type>(task_to_keep),
331+
task_frames.end());
329332

330333
// Task frames receive the reporting budget first. If capacity remains,
331334
// fill it with physical context. For an on-CPU task, split that context
@@ -359,24 +362,26 @@ ThreadInfo::unwind_tasks(EchionSampler& echion, PyThreadState* tstate)
359362
if ((leaf_truncated || runtime_truncated) && locations >= max_frames) {
360363
if (runtime_to_keep > 0) {
361364
runtime_to_keep--;
362-
locations -= rendered_location_count(python_stack[runtime_start + runtime_to_keep]);
363365
} else if (leaf_to_keep > 0) {
364366
leaf_to_keep--;
365-
locations -= rendered_location_count(python_stack[leaf_to_keep]);
366367
}
367368
leaf_truncated = leaf_depth > leaf_to_keep;
368369
runtime_truncated = runtime_available > runtime_to_keep;
369370
}
370371

371-
stack.insert(stack.end(), python_stack.begin(), python_stack.begin() + leaf_to_keep);
372+
stack.insert(stack.end(),
373+
python_stack.begin(),
374+
python_stack.begin() + static_cast<FrameStack::difference_type>(leaf_to_keep));
372375
if (leaf_truncated) {
373376
stack_info->omission_index = stack.size();
374377
stack_info->omitted_frames = leaf_depth - leaf_to_keep;
375378
}
376379
stack.insert(stack.end(), task_frames.begin(), task_frames.end());
380+
const auto runtime_begin =
381+
python_stack.begin() + static_cast<FrameStack::difference_type>(runtime_start);
377382
stack.insert(stack.end(),
378-
python_stack.begin() + runtime_start,
379-
python_stack.begin() + runtime_start + runtime_to_keep);
383+
runtime_begin,
384+
runtime_begin + static_cast<FrameStack::difference_type>(runtime_to_keep));
380385
if (!leaf_truncated && runtime_truncated) {
381386
stack_info->omission_index = stack.size();
382387
stack_info->omitted_frames = runtime_available - runtime_to_keep;
@@ -387,11 +392,12 @@ ThreadInfo::unwind_tasks(EchionSampler& echion, PyThreadState* tstate)
387392
bool sync_truncated = python_stack.size() > sync_to_keep;
388393
if (sync_truncated && locations >= max_frames && sync_to_keep > 0) {
389394
sync_to_keep--;
390-
locations -= rendered_location_count(python_stack[sync_to_keep]);
391395
}
392396

393397
stack = std::move(task_frames);
394-
stack.insert(stack.end(), python_stack.begin(), python_stack.begin() + sync_to_keep);
398+
stack.insert(stack.end(),
399+
python_stack.begin(),
400+
python_stack.begin() + static_cast<FrameStack::difference_type>(sync_to_keep));
395401
if (sync_truncated) {
396402
stack_info->omission_index = stack.size();
397403
stack_info->omitted_frames = python_stack.size() - sync_to_keep;

0 commit comments

Comments
 (0)