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.
xyzzy_plugh 22 hours ago [-]
> I really like the idea of a deterministic VM (I like Antithesis for a similar reason!)
I agree, and I also like Antithesis, but I am a bit dismayed that deterministic high-performance VMs haven't become commodity yet.
I know, I know, I am impatient, and it will happen eventually, but it's frustrating to see Antithesis corner the market so hard with a closed solution.
Maybe this is a sign I should start yet another side project?
cmrx64 13 hours ago [-]
been feeling similarly
hungryhobbit 15 hours ago [-]
A co-worker (formally of Nvidia) recently explained to us (his new company) Nvidia's cultural "speed of light" idea.
The core idea is you don't ask "is our GPU (or whatever is being built) as fast as the last one?" You don't even ask "is it as good as any GPU ever made?"
You instead ask "is it as fast as the speed of light?"
In other words, if you just waved away everything slowing you down, what's the absolute fastest you could complete your task? ONLY once you know that can you start putting back the other factors that slow you down: first you must start by comparing to the fastest possible way things could be ("speed of light").
Similar idea here.
rootlocus 15 hours ago [-]
Curiously enough I reached the same mentality while doing performance optimizations in university. At some point you realize performance optimization is just trimming away fat you didn't actually need. This means there's a lean muscle mass somewhere that's absolutely necessary and you can't do [the thing] without it. That's essentially the only computation required to implement the feature. Everything else is fat.
Sure, sometimes fat is good. Fat is compromise. Fat might be orthogonal concerns. But you'll never get leaner than that essential muscle mass.
I guess in their case "speed of light" is the leanest muscle mass required.
disperso 21 hours ago [-]
Seems very interesting. Is there some parallel to make with RR (record and replay) in terms of features, limitations, etc.?
[rr maintainer here]. Similar principles but there are important differences. rr records and replays user-space processes and has to understand the user/kernel interface really well, which is a problem because that interface is super complicated. RewindVM replays the whole VM, simplifying the interface because the hypervisor interface is (or at least, can be configured to be) somewhat simpler than the user/kernel interface. The overhead of replaying at the VM level will be different ... possibly lower, possibly higher, depending on the workload; you might expect there to be fewer VM exits than system call traps, but OTOH you have to record and replay the entire guest OS instead of specific processes.
In terms of functionality, they're different. rr supports arbitrary timeslicing, e.g. thread switches at any program instruction, which ReplayVM does not. RewindVM depends on Nix, rr doesn't. RewindVM supports a kind of "mutable replay" where you can resume a VM from a checkpoint and cause it to do something different from what was previously recorded; rr's version of that is much more limited.
Veserv 20 hours ago [-]
Everything they described about their runtime is just a time travel debugger using a single-threaded record and replay model. So yes.
Their visualizations are techniques based around leveraging the extra data available in a full instruction trace. As such, they can be applied to any time travel debugger datastream, which trivially has a full instruction trace, or just raw instruction trace if that is all you have.
uvdn7 23 hours ago [-]
Does this type of analysis and deterministic VM help async workloads (e.g. c++ coroutine, fiber, future, etc.)? My understanding is that they don't. I would love to know how to find the critical path for async code. It feels very hard (maybe impossible) to do without changing the framework code (e.g. embedding something like a request context so we know a later task on thread A is actually a continuation for request R).
setheron 23 hours ago [-]
Yes it does. Everything is deterministic even the thread orderings and all randomness that would decide asyc scheduling in user space.
uvdn7 22 hours ago [-]
I see. I am not familiar with deterministic VMs. I can see how it can intercept all system calls. I guess randomness is deterministic as well because all the inputs to the RNG are deterministic. So everything is a deterministic state machine.
> Give a CPU the same registers, the same memory and the same instructions, and it computes the same result.
So is branch prediction, cacheline misses, memory accesses I guess.
> One more outside influence is easy to miss: other CPUs. On two cores, which thread wins a race comes down to cache misses and pipeline stalls, so Rewind provides a single virtual CPU and the threads take turns on it.
Is this a limitation in practice? With a single virtual cpu, data races simply can't happen?
setheron 14 hours ago [-]
they are no longer possible due to timing from the hardware.
adsharma 21 hours ago [-]
Things like this could be done via sleep profiling or CPU stall profiling.
But they involve a trade-off in the Linux kernel or spending more transistors in CPU design.
Weird title. Also, the post just ends with identifying but not solving the problem?
jiveturkey 18 hours ago [-]
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.
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).
yuan278501381 1 days ago [-]
[flagged]
Twirrim 21 hours ago [-]
There's a great talk from Strange Loop from 2019 by Professor Emery Berger called "Performance Matters"[1] where he in part dives into the fact that memory layout can have a huge impact and that you may not have as much control over layout as you think.
For example he cites that even the username of the person running the program can be enough to result in some crippling performance impacts (even if the program doesn't pick it up, on *nix systems it's part of the environment variables!)
One of the white papers he references, from 2009, by Mytkowicz et al. is titled "Producing Wrong Data Without Doing Anything Obviously Wrong!" and is worth at least a skim through, if not a full read. The starting abstract:
> This paper presents a surprising result: changing a seemingly innocuous aspect of an experimental setup can cause a systems researcher to draw wrong conclusions from an experiment. What appears to be an innocuous aspect in the experimental setup may in fact introduce a significant bias in an evaluation. This phenomenon is called measurement bias in the natural and social sciences. Our results demonstrate that measurement bias is significant and commonplace in computer system evaluation. By significant we mean that measurement bias can lead to a performance analysis that either over-states an effect or even yields an incorrect conclusion. By commonplace we mean that measurement bias occurs in all architectures that we tried (Pentium 4, Core 2, and m5 O3CPU), both compilers that we tried (gcc and Intel’s C compiler), and most of the SPEC CPU2006 C programs. Thus, we cannot ignore mea surement bias. Nevertheless, in a literature survey of 133 recent papers from ASPLOS, PACT, PLDI, and CGO, we determined that none of the papers with experimental results adequately consider measurement bias.
The relevant passage from the paper in relation to Dr Berger's talk:
> The most important point to take away from this graph is that depending on the shell environment size we may conclude that (i) the O3 optimizations are beneficial (i.e., the y value is greater than 1.0); (ii) the O3 optimizations degrade performance; and (iii) increasing the UNIX environment size does not predict the O3 speedup because as the size increases speedup increases and decreases, ranging from 0.91 to 1.07
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.
(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_chest63 1 days ago [-]
Flame graphs alone justify the worship, found a hot regex in our billing service in ten minutes
db48x 1 days 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 days 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 days 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__ 1 days 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.
manwe150 22 hours ago [-]
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)
pacoverdi 6 hours ago [-]
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:
> 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.
manwe150 12 hours ago [-]
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
SeshSwapCarl 15 hours ago [-]
[dead]
sgerenser 20 hours ago [-]
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_k 18 hours ago [-]
Thanks for sharing. Can you please hint what is the purpose of that simulation application? Is it for stress testing Azure compute?
sgerenser 17 hours ago [-]
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.)
ferguess_k 16 hours ago [-]
Thanks for sharing :) An interesting project indeed. I'm a bit surprised that MSFT does CPU/SoC design.
sdevonoes 1 days 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 1 days 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.
BigRedEye 16 hours ago [-]
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.
shellctl 20 hours ago [-]
[flagged]
wjddidi 1 days ago [-]
[flagged]
pacoverdi 7 hours ago [-]
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 :)
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
coffeebreak_py 23 hours ago [-]
[flagged]
sightlinemac 1 days 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.
Rendered at 14:01:27 GMT+0000 (Coordinated Universal Time) with Vercel.
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.
I agree, and I also like Antithesis, but I am a bit dismayed that deterministic high-performance VMs haven't become commodity yet.
I know, I know, I am impatient, and it will happen eventually, but it's frustrating to see Antithesis corner the market so hard with a closed solution.
Maybe this is a sign I should start yet another side project?
The core idea is you don't ask "is our GPU (or whatever is being built) as fast as the last one?" You don't even ask "is it as good as any GPU ever made?"
You instead ask "is it as fast as the speed of light?"
In other words, if you just waved away everything slowing you down, what's the absolute fastest you could complete your task? ONLY once you know that can you start putting back the other factors that slow you down: first you must start by comparing to the fastest possible way things could be ("speed of light").
Similar idea here.
Sure, sometimes fat is good. Fat is compromise. Fat might be orthogonal concerns. But you'll never get leaner than that essential muscle mass.
I guess in their case "speed of light" is the leanest muscle mass required.
https://github.com/rr-debugger/rr
In terms of functionality, they're different. rr supports arbitrary timeslicing, e.g. thread switches at any program instruction, which ReplayVM does not. RewindVM depends on Nix, rr doesn't. RewindVM supports a kind of "mutable replay" where you can resume a VM from a checkpoint and cause it to do something different from what was previously recorded; rr's version of that is much more limited.
Their visualizations are techniques based around leveraging the extra data available in a full instruction trace. As such, they can be applied to any time travel debugger datastream, which trivially has a full instruction trace, or just raw instruction trace if that is all you have.
> Give a CPU the same registers, the same memory and the same instructions, and it computes the same result.
So is branch prediction, cacheline misses, memory accesses I guess.
> One more outside influence is easy to miss: other CPUs. On two cores, which thread wins a race comes down to cache misses and pipeline stalls, so Rewind provides a single virtual CPU and the threads take turns on it.
Is this a limitation in practice? With a single virtual cpu, data races simply can't happen?
But they involve a trade-off in the Linux kernel or spending more transistors in CPU design.
^1: https://xkcd.com/1053/
https://www.youtube.com/watch?v=tDacjrSCeq4
> 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.
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.
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).
One of the white papers he references, from 2009, by Mytkowicz et al. is titled "Producing Wrong Data Without Doing Anything Obviously Wrong!" and is worth at least a skim through, if not a full read. The starting abstract:
> This paper presents a surprising result: changing a seemingly innocuous aspect of an experimental setup can cause a systems researcher to draw wrong conclusions from an experiment. What appears to be an innocuous aspect in the experimental setup may in fact introduce a significant bias in an evaluation. This phenomenon is called measurement bias in the natural and social sciences. Our results demonstrate that measurement bias is significant and commonplace in computer system evaluation. By significant we mean that measurement bias can lead to a performance analysis that either over-states an effect or even yields an incorrect conclusion. By commonplace we mean that measurement bias occurs in all architectures that we tried (Pentium 4, Core 2, and m5 O3CPU), both compilers that we tried (gcc and Intel’s C compiler), and most of the SPEC CPU2006 C programs. Thus, we cannot ignore mea surement bias. Nevertheless, in a literature survey of 133 recent papers from ASPLOS, PACT, PLDI, and CGO, we determined that none of the papers with experimental results adequately consider measurement bias.
The relevant passage from the paper in relation to Dr Berger's talk:
> The most important point to take away from this graph is that depending on the shell environment size we may conclude that (i) the O3 optimizations are beneficial (i.e., the y value is greater than 1.0); (ii) the O3 optimizations degrade performance; and (iii) increasing the UNIX environment size does not predict the O3 speedup because as the size increases speedup increases and decreases, ranging from 0.91 to 1.07
[1] https://www.youtube.com/watch?v=r-TLSBdHe1A [2] https://users.cs.northwestern.edu/~robby/courses/322-2013-sp...
(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.
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.
I tried to combine both orientations in a 3d visualization here:
https://github.com/pcdv/mountain-graph
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.
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.
Here is my small contribution to the altar though : 3d flame graphs :)
https://github.com/pcdv/mountain-graph
no one ever bothered to look. a profile found it instantly