Comments (10)
I would like to help with this but am not sure where to start. I'm thinking we could leverage some of the existing sampling profilers out there but am not sure what changes need to be made to their output for Pyroscope to read them correctly.
Examples,
- https://github.com/adsr/phpspy
- https://github.com/sj-i/php-profiler
- https://github.com/nikic/sample_prof
from pyroscope.
@markhuot This is already very useful! phpspy
looks very promising. Profilers we use for python and ruby (py-spy
and rbspy
) use a similar approach for getting the profiling data (they look at process memory X number of times per second) and I bet it would be relatively straightforward to add phpspy
to pyroscope if we modify it just a little bit.
For example, here's how we integrated rbspy into pyroscope:
- we modified rbspy to compile into a library instead of an executable binary
- we modified rbspy code to implement the following interface: https://github.com/pyroscope-io/rbspy/blob/main/lib/rbspy.h#L3-L5
- once you can build a static library that complies with this interface, integrating it with go is pretty straightforward: https://github.com/pyroscope-io/pyroscope/blob/main/pkg/agent/rbspy/rbspy.go#L1-L74
C Interface
The C interface has 3 functions, they all take a PID and a buffer to report errors to. snapshot
function also takes a buffer that it writes the stack-trace to.
rbspy_init initializes the spy
int rbspy_init(pid_t pid, void* err_ptr, int err_len);
rbspy_cleanup releases the resources associated with the initialization
int rbspy_cleanup(pid_t pid, void* err_ptr, int err_len);
rbspy_snapshot is the most important one, it copies the current stack trace of the process to ptr
int rbspy_snapshot(pid_t pid, void* ptr, int len, void* err_ptr, int err_len);
I hope this is enough information to get started. @markhuot Ping me in our Slack, I would love to help, this seems very promising.
from pyroscope.
Thanks for these pointers @petethepig! I've dug in to phpspy
and have a much better understanding of how it's working and what it's doing now. Unfortunately the C work is a bit outside my day-to-day experience so I'm getting up to speed on that. In your first bullet you say "we modified rbspy to compile into a library instead of an executable binary." Is that something you did inside the rbspy
logic or a flag you flip on the compiler?
from pyroscope.
Ah, I think I see. I've been looking through this commit for inspiration, grafana/rbspy@00dbbe4
from pyroscope.
@markhuot I think for a C library it will be more of a flag in the compiler type thing.
from pyroscope.
PHP support would be really useful.
from pyroscope.
Started working on it in #157
@markhuot — I set up all the C library scaffolding, I think all that's left to do is connecting the profiling code to the interface.
from pyroscope.
Also made this diagram describing the relationship between components:
from pyroscope.
@adrianandreias @arrack @jamesaspence @jnlin @kcloze @knibals @Kortivex @markhuot @Slach @tooolbox @topazas @vearutop
We've just released v0.0.31 with php support. Please try it out, we would love to hear feedback from any of you.
Currently it only works on Linux and the way to start it is by using pyroscope exec
:
pyroscope exec php main.php
Or you can also connect to an existing php process:
pyroscope connect -pid <pid of the process>
We also have a dockerized example project here
from pyroscope.
Closing this, PHP support is already provided through phpspy.
from pyroscope.
Related Issues (20)
- Row buffering prevents asynchronous symbols fetching
- ebpf(python): does not work with memory swapping enabled nicely
- ebpf improvements ideas
- Improve developer experience with ebpf testdata HOT 4
- [DOC] Update Pyroscope for Agent > Alloy HOT 1
- [DOC] Update Cloud Profiles docs for Agent > Alloy
- Helm: Update from the agent helm chart to the alloy one HOT 1
- Doesn't work with Python3.12 HOT 1
- Trace exemplars HOT 1
- Memory allocation profiling in .NET HOT 7
- [pyro UI] Tags don't work as expected
- Fail to run alloy to pull profiles HOT 1
- Reduce confusion with profile types in Pyroscope HOT 2
- Panic during Ad Hoc profile upload
- profiles from python sdk have -1 as line number
- The sample count displayed is wrong
- Explain basics about flamegraph / profiles HOT 3
- Provide API to access span IDs in profiles
- Memory profiling with eBPF
- CVE-2023-6992 zlib, CVE-2023-42366 busybox HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyroscope.