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

try removing a dispatch_with_results call #11529

Draft
wants to merge 35 commits into
base: main
Choose a base branch
from

Conversation

emmettbutler
Copy link
Collaborator

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

@emmettbutler emmettbutler requested review from a team as code owners November 25, 2024 15:06
@emmettbutler emmettbutler marked this pull request as draft November 25, 2024 15:06
Copy link
Contributor

github-actions bot commented Nov 25, 2024

CODEOWNERS have been resolved as:

ddtrace/_trace/trace_handlers.py                                        @DataDog/apm-sdk-api-python
ddtrace/appsec/_asm_request_context.py                                  @DataDog/asm-python
ddtrace/appsec/_handlers.py                                             @DataDog/asm-python
ddtrace/appsec/_trace_utils.py                                          @DataDog/asm-python
ddtrace/contrib/dbapi/__init__.py                                       @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/dbapi_async/__init__.py                                 @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/aiomysql/patch.py                              @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/asgi/middleware.py                             @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/asyncpg/patch.py                               @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/django/patch.py                                @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/django/utils.py                                @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/flask/patch.py                                 @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/flask/wrappers.py                              @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/wsgi/wsgi.py                                   @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/ext/test_visibility/_utils.py                                   @DataDog/ci-app-libraries
ddtrace/ext/test_visibility/api.py                                      @DataDog/ci-app-libraries
ddtrace/internal/ci_visibility/recorder.py                              @DataDog/ci-app-libraries
ddtrace/internal/core/__init__.py                                       @DataDog/apm-core-python
ddtrace/internal/core/event_hub.py                                      @DataDog/apm-core-python
ddtrace/internal/test_visibility/_atr_mixins.py                         @DataDog/ci-app-libraries
ddtrace/internal/test_visibility/_efd_mixins.py                         @DataDog/ci-app-libraries
ddtrace/internal/test_visibility/_itr_mixins.py                         @DataDog/ci-app-libraries
ddtrace/internal/test_visibility/_utils.py                              @DataDog/ci-app-libraries
ddtrace/internal/test_visibility/api.py                                 @DataDog/ci-app-libraries
ddtrace/internal/utils/__init__.py                                      @DataDog/apm-core-python
ddtrace/propagation/_database_monitoring.py                             @DataDog/apm-sdk-api-python

@pr-commenter
Copy link

pr-commenter bot commented Nov 25, 2024

Benchmarks

Benchmark execution time: 2024-12-06 20:44:47

Comparing candidate commit 601f456 in PR branch emmett.butler/no-dispatch-with-results with baseline commit 00440f5 in branch main.

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

scenario:iast_aspects-ospathdirname_aspect

  • 🟥 execution_time [+555.925ns; +622.536ns] or [+15.258%; +17.086%]

scenario:iast_aspects-ospathsplitext_aspect

  • 🟥 execution_time [+417.076ns; +475.049ns] or [+11.352%; +12.930%]

@romainkomorn-exdatadog
Copy link
Contributor

I know this is a draft/WIP but I worry about the usage for this, where one could conceivably:

  • call get_item() without ever calling dispatch()
  • call dispatch(), call get_item(), then call get_item() a second time and get a possibly unexpectedly-stale result
  • runaway set_item()s could end up leaking memory (eg: set_item(f"my_unique_object_id"))

I like the idea of cleaning up the syntax around dispatch_with_results(), though, but I think its current approach makes sense, and I think anyone who wants to have behavior where the item isn't recomputed multiple times could (or should) implement a caching mechanism for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants