Skip to content

chore(profiling): explicitly set or clear NDEBUG for memalloc extension #13218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 16, 2025

Conversation

nsrip-dd
Copy link
Contributor

@nsrip-dd nsrip-dd commented Apr 16, 2025

The memalloc C extension has debug assert statements. We want them off
by default in case they guard a costly call we wouldn't normally want to
happen. Depending on how the CPython interpreter running setup.py was
built, we may already get -DNDEBUG via the CFLAGS from sysconfig, which
disables asserts. See the setuptools docs.

But rather than rely on that, make sure that asserts
are explicitly disabled for normal builds and explicitly enabled for
debug builds.

Checklist

  • PR author has checked that all the criteria below are met
  • The PR description includes an overview of the change
  • The PR description articulates the motivation for the change
  • The change includes tests OR the PR description describes a testing strategy
  • The PR description notes risks associated with the change, if any
  • Newly-added code is easy to change
  • The change follows the library release note guidelines
  • The change includes or references documentation updates if necessary
  • Backport labels are set (if applicable)

Reviewer Checklist

  • Reviewer has checked that all the criteria below are met
  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Newly-added code is easy to change
  • Release note makes sense to a user of the library
  • If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy

The memalloc C extension has debug assert statements. We want them off
by default in case they guard a costly call we wouldn't normally want to
happen. Depending on how the CPython interpreter running setup.py was
built, we may already get -DNDEBUG from the CFLAGS via sysconfig, which
disables asserts. But rather than rely on that, make sure that asserts
are explicitly disabled for normal builds and explicitly enabled for
debug builds.
@nsrip-dd nsrip-dd requested a review from a team as a code owner April 16, 2025 17:06
@nsrip-dd nsrip-dd requested a review from sanchda April 16, 2025 17:06
Copy link
Contributor

CODEOWNERS have been resolved as:

setup.py                                                                @DataDog/python-guild

@nsrip-dd nsrip-dd added the changelog/no-changelog A changelog entry is not required for this PR. label Apr 16, 2025
Copy link
Contributor

Bootstrap import analysis

Comparison of import times between this PR and base.

Summary

The average import time from this PR is: 232 ± 1 ms.

The average import time from base is: 233 ± 2 ms.

The import time difference between this PR and base is: -1.45 ± 0.07 ms.

Import time breakdown

The following import paths have shrunk:

ddtrace.auto 1.922 ms (0.83%)
ddtrace.bootstrap.sitecustomize 1.254 ms (0.54%)
ddtrace.bootstrap.preload 1.254 ms (0.54%)
ddtrace.internal.products 1.254 ms (0.54%)
ddtrace.internal.remoteconfig.client 0.608 ms (0.26%)
ddtrace 0.667 ms (0.29%)

@nsrip-dd nsrip-dd enabled auto-merge (squash) April 16, 2025 18:04
@pr-commenter
Copy link

pr-commenter bot commented Apr 16, 2025

Benchmarks

Benchmark execution time: 2025-04-16 18:09:36

Comparing candidate commit abd02d8 in PR branch nick.ripley/explicit-ndebug with baseline commit 002e5f9 in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 506 metrics, 2 unstable metrics.

@nsrip-dd nsrip-dd merged commit dc4cd33 into main Apr 16, 2025
760 of 763 checks passed
@nsrip-dd nsrip-dd deleted the nick.ripley/explicit-ndebug branch April 16, 2025 18:10
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