Git Product home page Git Product logo

qpprof's Introduction

qpprof

qpprof complements the pprof tool.

Commands

Use qpprof command --help to get more information.

Flat aggregation

Alternative flat aggregations allow you to get the top with some of the nodes being folded to their callers.

For instance, take this copyBytes() function:

func copyBytes(b []byte) []byte {
  dst := make([]byte, len(b))
  copy(dst, b)
  return dst
}

If you benchmark it and use pprof top, then you'll see this:

(pprof) top 5
37.56% runtime.mallocgc
12.16% runtime.memclrNoHeapPointers
 9.35% runtime.memmove
 8.47% runtime.scanobject
 6.42% runtime.scanblock

With flat-with-runtime you'll get something that you would expect:

$ qpprof flat-with-runtime cpu.out
6.25s example.copyBytes
 40ms example.BenchmarkCopyBytes
 20ms testing.(*B).runN

There is also flat-with-stdlib that folds all standard library functions, not just the runtime package.

Enriching the profile

Given a CPU profile X and executable E that was used to collect it, we can generate a new CPU profile Y that contains even more useful information.

What we can add to the profile:

  • Explicit bound checks timings (displayed as runtime.boundcheck)
  • Explicit nil checks timings (displayed as runtime.nilcheck)
$ qpprof enrich -o=cpu2.out -exe=prog cpu.out
runtime.boundcheck: 7 samples (300ms)
runtime.nilcheck: 22 samples (300ms)

Now let's open cpu2.out with pprof:

(pprof) top boundcheck|nilcheck
Active filters:
   focus=boundcheck|nilcheck
Showing nodes accounting for 0.60s, 1.10% of 54.68s total
Showing top 10 nodes out of 132
      flat  flat%   sum%        cum   cum%
     0.30s  0.55%  0.55%      0.30s  0.55%  runtime.boundcheck (inline)
     0.30s  0.55%  1.10%      0.30s  0.55%  runtime.nilcheck (inline)

The implicit bound checks are now explicit, visible in the profile.

qpprof's People

Contributors

quasilyte avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

isgasho

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.