pprof-rs icon indicating copy to clipboard operation
pprof-rs copied to clipboard

Dont panic for 0 frequence

Open arilou opened this issue 2 years ago • 2 comments

Make 0 frequency a valid option.

arilou avatar Dec 04 '22 08:12 arilou

Thanks for your contribution :beers:.

If the interval is 0, the timer is stopped. I don't think it's intuitive for users. Could we return the error to the user?

Actually, panic is not that bad :thinking:. Could you give more explanation on why you want to avoid the panic?

YangKeao avatar Dec 09 '22 06:12 YangKeao

Hi @YangKeao, yes I can give you the scenario where this found me, I have integrated pprof-rs to an application I'm writing, so first of all thank it's a great crate and it helped find some nice places that required additional optimizations.

As for the scenario, the application I'm writing has a server listening thread which accepts commands, for example one of the command is to start the profiling.

I have added another command which collects the backtraces of all the threads in the application using your crate, basically what I do is set the frequency to 0, and then tkill I can send a SIGPROF to each thread, once I'm done sending the SIGPROF to each thread I collect the backtraces from the Profiler.

I thought about contributing that piece of code as well but it's very platform specific (only Linux) and it's not really a profiling scenario.

Thanks, -- Jon.

arilou avatar Dec 09 '22 10:12 arilou