News for hackers. Stuff that matters.
Re:Apple's new Processor Trace instrument is incredible by do_not_redeem on Saturday August 16, 2025 @06:34PM (#44927410)
> Instead of statistical sampling like most profilers, you get a complete picture of your app’s execution flow.

Potentially interesting, but it's not really clear whether this is anything new or not. valgrind + kcachegrind does this too.

https://developer.apple.com/documentation/xcode/analyzing-cp...

These screenshots look a lot like kcachegrind with a slightly reimagined UI. Is there actually anything new here, or is this another case of Apple finally catching up to the open source world?

Re:Apple's new Processor Trace instrument is incredible by nkurz on Saturday August 16, 2025 @07:05PM (#44927573)
As 'GeekyBear' implies in a sibling comment, valgrind works with an emulation of an ideal processor rather than directly on the actual CPU. Sometimes this gives you a good idea of how the program will actually run, and sometimes it doesn't. As processors became more complex, it got farther and farther from the truth. Personally, I started in the Valgrind era and stopped using it as soon as better tools using native instrumentation became available. If Apple's approach works as well as described, it is much better than anything from that era.
Re:Apple's new Processor Trace instrument is incredible by do_not_redeem on Saturday August 16, 2025 @07:16PM (#44927635)
I've never found cachegrind inaccurate, but maybe I'm not doing hardcore enough performance work. You can also use perf and get you numbers straight from the hardware if that's what you need. Truth be told I mainly use cachegrind because I prefer kcachegrind's UI to hotspot.

(I even prefer cachegrind's approach since the numbers will be less distorted by other random background activity on the machine, but that could just be idealism on my part, who knows.)

If perf or the vendor-specific tools like vtune/uprof aren't sufficient for you then I'm curious what do you use?

Re:Apple's new Processor Trace instrument is incredible by nkurz on Saturday August 16, 2025 @07:45PM (#44927764)
I switched from emulator tools like valgrind to tools with hardware support like perf, pmu-tools, and VTune. I generally found them sufficient, but sometimes buggy and difficult to use.

Cachegrind is occasionally inaccurate due to an inaccurate model, but the greater problem was that cache hit percentages only tell a fraction of the story. To be able to predict performance I often needed to be able to accurately measure things like the number of memory requests in flight.

Searching now for an example, I hit on a comment I made here a few years ago where this new tool probably would have been helpful: https://news.ycombinator.com/item?id=18442131

In general I have much greater faith in the on chip performance registers. That said, other than glancing at news stories like this I haven't been keeping up with recent advances. I guess it's possible that cachegrind and friends have improved since I was using them.

Re:Apple's new Processor Trace instrument is incredible by do_not_redeem on Saturday August 16, 2025 @08:12PM (#44927891)
I've always reached for llvm-mca when I need stuff like that, but again it's all predicted/ideal numbers, not live off the hardware. And you need to start off with another tool first to pinpoint where to look.

I've never come across pmu-tools, thanks for the tip. I'll try it out next time I'm in the trenches.

Re:Apple's new Processor Trace instrument is incredible by GeekyBear on Saturday August 16, 2025 @06:50PM (#44927509)
> Potentially interesting, but it's not really clear whether this is anything new or not. valgrind + kcachegrind does this too.

Looking at the kcachegrind homepage, it doesn't sound like they are pulling their data directly from the CPU core itself:

> Callgrind uses runtime instrumentation via the Valgrind framework for its cache simulation and call-graph generation.

https://kcachegrind.github.io/html/Home.html

Apple seems to have modified it's core design so that it will stream data to a log file while the code is running.

> Recent Apple silicon devices can capture a processor trace where the CPU stores information about the code it runs, including the branches it takes and the instructions it jumps to. The CPU streams this information to an area on the file system so that you can analyze it with the Processor Trace instrument.

Re:Apple's new Processor Trace instrument is incredible by jauntywundrkind on Saturday August 16, 2025 @07:06PM (#44927574)
Intel has a Performance Monitoring Unit on its core that has significant overlap.

Forgetting this tool-space, but at least some of these tools can make use of that hardware:

https://github.com/intel/pcm https://github.com/andikleen/pmu-tools

Re:Apple's new Processor Trace instrument is incredible by kaladin-jasnah on Saturday August 16, 2025 @08:26PM (#44927959)
IIRC perf does it as well.
Re:Apple's new Processor Trace instrument is incredible by do_not_redeem on Saturday August 16, 2025 @07:03PM (#44927560)
If you need data straight from the hardware you can use e.g. perf+hotspot, although I've heard that perf's tracing (not sampling!) supports fewer CPUs (but still more than just 1)