Skip to content

Make use of fast_shutdown to avoid freeing overhead#3429

Merged
bwoebi merged 1 commit into
masterfrom
bob/fast-shutdown
Sep 29, 2025
Merged

Make use of fast_shutdown to avoid freeing overhead#3429
bwoebi merged 1 commit into
masterfrom
bob/fast-shutdown

Conversation

@bwoebi

@bwoebi bwoebi commented Sep 22, 2025

Copy link
Copy Markdown
Collaborator

Note that mistakes in terms of fast_shutdown can lead to actual memory leaks!
We need to ensure stability on memory for this one.

@bwoebi
bwoebi requested a review from a team as a code owner September 22, 2025 18:17
@pr-commenter

pr-commenter Bot commented Sep 22, 2025

Copy link
Copy Markdown

Benchmarks [ tracer ]

Benchmark execution time: 2025-09-22 19:06:03

Comparing candidate commit a3e585a in PR branch bob/fast-shutdown with baseline commit c70ff24 in branch master.

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

scenario:ComposerTelemetryBench/benchTelemetryParsing

  • 🟩 execution_time [-1338.261ns; -461.739ns] or [-11.843%; -4.086%]

scenario:MessagePackSerializationBench/benchMessagePackSerialization

  • 🟩 execution_time [-10.926µs; -9.774µs] or [-9.503%; -8.500%]

scenario:MessagePackSerializationBench/benchMessagePackSerialization-opcache

  • 🟩 execution_time [-14.226µs; -12.434µs] or [-11.878%; -10.381%]

scenario:TraceAnnotationsBench/benchTraceAnnotationOverhead-opcache

  • 🟥 execution_time [+4.829µs; +9.832µs] or [+2.820%; +5.742%]

scenario:TraceFlushBench/benchFlushTrace

  • 🟩 execution_time [-72.196µs; -35.104µs] or [-5.709%; -2.776%]

scenario:TraceSerializationBench/benchSerializeTrace

  • 🟩 execution_time [-32.622µs; -18.578µs] or [-7.513%; -4.279%]

@morrisonlevi morrisonlevi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I see fast shutdown is inversely related to full_tables_cleanup, but I'm not exactly sure when that is set. My guess based on scanning code is that full_tables_cleanup is mostly 0, so most of the time on this branch we would be doing fast shutdown?

As for the details, it looks like it skips calling destructors. Are you certain this is correct, even in weird conditions like fatals or unhandled exceptions, etc?

Also, it seems like the allocation profiler would interfere with this optimization, since it checks is_zend_mm, yeah?

@bwoebi

bwoebi commented Sep 29, 2025

Copy link
Copy Markdown
Collaborator Author

@morrisonlevi I copy pasted the logic from shutdown_executor() in php-src, so it should be fine. And yes, full_tables_cleanup is generally 0. Also no, it doesn't skip calling destructors (zend_call_destructors happens directly in php_request_shutdown). It skips freeing the objects though.

However, the allocation profiler is a problem, but that's slightly orthogonal - this makes the whole fast_shutdown of PHP not work. That's something the profiler should address though.

@bwoebi
bwoebi merged commit e395428 into master Sep 29, 2025
1865 of 1871 checks passed
@bwoebi
bwoebi deleted the bob/fast-shutdown branch September 29, 2025 18:26
@github-actions github-actions Bot added this to the 1.13.0 milestone Sep 29, 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.

3 participants