Skip to content
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

feat(profiling): add experimental outside-in stack sampling method (stack v2) #8471

Merged
merged 115 commits into from
Mar 5, 2024

Conversation

sanchda
Copy link
Contributor

@sanchda sanchda commented Feb 21, 2024

This allows users to optionally use a new stack sampling technique. Briefly,

  • Avoids issues in Python 3.11 and later where the C struct backing Python frame objects may contain invalid pointers (causing segfaults within standard API calls)
  • Addresses a bias in the "normal" stack sampler where we had a tendency to sample threads only at the points where they transitioned off-GIL
  • Hopefully removes some serialization overhead, although in the first few versions the overall consumption of this technique may be higher.

There are a few tests around the new code, those will be added to CI in a later update.

Checklist

  • Change(s) are motivated and described in the PR description
  • Testing strategy is described if automated tests are not included in the PR
  • Risks are described (performance impact, potential for breakage, maintainability)
  • Change is maintainable (easy to change, telemetry, documentation)
  • Library release note guidelines are followed or label changelog/no-changelog is set
  • Documentation is included (in-code, generated user docs, public corp docs)
  • Backport labels are set (if applicable)
  • If this PR changes the public interface, I've notified @DataDog/apm-tees.
  • If change touches code that signs or publishes builds or packages, or handles credentials of any kind, I've requested a review from @DataDog/security-design-and-guidance.

Reviewer Checklist

  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Description motivates each change
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Change is maintainable (easy to change, telemetry, documentation)
  • Release note makes sense to a user of the library
  • 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

@sanchda sanchda changed the title Title TBD, but something something stack v2 something profiling profiling faster, and then some emojis I don't know I'm not very good at this template I should probably read the standard more carefully feat(profiling): add experimental outside-in stack sampling method (stack v2) Feb 21, 2024
Moved things around to streamline the build process a bit.  Also
discovered that recent changes were leaking intermediate artifacts into
the final .whl, which was causing auditwheel issues when the .so.debug
from libdatadog was being inspected.
@sanchda sanchda requested a review from P403n1x87 February 27, 2024 07:21
@sanchda sanchda disabled auto-merge March 4, 2024 16:06
@sanchda sanchda enabled auto-merge (squash) March 4, 2024 16:06
@sanchda sanchda merged commit 33d0af1 into main Mar 5, 2024
158 checks passed
@sanchda sanchda deleted the sanchda/profiling_stack_v2 branch March 5, 2024 17:52
Copy link
Contributor

github-actions bot commented Mar 7, 2024

The backport to 2.7 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.7 2.7
# Navigate to the new working tree
cd .worktrees/backport-2.7
# Create a new branch
git switch --create backport-8471-to-2.7
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 33d0af1c205f512858179d13306caf2dea0c414d
# Push it to GitHub
git push --set-upstream origin backport-8471-to-2.7
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.7

Then, create a pull request where the base branch is 2.7 and the compare/head branch is backport-8471-to-2.7.

sanchda added a commit that referenced this pull request Mar 7, 2024
…tack v2) (#8471)

This allows users to optionally use a new stack sampling technique.
Briefly,

* Avoids issues in Python 3.11 and later where the C struct backing
Python frame objects may contain invalid pointers (causing segfaults
within standard API calls)
* Addresses a bias in the "normal" stack sampler where we had a tendency
to sample threads only at the points where they transitioned off-GIL
* Hopefully removes some serialization overhead, although in the first
few versions the overall consumption of this technique may be higher.

There are a few tests around the new code, those will be added to CI in
a later update.

- [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] Risks are described (performance impact, potential for breakage,
maintainability)
- [x] Change is maintainable (easy to change, telemetry, documentation)
- [x] [Library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
are followed or label `changelog/no-changelog` is set
- [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))
- [x] If this PR changes the public interface, I've notified
`@DataDog/apm-tees`.
- [x] If change touches code that signs or publishes builds or packages,
or handles credentials of any kind, I've requested a review from
`@DataDog/security-design-and-guidance`.

- [x] Title is accurate
- [x] All changes are related to the pull request's stated goal
- [x] Description motivates each change
- [x] Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- [x] Testing strategy adequately addresses listed risks
- [x] Change is maintainable (easy to change, telemetry, documentation)
- [x] Release note makes sense to a user of the library
- [x] Author has 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: sanchda <[email protected]>
Co-authored-by: Gabriele N. Tornetta <[email protected]>
Co-authored-by: Tahir H. Butt <[email protected]>
(cherry picked from commit 33d0af1)
Copy link
Contributor

github-actions bot commented Mar 7, 2024

The backport to 2.7 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.7 2.7
# Navigate to the new working tree
cd .worktrees/backport-2.7
# Create a new branch
git switch --create backport-8471-to-2.7
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 33d0af1c205f512858179d13306caf2dea0c414d
# Push it to GitHub
git push --set-upstream origin backport-8471-to-2.7
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.7

Then, create a pull request where the base branch is 2.7 and the compare/head branch is backport-8471-to-2.7.

sanchda added a commit that referenced this pull request Mar 7, 2024
…ackport #8471 to 2.7] (#8635)

Backport of #8471 to 2.7

This allows users to optionally use a new stack sampling technique.
Briefly,

* Avoids issues in Python 3.11 and later where the C struct backing
Python frame objects may contain invalid pointers (causing segfaults
within standard API calls)
* Addresses a bias in the "normal" stack sampler where we had a tendency
to sample threads only at the points where they transitioned off-GIL
* Hopefully removes some serialization overhead, although in the first
few versions the overall consumption of this technique may be higher.

There are a few tests around the new code, those will be added to CI in
a later update.

## 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] Risks are described (performance impact, potential for breakage,
maintainability)
- [x] Change is maintainable (easy to change, telemetry, documentation)
- [x] [Library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
are followed or label `changelog/no-changelog` is set
- [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))
- [x] If this PR changes the public interface, I've notified
`@DataDog/apm-tees`.
- [x] If change touches code that signs or publishes builds or packages,
or handles credentials of any kind, I've requested a review from
`@DataDog/security-design-and-guidance`.

## Reviewer Checklist

- [x] Title is accurate
- [x] All changes are related to the pull request's stated goal
- [x] Description motivates each change
- [x] Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- [x] Testing strategy adequately addresses listed risks
- [x] Change is maintainable (easy to change, telemetry, documentation)
- [x] Release note makes sense to a user of the library
- [x] Author has 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)
sanchda added a commit that referenced this pull request Mar 7, 2024
…ackport #8471 to 2.7] (#8636)

Backport of #8615 to 2.7

This fixes a few defects in how the ddup and stack_v2 native extensions
permitted failure.

It also modifies the cmake invocation in setup.py so as to use the one
provided by the `cmake` module we already depended upon. I thought the
old way would have given it to us, but it appears as though the 2.7.1
release revealed the profiling-related native extensions failed to
build.

## 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] Risks are described (performance impact, potential for breakage,
maintainability)
- [x] Change is maintainable (easy to change, telemetry, documentation)
- [x] [Library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
are followed or label `changelog/no-changelog` is set
- [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))
- [x] If this PR changes the public interface, I've notified
`@DataDog/apm-tees`.
- [x] If change touches code that signs or publishes builds or packages,
or handles credentials of any kind, I've requested a review from
`@DataDog/security-design-and-guidance`.

## Reviewer Checklist

- [x] Title is accurate
- [x] All changes are related to the pull request's stated goal
- [x] Description motivates each change
- [x] Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- [x] Testing strategy adequately addresses listed risks
- [x] Change is maintainable (easy to change, telemetry, documentation)
- [x] Release note makes sense to a user of the library
- [x] Author has 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: sanchda <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Profiling Continous Profling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants