Lurker News

Comments (47) 14 threads

Earlier comments
jiveturkey1 reply#
sadly the answer to the investigation was just a footnote.

> 4 Turns out that the test sleeps on purpose: it is checking how far uv_hrtime moves across a sleep. There is nothing to optimize in this case.
also, no explanation of why he didn't look into the epoll_wait(). i guess because this is a blocking call, not intentionally asleep, and also the intentional sleep is magnified 600 times? epoll_wait() shows up as consuming 3x of the wall time but in the shortening analysis the nanosleeps are shown to add up to more time asleep. i'm a little confused on that.
good article, would have been great with more editing. and it would be great to also see an example where a problem is fixed.

setheron1 reply#
I have been filing some of the bugs at https://rewindvm.dev/bugs.html as I work on them upstream.

I wanted the article to be more about the idea and performance investigation rather than about this one bug though.
With this much insight, lots of software has lots of bugs.

jiveturkey#
Yeah, the article was successful in showing the tool, very successful. Much more of a gentleman's introduction than for example https://www.brendangregg.com/offcpuanalysis.html

I only looked at the first bug you list on the bugs.html page, and it doesn't appear to have needed or used the `time` tool. As this article is specifically about the `time` functionality, that's what I was complaining was missing from your article. Maybe that was an unfair complaint, as I can't find a single example on the internet (using Gregg's tooling, which has existed forever).

perdy1 reply#
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.
jiuge19261 reply#
[flagged]
dang#
Some of your recent comments have been killed by our software because they've been classified as genai text, which is not allowed on HN itself (see https://news.ycombinator.com/newsguidelines.html#generated and https://news.ycombinator.com/item?id=47340079).

(It's fine, of course, to use AI tools—we use them heavily ourselves. Just please don't use them to generate or edit text to be read by fellow humans on Hacker News.)
It's impossible to know for sure what was LLM generated or edited, but we have to rely on imperfect classifiers or else the site would be completely flooded by genai text, which is not what the community here wants to read, nor in the intended spirit of HN.

zinc_chest635 replies#
Flame graphs alone justify the worship, found a hot regex in our billing service in ten minutes
db48x1 reply#
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#
Any loop is the prime suspect for optimization. I’ve seen a lot of naive implementation of something instead of using standard algorithms.
sgerenser2 replies#
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__2 replies#
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.

manwe1503 replies#
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)

Continue this thread — 3 replies

sgerenser#
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.
ferguess_k1 reply#
Thanks for sharing. Can you please hint what is the purpose of that simulation application? Is it for stress testing Azure compute?
sgerenser1 reply#
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.)

Continue this thread — 1 reply

sdevonoes2 replies#
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#
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.
BigRedEye#
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.

d675#
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

pacoverdi#
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.

Here is my small contribution to the altar though : 3d flame graphs :)
https://github.com/pcdv/mountain-graph

Load more comments