Skip to content

ci: native extension hash cache #13675

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 9 commits into
base: main
Choose a base branch
from
Open

ci: native extension hash cache #13675

wants to merge 9 commits into from

Conversation

P403n1x87
Copy link
Contributor

@P403n1x87 P403n1x87 commented Jun 16, 2025

We make the native extension cache more fine-grained by generating hashes for each single native integration that we build. We then store each generated artifact in the cache according to this FS structure

.ext_cache/           # Example:
└─ <module_name>/     #   "ddtrace.profiling.collector"
   └─ <source_hash>/  #   <sha256 hex digest>
      └─ <binary>     #   "collector.cpython-310-darwin.so"

We implement a custom command to allow retrieving the source to target mapping from setup.py directly, instead of coding the same information elsewhere, which would increase the maintenance cost of the whole build process.

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

Copy link
Contributor

github-actions bot commented Jun 16, 2025

CODEOWNERS have been resolved as:

scripts/gen_ext_cache_scripts.py                                        @DataDog/apm-core-python
.gitlab-ci.yml                                                          @DataDog/apm-core-python
scripts/gen_gitlab_config.py                                            @DataDog/apm-core-python
setup.py                                                                @DataDog/python-guild

Copy link
Contributor

github-actions bot commented Jun 16, 2025

Bootstrap import analysis

Comparison of import times between this PR and base.

Summary

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

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

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

Import time breakdown

The following import paths have shrunk:

ddtrace.auto 1.980 ms (0.72%)
ddtrace.bootstrap.sitecustomize 1.307 ms (0.48%)
ddtrace.bootstrap.preload 1.307 ms (0.48%)
ddtrace.internal.remoteconfig.client 0.629 ms (0.23%)
ddtrace 0.673 ms (0.25%)
ddtrace.internal._unpatched 0.032 ms (0.01%)
json 0.032 ms (0.01%)
json.decoder 0.032 ms (0.01%)
re 0.032 ms (0.01%)
enum 0.032 ms (0.01%)
types 0.032 ms (0.01%)

@pr-commenter
Copy link

pr-commenter bot commented Jun 16, 2025

Benchmarks

Benchmark execution time: 2025-06-17 19:21:57

Comparing candidate commit 7ea29ec in PR branch ci/ext-hash-cache with baseline commit 75b029a in branch main.

Found 0 performance improvements and 4 performance regressions! Performance is the same for 557 metrics, 3 unstable metrics.

scenario:iastaspectsospath-ospathbasename_aspect

  • 🟥 execution_time [+614.163ns; +775.184ns] or [+14.492%; +18.292%]

scenario:iastaspectsospath-ospathsplit_aspect

  • 🟥 execution_time [+756.817ns; +870.258ns] or [+15.648%; +17.994%]

scenario:iastaspectsospath-ospathsplitdrive_aspect

  • 🟥 execution_time [+388.873ns; +439.888ns] or [+10.712%; +12.117%]

scenario:telemetryaddmetric-1-distribution-metric-1-times

  • 🟥 execution_time [+312.824ns; +376.171ns] or [+10.758%; +12.937%]

@P403n1x87 P403n1x87 force-pushed the ci/ext-hash-cache branch from 6f2e103 to 51d40bd Compare June 16, 2025 13:05
Copy link
Member

@brettlangdon brettlangdon left a comment

Choose a reason for hiding this comment

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

high level looks good

@P403n1x87 P403n1x87 added changelog/no-changelog A changelog entry is not required for this PR. and removed backport 2.21 labels Jun 16, 2025
@P403n1x87 P403n1x87 force-pushed the ci/ext-hash-cache branch 2 times, most recently from 1318da0 to b792156 Compare June 16, 2025 16:22
We make the native extension cache more fine-grained by generating
hashes for each single native integration that we build.
@P403n1x87 P403n1x87 force-pushed the ci/ext-hash-cache branch from b792156 to 475f53f Compare June 16, 2025 16:34
@P403n1x87 P403n1x87 force-pushed the ci/ext-hash-cache branch from b9cc62e to f6b4c86 Compare June 17, 2025 10:03
@P403n1x87 P403n1x87 force-pushed the ci/ext-hash-cache branch from 9cc194d to 0ce8fda Compare June 17, 2025 14:52
@P403n1x87 P403n1x87 force-pushed the ci/ext-hash-cache branch from 0ce8fda to 74a8c35 Compare June 17, 2025 15:38
riot -v run -s --python=$PYTHON_VERSION smoke_test
touch cache_used.txt
apt update && apt install -y sccache
pip install riot==0.20.1
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps we can include riot in the cached venv?

@P403n1x87 P403n1x87 marked this pull request as ready for review June 17, 2025 18:38
@P403n1x87 P403n1x87 requested review from a team as code owners June 17, 2025 18:38
@P403n1x87 P403n1x87 enabled auto-merge (squash) June 17, 2025 18:38
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