Skip to content

chore: simplify periodic thread implementation#19142

Open
P403n1x87 wants to merge 2 commits into
mainfrom
chore/simplfy-threads
Open

chore: simplify periodic thread implementation#19142
P403n1x87 wants to merge 2 commits into
mainfrom
chore/simplfy-threads

Conversation

@P403n1x87

Copy link
Copy Markdown
Contributor

Description

We simplify the implementation of native periodic threads by removing unnecessary defensive coding. The changes in #18921 provided the minimal fix required to fix a fork-related hang, with the defensive coding in #18636 and #18920 thus becoming redundant.

We simplify the implementation of native periodic threads by removing
unnecessary defensive coding. The changes in #18921 provided the minimal
fix required to fix a fork-related hang, with the defensive coding in
@P403n1x87 P403n1x87 added the changelog/no-changelog A changelog entry is not required for this PR. label Jul 17, 2026
@P403n1x87
P403n1x87 requested a review from r1viollet July 17, 2026 14:40
@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Codeowners resolved as

ddtrace/internal/_threads.cpp                                           @DataDog/apm-core-python
ddtrace/internal/threads.py                                             @DataDog/apm-core-python

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Jul 17, 2026

Copy link
Copy Markdown

Circular import analysis

⚠️ Existing circular imports

There are 45 circular imports that already exist on the base branch and have not been changed by this PR.

Show existing cycles (showing 5 of 45 shortest)
ddtrace.internal.core -> ddtrace._trace.span -> ddtrace.internal.core
ddtrace.internal.datastreams -> ddtrace.internal.datastreams.kombu -> ddtrace.internal.datastreams
ddtrace.internal.datastreams -> ddtrace.internal.datastreams.aiokafka -> ddtrace.internal.datastreams
ddtrace.internal.datastreams -> ddtrace.internal.datastreams.botocore -> ddtrace.internal.datastreams
ddtrace.internal.datastreams -> ddtrace.internal.datastreams.google_cloud_pubsub -> ddtrace.internal.datastreams

To see all cycles, download the cycles-base.json and cycles-pr.json artifacts from this CI job and run:

uv run --script scripts/import-analysis/cycles.py compare cycles-base.json cycles-pr.json

@pr-commenter

pr-commenter Bot commented Jul 17, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-07-17 15:53:04

Comparing candidate commit ba3350b in PR branch chore/simplfy-threads with baseline commit dc8538c in branch main.

Found 0 performance improvements and 5 performance regressions! Performance is the same for 612 metrics, 10 unstable metrics.

scenario:iastaspects-lstrip_aspect

  • 🟥 execution_time [+64.857µs; +72.774µs] or [+19.794%; +22.211%]

scenario:iastaspects-swapcase_aspect

  • 🟥 execution_time [+67.799µs; +76.998µs] or [+19.327%; +21.949%]

scenario:iastaspectsospath-ospathbasename_aspect

  • 🟥 execution_time [+108.152µs; +114.700µs] or [+24.826%; +26.329%]

scenario:span-start

  • 🟥 execution_time [+1.149ms; +1.311ms] or [+7.267%; +8.293%]

scenario:telemetryaddmetric-1-count-metric-1-times

  • 🟥 execution_time [+178.374ns; +214.702ns] or [+8.551%; +10.292%]

@datadog-official

datadog-official Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Pipelines  Tests

⚠️ Warnings

🚦 74 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-py | build linux serverless: [amd64, cp315-cp315, v113741238-d2b8243-manylinux2014_x86_64, 1]   View in Datadog   GitLab

DataDog/apm-reliability/dd-trace-py | build linux serverless: [arm64, cp315-cp315, v113741357-d2b8243-manylinux2014_aarch64, 1]   View in Datadog   GitLab

DataDog/apm-reliability/dd-trace-py | build linux serverless: [arm64, cp315-cp315, v113741589-d2b8243-musllinux_1_2_aarch64, 1]   View in Datadog   GitLab

View all 74 failed jobs.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: ba3350b | Docs | Datadog PR Page | Give us feedback!

@P403n1x87
P403n1x87 marked this pull request as ready for review July 17, 2026 15:51
@P403n1x87
P403n1x87 requested a review from a team as a code owner July 17, 2026 15:51
@P403n1x87
P403n1x87 requested a review from brettlangdon July 17, 2026 15:51

// Remove the thread from the mapping of active threads.
unregister_periodic_thread_if_self(state->periodic_threads, self->ident, (PyObject*)self);
PyDict_DelItem(state->periodic_threads, self->ident);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is still the same bug as before, no?

or the issue was one of the "remove from periodic thread" calls below that was deleted?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it was the one deleted in #18921

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/no-changelog A changelog entry is not required for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants