Repository navigation
fix(profiling): Release the Excimer profiler when the transaction profiler stops - #2424
Open
stayallive wants to merge 1 commit into
Open
stayallive wants to merge 1 commit into
stayallive wants to merge 1 commit into
Conversation
…filer stops A finished transaction is part of a reference cycle (span recorder and child spans), so it is only freed by PHP's cycle collector. It kept the Profiler and therefore the ExcimerProfiler alive, whose OS timer (a thread on Linux) is only freed on destruction. Long-running workers could exhaust their thread limit. Profiler::stop() now drops the ExcimerProfiler after flushing its log, while getProfile() keeps returning the collected profile. Fixes #2423 Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Finished profiled transactions kept their Excimer timer (a thread on Linux) alive until PHP's cycle collector ran. A
Transactionis part of a reference cycle (its span recorder contains the transaction itself, and child spans reference it), so unsetting it doesn't free it. It held on to theProfiler, which held the\ExcimerProfiler, whose OS timer is only released on destruction, not onstop(). In long-running workers the collector may not run often enough, and the process can hit its thread limit (ExcimerProfiler::start(): Error in pthread_create(): Resource temporarily unavailable).Profiler::stop()now drops the\ExcimerProfilerright after flushing its log.getProfile()uses a separate availability flag, so it still returns the collected profile afterstop().Profilerisfinaland@internal, andTransaction::getProfiler()behaves as before.Reproduced with the script from the issue (Linux, PHP 8.4, ext-excimer 1.2.6):
Added
tests/Profiling/ProfilerTest.php(requiresexcimer), which checks thatstop()releases the Excimer profiler while the profile stays available, and that a finished transaction still attaches its profile to the event. Both tests fail without the fix.Issues
🤖 Generated with Claude Code