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.
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.
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.
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)
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.
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.)
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?
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.
You can collect profiles from your production environment using some sort of continuous profiler, like Grafana Alloy or the OTel profiler. We actually built https://github.com/yandex/perforator specifically to profile everything we can reach.
This thing also greatly helps when exploring unfamiliar codebases. You can just open a flame graph in a few clicks and see what the program actually does.
scripts got significantly faster using isoformat for parsing date times over str. These were critical recovery/startup scripts for an ultra low latency
no one ever bothered to look. a profile found it instantly
I don't usually worship much, but I must admit flame graphs have had a huge influence on my work. I've used them creatively for other things than performance analysis.
Comments (47) 14 threads
Show all comments
Showing thread 12 of 14
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.
Unfortunately since then most wins haven’t been nearly as dramatic, but still a happy user of flame graphs.
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.
Continue this thread — 3 replies
Continue this thread — 1 reply
But everything usually looks fine on local env, and can’t really replicate the intricacies of prod locally. How do you guys do it?
This thing also greatly helps when exploring unfamiliar codebases. You can just open a flame graph in a few clicks and see what the program actually does.
no one ever bothered to look. a profile found it instantly
Here is my small contribution to the altar though : 3d flame graphs :)
https://github.com/pcdv/mountain-graph