-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
profiler: add Start function with a context to abort profiling #8632
Comments
I've created a draft PR at #8633 While I was working on it I realized that there are more "problems" - e.g. some state is globally set, like @aabmass since you got assigned to this - WDYT? |
@timofurrer thanks for sending a PR and opening discussion. As you figured out, there is a lot of global state that makes this tricky since the initial assumption was that profiling would be started and never stopped for a process lifetime. We make the same assumption in the Python, NodeJS, and Java agents which also don't provide a stop function, so this would introduce some inconsistency and complexity.
Do you mind expanding on the use case a bit? |
Sure, so we have this application running in a customer environment and they / we want to be able to enable profiling from time to time - but not always. In general, this entire application is configurable remotely - and is also changed during runtime remotely, without having to restart it. It would be great if we could follow the same pattern with the profiler. @aabmass btw. I'd be more than happy to contribute a "proper" PR (or a set of them) to gradually refactor to something "desired" -> for example remove the global state without breaking the public interface. And after that introduce an API which allows to properly start and stop a profiler. If you'd be willing to review and accept such a change then let me know and I'll contribute that. EDIT: maybe something like this is a better start: |
This change set refactors the profiler to reduce the global state drastically. It tries to keep the changes minimal on purpose and with that many opportunities to simplify the code have been left out. This change set also prepares the profiler to allow for a stop API, that is once the profiler has been started it can be stopped again and restarted - even with a different config. Refs googleapis#8632
@timofurrer thanks for prototyping this, I appreciate the effort! Unfortunately we can't accept such a contribution right now because of our support load. We'd like to keep complications to a minimum and not expand our feature set at all. We are happy to accept any bug fixes–just not feature requests right now. You're of course welcome to release this new feature as a fork that you/your customers can pull in. |
Is your feature request related to a problem? Please describe.
I want to be able to stop the profiling and restart it - possibly with another config even.
However, the current API with
profiler.Start()
doesn't support that.Describe the solution you'd like
Possibly a
ctx
argument for theStart()
function, however, this is likely not possible due to backwards compatibility, therefore a new function could be added:I think that
pollProfilerService
service also needs to change to respect exiting thefor
-loop on context cancellation.When that is implemented I think the code and test code can be refactored to remove
i < config.numProfiles
andprofilerDone
channel and use a context during tests.Describe alternatives you've considered
profiler.Config
field with a context - that would avoid addingStartWithContext
, but is also kinda weird from an API perspectiveAdditional context
I haven't looked at the profiler internals and I'm not sure if it's even possible to simply stop and restart the profiling without leaving any traces of it.
I'm also open to contribute this myself if you are willing to accept the change :)
The text was updated successfully, but these errors were encountered: