Git Product home page Git Product logo

Comments (10)

markhuot avatar markhuot commented on August 17, 2024 3

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,

from pyroscope.

petethepig avatar petethepig commented on August 17, 2024

@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:

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.

markhuot avatar markhuot commented on August 17, 2024

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.

markhuot avatar markhuot commented on August 17, 2024

Ah, I think I see. I've been looking through this commit for inspiration, grafana/rbspy@00dbbe4

from pyroscope.

petethepig avatar petethepig commented on August 17, 2024

@markhuot I think for a C library it will be more of a flag in the compiler type thing.

from pyroscope.

adrianandreias avatar adrianandreias commented on August 17, 2024

PHP support would be really useful.

from pyroscope.

petethepig avatar petethepig commented on August 17, 2024

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.

petethepig avatar petethepig commented on August 17, 2024

Also made this diagram describing the relationship between components: agents

from pyroscope.

petethepig avatar petethepig commented on August 17, 2024

@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.

abeaumont avatar abeaumont commented on August 17, 2024

Closing this, PHP support is already provided through phpspy.

from pyroscope.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.