All Projects → AtheMathmo → Cpuprofiler

AtheMathmo / Cpuprofiler

Rust bindings to google's cpuprofiler

Programming Languages

rust
11053 projects

Labels

Projects that are alternatives of or similar to Cpuprofiler

Eluaprofiler
Easy LuaProfiler
Stars: ✭ 38 (-66.67%)
Mutual labels:  profiler
Devel Nytprof
Devel::NYTProf is a powerful feature-rich source code profiler for Perl. (Mostly in maintenance mode, so PRs are much more likely to be acted upon than Issues.)
Stars: ✭ 61 (-46.49%)
Mutual labels:  profiler
Tracy
😎 Tracy: the addictive tool to ease debugging PHP code for cool developers. Friendly design, logging, profiler, advanced features like debugging AJAX calls or CLI support. You will love it.
Stars: ✭ 1,345 (+1079.82%)
Mutual labels:  profiler
Nanoscope
An extremely accurate Android method tracing tool.
Stars: ✭ 1,023 (+797.37%)
Mutual labels:  profiler
Phpspy
Low-overhead sampling profiler for PHP 7+
Stars: ✭ 1,105 (+869.3%)
Mutual labels:  profiler
Gdbprofiler
Rich man's profiler, a profiler for native OCaml and other executables
Stars: ✭ 75 (-34.21%)
Mutual labels:  profiler
Samp Plugin Profiler
Performance profiler plugin for SA-MP server
Stars: ✭ 33 (-71.05%)
Mutual labels:  profiler
Xhgui
Web interface for XHProf profiling data can store data in MongoDB or PDO database
Stars: ✭ 1,507 (+1221.93%)
Mutual labels:  profiler
Vcprofiler
An accurate and simple tool uses KVO to measure the time cost of every view controller.
Stars: ✭ 61 (-46.49%)
Mutual labels:  profiler
Semile
Profile what you care, monitor how it goes (support C/C++)
Stars: ✭ 89 (-21.93%)
Mutual labels:  profiler
Stackimpact Nodejs
DEPRECATED StackImpact Node.js Profiler - Production-Grade Performance Profiler: CPU, memory allocations, async calls, errors, metrics, and more
Stars: ✭ 46 (-59.65%)
Mutual labels:  profiler
Dntprofiler
DNTProfiler is an EF 6.x and NH 4.x profiler.
Stars: ✭ 59 (-48.25%)
Mutual labels:  profiler
Opencover
A code coverage tool for .NET 2 and above (WINDOWS OS only), support for 32 and 64 processes with both branch and sequence points
Stars: ✭ 1,256 (+1001.75%)
Mutual labels:  profiler
Android Methods Profiler
Yet another Android Profiler for AOSP .trace files
Stars: ✭ 43 (-62.28%)
Mutual labels:  profiler
Optick
C++ Profiler For Games
Stars: ✭ 1,364 (+1096.49%)
Mutual labels:  profiler
Php Spx
A simple & straight-to-the-point PHP profiling extension with its built-in web UI
Stars: ✭ 972 (+752.63%)
Mutual labels:  profiler
Miku Luaprofiler
Stars: ✭ 1,125 (+886.84%)
Mutual labels:  profiler
Jvm Profiler
JVM Profiler Sending Metrics to Kafka, Console Output or Custom Reporter
Stars: ✭ 1,558 (+1266.67%)
Mutual labels:  profiler
Easy profiler
Lightweight profiler library for c++
Stars: ✭ 1,594 (+1298.25%)
Mutual labels:  profiler
Xpedite
A non-sampling profiler purpose built to measure and optimize performance of ultra low latency/real time systems
Stars: ✭ 89 (-21.93%)
Mutual labels:  profiler

CPU Profiler

This library provides bindings to google's cpuprofiler.

Why use this?

There are other profiling tools for Rust, cargo-profiler is particularly good! This library certainly doesn't replace those but adds some different tools to the mix:

  • Makes it easy to profile only sections of code
  • Uses statistical sampling (like oprofiler) which means low overhead
  • Works with pprof for a range of output formats

Installation

In order to use this library you will need to install gperftools. There are instructions in their repository but it's roughly the following:

  1. Download package from releases
  2. Run ./configure
  3. Run make install
  4. Run sudo ldconfig

There may be some other dependencies for your system - these are explained well in their INSTALL document. For example libunwind (> 0.99.0) is required for 64 bit systems.

Usage

Add cpuprofiler to your Cargo.toml manifest.

[dependencies]
cpuprofiler = "0.0.4"

Add the dependency to your root:

extern crate cpuprofiler;

Start and stop the profiler around the code you'd like to draw samples. This will save the profile to a file you specify.

use cpuprofiler::PROFILER;

PROFILER.lock().unwrap().start("./my-prof.profile").unwrap();
// Code you want to sample goes here!
PROFILER.lock().unwrap().stop().unwrap();

Now you can just run the code as you would normally. Once complete the profile will be saved to ./my-prof.profile.

The final step is the fun part - analyzing the profile!

Analyzing the profile

To analyze the profile we use google's pprof tool.

An old version of this tool is included with the gperftools package. This is the version I have been using but the newer Go version should work too! The usage of pprof is well documented in the cpuprofiler docs.

The Result

The output format is entirely dependent on pprof but here are some examples from a Rust program:

Text

Total: 855 samples
     207  24.2%  24.2%      207  24.2% matrixmultiply::gemm::masked_kernel::hfdb4f50027c4d91c
     156  18.2%  42.5%      853  99.8% _$LT$rusty_machine..learning..optim..grad_desc..StochasticGD$u20$as$u20$rusty_machine..learning..optim..OptimAlgorithm$LT$M$GT$$GT$::optimize::h2cefcdfbe42a4db8
      79   9.2%  51.7%       79   9.2% _$LT$$RF$$u27$a$u20$rulinalg..vector..Vector$LT$T$GT$$u20$as$u20$core..ops..Mul$LT$T$GT$$GT$::mul::h21ce4ecb4bbcb555
      66   7.7%  59.4%       73   8.5% __ieee754_exp_sse2
      61   7.1%  66.5%       95  11.1% _$LT$rusty_machine..learning..toolkit..regularization..Regularization$LT$T$GT$$GT$::l2_reg_grad::h4dff2e22567a587e
      57   6.7%  73.2%      274  32.0% matrixmultiply::gemm::dgemm::h2d985771431fcfd4
      41   4.8%  78.0%       42   4.9% _$LT$rulinalg..matrix..Matrix$LT$T$GT$$GT$::transpose::h736b18b122958bcd
      31   3.6%  81.6%       32   3.7% sdallocx

The first column is the number of samples from each function. The second is the percentage of samples which were found directly in this function, and the third column is the percentage of samples which were in this function or it's children. I think...

Graphviz

Below is a snippet of an interactive graph output.

Function call graph

The above graph is produced by pprof and shows which functions the samples belong too. In the above we see that there were 513 samples in the compute_grad function and 119 of these were matrix multiplication.

TODO

  • Better crate documentation
  • Expose other functions from google's cpuprofiler. This allows more options, status checks and more.
  • Can we write a sampling profiler in Rust?!
  • Integration with cargo-profiler?

License

This project has a BSD license to match the gperftools license. Which makes sense, I think?

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].