Skip to content

perf(profiling): speed up stack walking by using function run_time_cache - #1998

Merged
morrisonlevi merged 28 commits into
masterfrom
levi/run-time-cache
Jul 25, 2023
Merged

perf(profiling): speed up stack walking by using function run_time_cache #1998
morrisonlevi merged 28 commits into
masterfrom
levi/run-time-cache

Conversation

@morrisonlevi

@morrisonlevi morrisonlevi commented Mar 31, 2023

Copy link
Copy Markdown
Collaborator

Description

This essentially re-applies #1949, with some changes:

  • Exclude accessing the run_time_cache on calls with trampolines, which causes a crash, see [BUG] Profiling SIGSEGV in 0.86.0 #1993.
  • Massage the source of has_invalid_run_time_cache to get good codegen out of it.
  • Fix a typo I kept making (stalk_walking instead of stack-walking). Reverted so performance can be more easily be compared when using native profiler.
  • Reset the string table on each request, preventing the table from unbounded memory growth across request.
    • Exclude the CLI from using the run_time_cache optimization, since it only has 1 PHP request and is often long lived.

Despite fixing the sigsegv and taking precautions about unbounded memory growth, I think we need to be cautious about rolling this out.

Readiness checklist

  • Changelog has been added to the release document.
  • Tests added for this feature/bug.

Reviewer checklist

  • Appropriate labels assigned.
  • Milestone is set.

@morrisonlevi morrisonlevi added ☠️ do-not-merge/WIP Overhead Relates to latency, CPU, or memory overhead profiling Relates to the Continuous Profiler labels Mar 31, 2023
@morrisonlevi morrisonlevi added this to the future milestone Mar 31, 2023
@morrisonlevi
morrisonlevi force-pushed the levi/run-time-cache branch 2 times, most recently from 44cb575 to d3c1224 Compare April 20, 2023 16:58
Comment thread profiling/src/php_ffi.c Outdated
@pr-commenter

pr-commenter Bot commented Jun 22, 2023

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2023-07-24 06:52:04

Comparing candidate commit 6b9104f in PR branch levi/run-time-cache with baseline commit afbd2db in branch master.

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

scenario:walk_stack/1

  • 🟩 wall_time [-11.371µs; -11.368µs] or [-60.302%; -60.289%]

scenario:walk_stack/50

  • 🟩 wall_time [-12.510µs; -12.507µs] or [-59.866%; -59.850%]

scenario:walk_stack/99

  • 🟩 wall_time [-12.618µs; -12.616µs] or [-60.098%; -60.087%]

scenario:walk_stack_instructions/1

  • 🟩 instructions [-102.7K instructions; -102.7K instructions] or [-66.134%; -66.121%]

scenario:walk_stack_instructions/50

  • 🟩 instructions [-99.0K instructions; -99.0K instructions] or [-65.308%; -65.303%]

scenario:walk_stack_instructions/99

  • 🟩 instructions [-98.8K instructions; -98.8K instructions] or [-65.266%; -65.265%]

Comment thread profiling/Cargo.toml Outdated
Comment thread profiling/Cargo.toml Outdated
@morrisonlevi
morrisonlevi force-pushed the levi/run-time-cache branch from bedd8f8 to f17b9cd Compare July 20, 2023 22:45
@morrisonlevi
morrisonlevi marked this pull request as ready for review July 21, 2023 15:14
@morrisonlevi
morrisonlevi requested review from a team as code owners July 21, 2023 15:14
@morrisonlevi morrisonlevi modified the milestones: future, 0.91.0 Jul 21, 2023
@morrisonlevi
morrisonlevi requested a review from bwoebi July 21, 2023 15:17
morrisonlevi and others added 2 commits July 21, 2023 16:48
Bob thinks the 100% prediction on the branch for
`ddog_php_prof_run_time_cache_handle < 0` is worth moving it out of
the other bitwise-ors. I am indifferent, so switching it.
@morrisonlevi
morrisonlevi merged commit f4e9591 into master Jul 25, 2023
@morrisonlevi
morrisonlevi deleted the levi/run-time-cache branch July 25, 2023 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

☠️ do-not-merge/WIP Overhead Relates to latency, CPU, or memory overhead profiling Relates to the Continuous Profiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants