Worshipping at the Altar of Brendan Gregg

(fzakaria.com)

85 points | by kqr 3 hours ago

6 comments

  • aidanhs 23 minutes ago
    I really like the idea of a deterministic VM (I like Antithesis for a similar reason!), though I saw on another post that your VM is single threaded which I feel like must compromise a lot of performance analyses? E.g. when you have very high throughput multithreaded pipelines.

    Personally I've really cooled on flamegraphs for the purpose of doing multithreaded performance analysis - it's so hard to infer cross-thread dependencies. I'd encourage people interested in performance analysis to read https://thume.ca/2023/12/02/tracing-methods/ (and I'd love to hear if there's something more recent than end of 2023 that has an updated census of tools) which makes a decent case for perfetto, though in my own use-cases I've just ended up creating low latency language-specific trace output library that I can aggregate and load into jaeger-ui, as you can actually add metadata indicating spans you follow from etc.

    For the author: your product looks very cool, but I encourage you (or someone you pay!) to do an extensive proof reading pass to remove LLM-isms, reading stuff like "process, with what it started" as a column header of ps-like output is like nails on a chalkboard.

  • yuan278501381 53 minutes ago
    Profiling desktop apps on Windows taught me the exact same lesson: your intuition about where memory goes is almost always wrong until you inspect loaded modules and private commit heaps. We once chased a mysterious 60 MB jump in a tiny C++ process, only to find out via VMMap/ETW that calling the standard OS file picker caused a third-party cloud drive shell extension to load the entire .NET 4 CLR into our process permanently. Same story with GPU drivers pinning hundreds of MBs after a DirectML session closes—you end up isolating those calls in short-lived child processes because no in-process cleanup API actually returns the pages.
  • zinc_chest63 2 hours ago
    Flame graphs alone justify the worship, found a hot regex in our billing service in ten minutes
    • db48x 1 hour ago
      Yea, I love being able to go from the new guy at a new job straight to the performance wizard in the first week, or even on the first day. It’s so fun to stare into the depths of a flamechart and then point out where the problems are.

      At one job they had built this whole nifty SQL library and used it everywhere. In the first profile I took I saw that repeatedly preparing a query took more time than running it and using the data. Each call to prepare took the same amount of time as the others, so it was obvious at a glance that they weren’t caching and reusing the results. The documentation said that they did, and their tests all worked, so they had used it for years even though it was fundamentally broken. That was a fun week.

      • skydhash 1 hour ago
        Any loop is the prime suspect for optimization. I’ve seen a lot of naive implementation of something instead of using standard algorithms.
    • sgerenser 1 hour ago
      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.

      • Sesse__ 16 minutes ago
        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.

    • sdevonoes 1 hour ago
      I struggle with measuring performance. I cannot run such tools in prod envs. Not even in dev envs, only locally. This is because only platform engs have prod access.

      But everything usually looks fine on local env, and can’t really replicate the intricacies of prod locally. How do you guys do it?

      • muststopmyths 51 minutes ago
        They should still be able to provide you with traces from prod even if you can't directly access the systems. Most of perf work is analyzing, not collecting.
      • wjddidi 38 minutes ago
        [flagged]
  • perdy 2 hours ago
    Determinism is the underrated part of all this. For a Python framework I maintain we moved the CI benchmarks to Callgrind: instruction counts instead of time, with the cache geometry pinned so it doesn't matter which runner you land on. The numbers basically stopped moving between runs, which wall-clock never gave us on shared runners. The catch is that you lose everything off-CPU, which is exactly what this post is about, so the critical path view is a bit enviable.
  • despacito 28 minutes ago
    Disappointed it doesn’t involve more screaming
  • sightlinemac 1 hour ago
    On a live machine you have to start tracing before the slow run happens, and tracing has a cost, so you only get a few attempts. Here every recording already logs every context switch because the VM needs them to replay, so the off-CPU and wakeup analysis can be done afterwards, on any run. The hrtime test is a useful distinction too: it accounts for 3.38s of the critical path, but the sleep is intentional, so the drag you can actually remove is zero.