An unofficial, read-only Hacker News reader. Join the beta →

Worshipping at the altar of Brendan Gregg (opens external site)

241 points by kqr 4 days ago | fzakaria.com | 47 comments on HN

View full thread · View on Hacker News

Comment thread (10)

  1. When I worked at Microsoft, I found a particular hot function using flame graphs in a C++ application covering roughly 50% of all call paths in some runs. It was the constructor for a hand-rolled map-like data structure that was used all over the app. Switching to IIRC an abseil hash map cut the overhead by something like 98%. The app was a simulation-type thing that ran on a server for millions of cycles and runs dropped from something like 2 hours to 1 hour, as you’d expect.

    Unfortunately since then most wins haven’t been nearly as dramatic, but still a happy user of flame graphs.

    Replies (2)
    1. Do you really need flame graphs for that? Wouldn't any normal profiler tell you if a function and its children used 50% of your CPU?

      I always struggle to see why people think flame graphs are so great, but I'm not sure if people are comparing them to a normal (non-graphical) profile or not.

      Replies (2)
      1. Flamegraphs sort the samples by location, rather than ordered by time. They also show hierarchy, rather than just leafs. All combinations on those two axis can be useful to present. Strictly speaking a normal profiler is probably one that gives leaf calls only in order, which is probably the least useful quadrant, but the fastest to generate (works better for hand annotated events and to see latency rather than time)
        Replies (2)
        1. > Flamegraphs sort the samples by location, rather than ordered by time.

          I'm not sure if I understand. Do you mean ordered by amount of time spent, or by event time in the executable? (Most profilers do the former, and flame graphs are implicitly a variant of that by scaling the blocks visually by execution time.)

          > They also show hierarchy, rather than just leafs.

          Like any profiler in graph mode? Every profiler I've used over the last 20 years (even gprof!) can show function hierarchy, both top-down and bottom-up.

          Replies (1)
          1. Event time. It's a common mode for profilers that are looking at latency. And yes, any profiler in call stack mode is the same data, just without the colorful visuals, as he talked about in the intro paragraph: https://www.brendangregg.com/flamegraphs.html
        2. With most flamegraph implementations, you can reverse the flame and see often called (hot) methods.

          I tried to combine both orientations in a 3d visualization here:

          https://github.com/pcdv/mountain-graph

      2. Probably could have done it without flame graphs, but the flame graphs made the problem incredibly obvious to anyone including non programmers. I was not originally on the project to work on performance per se, so I had to justify the work.
    2. Thanks for sharing. Can you please hint what is the purpose of that simulation application? Is it for stress testing Azure compute?
      Replies (1)
      1. CPU/SoC performance modeling. It probably had a side effect of stress testing azure compute though. And yes, the irony of a performance modeling tool having terrible performance wasn’t lost on me. (Probably a result of the app mostly being written by people with a hardware engineering background, not software.)
        Replies (1)
        1. Thanks for sharing :) An interesting project indeed. I'm a bit surprised that MSFT does CPU/SoC design.