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

Merged
merged 10 commits into from
Jun 18, 2025
Merged

ci: native extension hash cache #13675

merged 10 commits into from
Jun 18, 2025

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: 278 ± 4 ms.

The average import time from base is: 281 ± 4 ms.

The import time difference between this PR and base is: -2.6 ± 0.2 ms.

Import time breakdown

The following import paths have shrunk:

ddtrace.auto 2.050 ms (0.74%)
ddtrace.bootstrap.sitecustomize 1.376 ms (0.50%)
ddtrace.bootstrap.preload 1.376 ms (0.50%)
ddtrace.internal.remoteconfig.client 0.645 ms (0.23%)
ddtrace 0.673 ms (0.24%)
ddtrace.internal._unpatched 0.030 ms (0.01%)
json 0.030 ms (0.01%)
json.decoder 0.030 ms (0.01%)
re 0.030 ms (0.01%)
enum 0.030 ms (0.01%)
types 0.030 ms (0.01%)

@pr-commenter
Copy link

pr-commenter bot commented Jun 16, 2025

Benchmarks

Benchmark execution time: 2025-06-18 16:41:27

Comparing candidate commit 940abae in PR branch ci/ext-hash-cache with baseline commit be1b1b1 in branch main.

Found 0 performance improvements and 6 performance regressions! Performance is the same for 559 metrics, 7 unstable metrics.

scenario:iastaspects-format_map_aspect

  • 🟥 execution_time [+511.661ns; +577.105ns] or [+15.885%; +17.917%]

scenario:iastaspects-lower_aspect

  • 🟥 execution_time [+173.124ns; +229.473ns] or [+7.698%; +10.204%]

scenario:iastaspects-swapcase_aspect

  • 🟥 execution_time [+213.222ns; +255.002ns] or [+8.687%; +10.389%]

scenario:iastaspects-upper_aspect

  • 🟥 execution_time [+188.002ns; +240.862ns] or [+8.334%; +10.677%]

scenario:iastaspectsospath-ospathnormcase_aspect

  • 🟥 execution_time [+334.621ns; +389.227ns] or [+9.585%; +11.149%]

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

  • 🟥 execution_time [+259.974ns; +306.521ns] or [+12.166%; +14.344%]

@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
@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
@P403n1x87 P403n1x87 mentioned this pull request Jun 18, 2025
2 tasks
@P403n1x87 P403n1x87 merged commit 55dd9fb into main Jun 18, 2025
752 checks passed
@P403n1x87 P403n1x87 deleted the ci/ext-hash-cache branch June 18, 2025 16:42
juanjux pushed a commit that referenced this pull request Jun 20, 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
- [x] 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](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## 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](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
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](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
brettlangdon pushed a commit that referenced this pull request Jun 20, 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
- [x] 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](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## 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](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
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](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
sydney-tung pushed a commit that referenced this pull request Jun 24, 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
- [x] 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](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## 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](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
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](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
happynancee pushed a commit that referenced this pull request Jul 7, 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
- [x] 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](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## 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](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
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](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
alyshawang pushed a commit that referenced this pull request Jul 25, 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
- [x] 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](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## 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](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
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](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
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.

3 participants