Skip to content

Commit 67dc041

Browse files
fix(setup): out-of-memory error [backport 1.18] (#6804)
Backport 07f59ac from #6792 to 1.18. When running setup.py extensions with the CMake parameter "-j", it could potentially raise an out-of-memory error. If someone wants to expedite the ddtrace installation, they should manually set the "CMAKE_BUILD_PARALLEL_LEVEL" environment variable. ## Checklist - [X] Change(s) are motivated and described in the PR description. - [X] Testing strategy is described if automated tests are not included in the PR. - [X] Risk is outlined (performance impact, potential for breakage, maintainability, etc). - [X] Change is maintainable (easy to change, telemetry, documentation). - [X] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed. If no release note is required, add label `changelog/no-changelog`. - [X] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)). - [X] Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [x] Title is accurate. - [x] No unnecessary changes are introduced. - [x] Description motivates each change. - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes unless absolutely necessary. - [x] Testing strategy adequately addresses listed risk(s). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] Release note makes sense to a user of the library. - [x] Reviewer has explicitly acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment. - [x] 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) Co-authored-by: Alberto Vara <[email protected]>
1 parent 9c036b7 commit 67dc041

File tree

9 files changed

+26
-4
lines changed

9 files changed

+26
-4
lines changed

.github/workflows/build_deploy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ jobs:
7575
# `platform.mac_ver()` reports incorrect MacOS version at 11.0
7676
# See: https://stackoverflow.com/a/65402241
7777
CIBW_ENVIRONMENT_MACOS: SYSTEM_VERSION_COMPAT=0
78+
CMAKE_BUILD_PARALLEL_LEVEL: 12
7879

7980
- uses: actions/upload-artifact@v3
8081
with:

.github/workflows/build_python_3.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ jobs:
5353
CIBW_BUILD: ${{ inputs.cibw_build }}
5454
CIBW_SKIP: ${{ inputs.cibw_skip }}
5555
CIBW_PRERELEASE_PYTHONS: ${{ inputs.cibw_prerelease_pythons }}
56+
CMAKE_BUILD_PARALLEL_LEVEL: 12
5657

5758
- uses: actions/upload-artifact@v3
5859
with:

.github/workflows/system-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ jobs:
4242
# that make assertion on backend data. Using a fake key allow to run system tests on PR originating from forks.
4343
# If ever it's needed, a valid key exists in the repo, using ${{ secrets.DD_API_KEY }}
4444
DD_API_KEY: 1234567890abcdef1234567890abcdef
45+
CMAKE_BUILD_PARALLEL_LEVEL: 12
4546
steps:
4647
- name: Setup python 3.9
4748
if: needs.needs-run.outputs.outcome == 'success'

.github/workflows/test_frameworks.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
env:
3434
DD_PROFILING_ENABLED: true
3535
DD_TESTING_RAISE: true
36+
CMAKE_BUILD_PARALLEL_LEVEL: 12
3637
defaults:
3738
run:
3839
working-directory: bottle
@@ -80,6 +81,7 @@ jobs:
8081
env:
8182
# Regression test for DataDog/dd-trace-py/issues/5722
8283
DD_UNLOAD_MODULES_FROM_SITECUSTOMIZE: true
84+
CMAKE_BUILD_PARALLEL_LEVEL: 12
8385
defaults:
8486
run:
8587
working-directory: sanic
@@ -131,6 +133,7 @@ jobs:
131133
DD_DEBUGGER_EXPL_COVERAGE_DELETE_LINE_PROBES: 1 # Delete to speed up
132134
DD_DEBUGGER_EXPL_CONSERVATIVE: 1
133135
PYTHONPATH: ../ddtrace/tests/debugging/exploration/:.
136+
CMAKE_BUILD_PARALLEL_LEVEL: 12
134137
defaults:
135138
run:
136139
working-directory: django
@@ -194,6 +197,7 @@ jobs:
194197
DD_PROFILING_ENABLED: true
195198
DD_TESTING_RAISE: true
196199
PYTHONPATH: ../ddtrace/tests/debugging/exploration/:.
200+
CMAKE_BUILD_PARALLEL_LEVEL: 12
197201
defaults:
198202
run:
199203
working-directory: graphene
@@ -235,6 +239,7 @@ jobs:
235239
env:
236240
DD_TESTING_RAISE: true
237241
DD_PROFILING_ENABLED: true
242+
CMAKE_BUILD_PARALLEL_LEVEL: 12
238243
defaults:
239244
run:
240245
working-directory: fastapi
@@ -277,6 +282,7 @@ jobs:
277282
DD_TESTING_RAISE: true
278283
DD_PROFILING_ENABLED: true
279284
PYTHONPATH: ../ddtrace/tests/debugging/exploration/
285+
CMAKE_BUILD_PARALLEL_LEVEL: 12
280286
defaults:
281287
run:
282288
working-directory: flask
@@ -362,6 +368,7 @@ jobs:
362368
DD_TESTING_RAISE: true
363369
DD_PROFILING_ENABLED: true
364370
PYTHONPATH: ../ddtrace/tests/debugging/exploration/
371+
CMAKE_BUILD_PARALLEL_LEVEL: 12
365372
defaults:
366373
run:
367374
working-directory: mako
@@ -407,6 +414,7 @@ jobs:
407414
DD_TESTING_RAISE: true
408415
DD_PROFILING_ENABLED: true
409416
PYTHONPATH: ../ddtrace/tests/debugging/exploration/
417+
CMAKE_BUILD_PARALLEL_LEVEL: 12
410418
defaults:
411419
run:
412420
working-directory: starlette
@@ -447,6 +455,7 @@ jobs:
447455
env:
448456
DD_TESTING_RAISE: true
449457
DD_PROFILING_ENABLED: true
458+
CMAKE_BUILD_PARALLEL_LEVEL: 12
450459
defaults:
451460
run:
452461
working-directory: requests
@@ -485,6 +494,7 @@ jobs:
485494
env:
486495
DD_TESTING_RAISE: true
487496
DD_PROFILING_ENABLED: true
497+
CMAKE_BUILD_PARALLEL_LEVEL: 12
488498
defaults:
489499
run:
490500
working-directory: asyncpg
@@ -528,6 +538,7 @@ jobs:
528538
env:
529539
DD_TESTING_RAISE: true
530540
PYTHONPATH: ../ddtrace/tests/debugging/exploration/
541+
CMAKE_BUILD_PARALLEL_LEVEL: 12
531542
defaults:
532543
run:
533544
working-directory: pylons
@@ -570,6 +581,7 @@ jobs:
570581
env:
571582
DD_TESTING_RAISE: true
572583
# PYTHONPATH: ../ddtrace/tests/debugging/exploration/
584+
CMAKE_BUILD_PARALLEL_LEVEL: 12
573585
defaults:
574586
run:
575587
working-directory: gunicorn
@@ -604,6 +616,7 @@ jobs:
604616
DD_TESTING_RAISE: true
605617
DD_PROFILING_ENABLED: true
606618
PYTHONPATH: ../ddtrace/tests/debugging/exploration/
619+
CMAKE_BUILD_PARALLEL_LEVEL: 12
607620
defaults:
608621
run:
609622
working-directory: uwsgi

.gitlab/benchmarks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ variables:
1010
timeout: 1h
1111
script:
1212
- export REPORTS_DIR="$(pwd)/reports/" && (mkdir "${REPORTS_DIR}" || :)
13+
- export CMAKE_BUILD_PARALLEL_LEVEL=12
1314
- git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/".insteadOf "https://github.com/DataDog/"
1415
- git clone --branch dd-trace-py https://github.com/DataDog/relenv-microbenchmarking-platform /platform && cd /platform
1516
- ./steps/capture-hardware-software-info.sh

docs/spelling_wordlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,3 +251,4 @@ programmatically
251251
DES
252252
Blowfish
253253
Gitlab
254+
CMake
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
issues:
3+
- |
4+
When running setup.py extensions with the CMake parameter "-j", it could potentially raise an out-of-memory error.
5+
If someone wants to expedite the ddtrace installation, they should manually set the "CMAKE_BUILD_PARALLEL_LEVEL"
6+
environment variable.

riotfile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def select_pys(min_version=MIN_PYTHON_VERSION, max_version=MAX_PYTHON_VERSION):
101101
"DD_CIVISIBILITY_AGENTLESS_ENABLED": "1",
102102
"DD_CIVISIBILITY_CODE_COVERAGE_ENABLED": "1",
103103
"DD_CIVISIBILITY_ITR_ENABLED": "1",
104+
"CMAKE_BUILD_PARALLEL_LEVEL": "12",
104105
},
105106
venvs=[
106107
Venv(

setup.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,6 @@ def build_extension(self, ext):
345345
# DEV: -j is only supported in CMake 3.12+ only.
346346
if hasattr(self, "parallel") and self.parallel:
347347
build_args += ["-j{}".format(self.parallel)]
348-
else:
349-
# Let CMake determine the parallelism to use
350-
build_args += ["-j"]
351348
try:
352349
cmake_cmd_with_args = [cmake_command] + cmake_args
353350
subprocess.run(cmake_cmd_with_args, cwd=tmp_iast_path, check=True)
@@ -462,7 +459,7 @@ def get_exts_for(name):
462459
)
463460

464461
if sys.version_info >= (3, 6, 0):
465-
ext_modules.append(Extension("ddtrace.appsec.iast._taint_tracking._native", sources=[], parallel=8))
462+
ext_modules.append(Extension("ddtrace.appsec.iast._taint_tracking._native", sources=[]))
466463
else:
467464
ext_modules = []
468465

0 commit comments

Comments
 (0)