Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

About continuous profiling #5277

Unanswered
wally-ntuple asked this question in Q&A
Discussion options

Is there anyone who uses continuous profiling on the Swoole-based project?
I know the blackfire.io supports Swoole but I'm looking for OSS.
Now I am trying to use Grafana Pyroscope but It does not work well with Swoole.
Any information or suggestions are appreciated.

You must be logged in to vote

Replies: 2 comments

Comment options

Have you tested xhprof or excimer?

You must be logged in to vote
0 replies
Comment options

I think https://github.com/NoiseByNorthwest/php-spx could be made Swoole-friendly provided one uses PHP's builtin server for the visualization of the profiling and spx_profiler_start() and spx_profiler_stop() in the Swoole server while setting automatic start to 0

Then a UNIX domain socket could be used to inform the Swoole server to either enable or disable profiling during runtime (which - for instance - would modify a Swoole\Atomic variable)

If the message coming in over the UNIX domain socket is to enable, then the Atomic variable would be set to 1 and some INI settings might be set via ini_set() (See the SPX extension repository for help on this)
Also be sure to check out their ISSUES section as I recall I found one issue that helped me.

Finally, in the code that needs to be profiled, you might do something like:

global $profilingEnabled; // This is the Swoole\Atomic variable controlling if PROFILING is currently enabled

if ((int) $profilingEnabled->get() === 1) {
spx_profiler_start();
}

// ... Code to be profiled ....

if ((int) $profilingEnabled->get() === 1) {
spx_profiler_stop();
}

I have previously done this on a project, however there is one caveat:

All INI settings of PHP SPX profiler extension are PHP_INI_SYSTEM if I recall correctly, so what I ended up doing was to modify the source code of the SPX extension such that all INI settings were instead PHP_INI_ALL (meaning that they are modifyable from any context)

Just my 2 cents...

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /