Skip to content

chore: implement rudimentary CMake incremental build #13652

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

P403n1x87
Copy link
Contributor

@P403n1x87 P403n1x87 commented Jun 11, 2025

We speed-up the build process for local development when CMake sources are not changed in between build runs. This reduces the build time from ~3 minutes to ~20 seconds. The feature is behind the DD_CMAKE_INCREMENTAL_BUILD flag. When running tests locally with riot, one would have to make sure that the variable is set in the environment, e.g.

DD_CMAKE_INCREMENTAL_BUILD=1 riot -v run ...

Note

This is just a temporary workaround. Long-term we would want to migrate away from CMake as much as possible to reduce the complexity inside setup.py.

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

@P403n1x87 P403n1x87 added the changelog/no-changelog A changelog entry is not required for this PR. label Jun 11, 2025
Copy link
Contributor

CODEOWNERS have been resolved as:

setup.py                                                                @DataDog/python-guild

Copy link
Contributor

github-actions bot commented Jun 11, 2025

Bootstrap import analysis

Comparison of import times between this PR and base.

Summary

The average import time from this PR is: 274 ± 2 ms.

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

The import time difference between this PR and base is: -1.4 ± 0.1 ms.

Import time breakdown

The following import paths have shrunk:

ddtrace.auto 1.956 ms (0.71%)
ddtrace.bootstrap.sitecustomize 1.276 ms (0.46%)
ddtrace.bootstrap.preload 1.276 ms (0.46%)
ddtrace.internal.remoteconfig.client 0.622 ms (0.23%)
ddtrace 0.680 ms (0.25%)
ddtrace.internal._unpatched 0.031 ms (0.01%)
json 0.031 ms (0.01%)
json.decoder 0.031 ms (0.01%)
re 0.031 ms (0.01%)
enum 0.031 ms (0.01%)
types 0.031 ms (0.01%)

@pr-commenter
Copy link

pr-commenter bot commented Jun 11, 2025

Benchmarks

Benchmark execution time: 2025-06-12 14:32:05

Comparing candidate commit e74ebb6 in PR branch chore/cmake-incremental-builds with baseline commit fd2bcdf in branch main.

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

scenario:iastaspects-upper_aspect

  • 🟥 execution_time [+185.178ns; +222.014ns] or [+8.207%; +9.839%]

scenario:telemetryaddmetric-1-gauge-metric-1-times

  • 🟥 execution_time [+246.144ns; +298.676ns] or [+11.600%; +14.075%]

@P403n1x87 P403n1x87 force-pushed the chore/cmake-incremental-builds branch from c73aa78 to 6b318e4 Compare June 12, 2025 07:31
@P403n1x87 P403n1x87 marked this pull request as ready for review June 12, 2025 07:31
@P403n1x87 P403n1x87 requested a review from a team as a code owner June 12, 2025 07:31
@P403n1x87 P403n1x87 enabled auto-merge (squash) June 12, 2025 07:31
@P403n1x87
Copy link
Contributor Author

Total time: 16.69s
Environment:
	CARGO_BUILD_JOBS: unset
	CMAKE_BUILD_PARALLEL_LEVEL: unset
	DD_COMPILE_MODE: Release
	DD_USE_SCCACHE: False
	DD_FAST_BUILD: False
Extension build times:
	Total: 10.22s (61.24%)
	ddtrace.internal._encoding: 2.22s (13.28%)
	ddtrace.profiling.collector.stack: 1.80s (10.79%)
	ddtrace.profiling.collector._task: 0.80s (4.82%)
	ddtrace.internal.telemetry.metrics_namespaces: 0.76s (4.52%)
	ddtrace.profiling._threading: 0.63s (3.79%)
	ddtrace.internal._tagset: 0.61s (3.66%)
	ddtrace.profiling.collector._traceback: 0.56s (3.35%)
	ddtrace.vendor.psutil._psutil_posix: 0.53s (3.17%)
	ddtrace.vendor.psutil._psutil_osx: 0.52s (3.13%)
	ddtrace.profiling.collector._memalloc: 0.51s (3.06%)
	ddtrace.internal._threads: 0.40s (2.38%)
	ddtrace.internal._rand: 0.35s (2.08%)
	ddtrace.internal.native._native: 0.23s (1.36%)
	ddtrace.appsec._iast._ast.iastpatch: 0.16s (0.96%)
	ddtrace.appsec._iast._stacktrace: 0.14s (0.82%)
	ddtrace.appsec._iast._taint_tracking._native: 0.01s (0.04%)
	ddtrace.internal.datadog.profiling.stack_v2._stack_v2: 0.00s (0.01%)
	ddtrace.internal.datadog.profiling.ddup._ddup: 0.00s (0.01%)
	ddtrace.internal.datadog.profiling.crashtracker._crashtracker: 0.00s (0.00%)

We speed-up the build process for local development when CMake sources
are not changed in between build runs.

This reduces the build time from about 3 minutes to about 20 seconds.
@P403n1x87 P403n1x87 force-pushed the chore/cmake-incremental-builds branch from 6b318e4 to 2d8b8c8 Compare June 12, 2025 07:56
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.

1 participant