Skip to content

refactor: encapsulate ALLOCATION_PROFILING_STATS for safety#3519

Merged
realFlowControl merged 2 commits intoflorian/stabilize-and-speedup-allocationsfrom
levi/stabilize-and-speedup-allocations
Dec 8, 2025
Merged

refactor: encapsulate ALLOCATION_PROFILING_STATS for safety#3519
realFlowControl merged 2 commits intoflorian/stabilize-and-speedup-allocationsfrom
levi/stabilize-and-speedup-allocations

Conversation

@morrisonlevi
Copy link
Copy Markdown
Collaborator

Description

Florian and I have been working to optimize the memory profiler in PR #3505, including writing some unsafe code. Rather than spreading the unsafe bits all over, I tried my hand at encapsulating them.

Now that ALLOCATION_PROFILING_STATS is private, and all public APIs do not allow the caller to keep references to it, we can say that allocation_profiling_stats_should_collect is safe. This does require that ginit and gshutdown were called correctly in the correct PHP lifecycle hooks, so I documented those and marked them unsafe as well.

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

@morrisonlevi morrisonlevi requested a review from a team as a code owner December 6, 2025 00:26
@pr-commenter
Copy link
Copy Markdown

pr-commenter Bot commented Dec 6, 2025

Benchmarks [ profiler ]

Benchmark execution time: 2025-12-06 00:35:51

Comparing candidate commit 22d474a in PR branch levi/stabilize-and-speedup-allocations with baseline commit df68409 in branch florian/stabilize-and-speedup-allocations.

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

@pr-commenter
Copy link
Copy Markdown

pr-commenter Bot commented Dec 6, 2025

Benchmarks [ tracer ]

Benchmark execution time: 2025-12-06 01:27:30

Comparing candidate commit 22d474a in PR branch levi/stabilize-and-speedup-allocations with baseline commit df68409 in branch florian/stabilize-and-speedup-allocations.

Found 3 performance improvements and 5 performance regressions! Performance is the same for 185 metrics, 1 unstable metrics.

scenario:ComposerTelemetryBench/benchTelemetryParsing-opcache

  • 🟩 execution_time [-1.557µs; -0.643µs] or [-11.451%; -4.726%]

scenario:MessagePackSerializationBench/benchMessagePackSerialization

  • 🟩 execution_time [-5.662µs; -4.538µs] or [-5.358%; -4.295%]

scenario:SamplingRuleMatchingBench/benchRegexMatching1

  • 🟥 execution_time [+91.587ns; +160.613ns] or [+7.825%; +13.723%]

scenario:SamplingRuleMatchingBench/benchRegexMatching2

  • 🟥 execution_time [+69.347ns; +145.853ns] or [+5.854%; +12.312%]

scenario:SamplingRuleMatchingBench/benchRegexMatching3

  • 🟥 execution_time [+56.472ns; +129.928ns] or [+4.744%; +10.914%]

scenario:SamplingRuleMatchingBench/benchRegexMatching4

  • 🟥 execution_time [+107.425ns; +162.775ns] or [+9.311%; +14.108%]

scenario:SpanBench/benchOpenTelemetryAPI

  • 🟥 mem_peak [+1.485MB; +1.514MB] or [+3.576%; +3.646%]

scenario:TraceSerializationBench/benchSerializeTrace

  • 🟩 execution_time [-44.190µs; -31.910µs] or [-9.715%; -7.015%]

Copy link
Copy Markdown
Member

@realFlowControl realFlowControl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed a comment that ended mid-sentence. Otherwise, nice and clean 🚀

@realFlowControl realFlowControl merged commit 476c702 into florian/stabilize-and-speedup-allocations Dec 8, 2025
7 of 62 checks passed
@realFlowControl realFlowControl deleted the levi/stabilize-and-speedup-allocations branch December 8, 2025 07:26
realFlowControl added a commit that referenced this pull request Dec 9, 2025
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