Skip to content
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

RAII API for profiling sections of code #10

Open
matklad opened this issue Jun 26, 2019 · 1 comment
Open

RAII API for profiling sections of code #10

matklad opened this issue Jun 26, 2019 · 1 comment

Comments

@matklad
Copy link

matklad commented Jun 26, 2019

Hi!

I am looking for a profiling tool for rust-analyzer, and I wonder if not-perf could be of help. I have some very specific requirements, but I am not a profiling expert, so I don't know if what I ask is at all possible, hence this feature-request/support issue :) Feel free to just close with "out of scope" if I ask for something silly!

rust-analyzer relies heavily on incremental computation, and I'd love to profile the incremental case. The interesting benchmark looks like this:

load_data_from_disk(); // 200ms of IO
compute_completion(); // triggers initial analysis, 10 seconds
{
    change_single_file();
    compute_completion(); // re computation after a change, 300 ms
}

I am only interested in profiling the block. Although the running-time of the benchmark is dominated by initial analysis, I explicitly don't care much about its performance.

So, what I like is to do

  • sampling profiling (so that I don't have to instrument my code / bias times)
  • of fairly short-lived blocks of CPU-heavy code (hundreds of milliseconds)
  • from withing the application itself (so that I can start/stop profiling for specific section of code)
  • without depending on C code (just because building C is a pain)

Is this possible at least in theory (ie, are there sampling tools than can give such data)? Could not-perf be of help here? My dream API would look like this:

load_data_from_disk();
compute_completion();
{
    let _p = not_perf::record("~/tmp/profile_data.perf")
        .append(); // append to the data file, so that I can run this in a loop
    change_single_file();
    compute_completion();
    // stops profiling on Drop
}
@matklad
Copy link
Author

matklad commented Jun 26, 2019

Oh, I must say that currently I try to use https://github.com/AtheMathmo/cpuprofiler and it kinda can do this, but has heavy C deps and lacks convenient APi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant