Re: [RFC] perf record: missing buildid for callstack modules

From: Peter Zijlstra
Date: Tue Jan 12 2016 - 08:40:22 EST


On Tue, Jan 12, 2016 at 01:18:05PM +0100, Ingo Molnar wrote:
> > Well, it really is rather a rare case, replacing binaries you're
> > profiling. Sure, if it happens (by accident or otherwise) it can be a
> > pain, but the cost of fixing this 'problem' is huge.
>
> But isn't this the common case for developers, who rebuild their binaries all the
> time, while profiling them? Looking at the wrong profile without having an
> indication that it's wrong is a problem.

I tend to:

1:
edit code
compile code
(perf) run code
inspect profile
goto 1

which does not have this problem at all. Only if you want to inspect
'old' profiles does this problem occur.

> > On my system that pass takes longer than the actual workload (of building a
> > kernel). Furthermore, the resulting data is useless for me.
>
> Hm, that's a powerful performance argument. Why is it so slow? I'd assume that by
> default we only need to save the build-ID itself per object - which is like 20
> bytes?

There is no buildid in the recorded data, I think it looks at every MMAP
record, finds the associated file, extracts the buildid and copies crap
into .debug directory.

Also, just parsing the gigabytes of data that comes out of perf-record
takes significant time, let alone poking around the filesystem and
copying files around.

Furthermore, I have 40 CPUs generating data, while only a single one is
doing all this post-processing.

# rm -rf ~/.debug/
# make O=defconfig-build/ clean; perf record make O=defconfig-build/ -j80 -s
# ls -lah perf.data
-rw------- 1 root root 2.7G Jan 12 14:18 perf.data
# du -sh ~/.debug/
240M /root/.debug/

That's a lot of pointless work.


> > And all for some weird corner case.
>
> So could we perhaps just switch the whole thing over to be mtime based: mtime is
> pretty indicative of whether a binary is the right one or not.
>
> And mtime could be checked at perf report time, not at perf record time: we'd only
> have to check whether the mtime of the object we read at perf report time is newer
> than the mtime of the perf.data (the creation of the profile).
>
> This does not solve rare corner cases like cross-system profiling, but I think the
> common case should not be burdened with the overhead of a rare case.

That might work, we have easy access to the mtime data for any file.