]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
perf record: Cache build-ID of hit DSOs only
authorNamhyung Kim <namhyung@kernel.org>
Thu, 31 Jul 2025 07:03:30 +0000 (00:03 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Thu, 31 Jul 2025 17:46:46 +0000 (10:46 -0700)
It post-processes samples to find which DSO has samples.  Based on that
info, it can save used DSOs in the build-ID cache directory.  But for
some reason, it saves all DSOs without checking the hit mark.  Skipping
unused DSOs can give some speedup especially with --buildid-mmap being
default.

On my idle machine, `time perf record -a sleep 1` goes down from 3 sec
to 1.5 sec with this change.

Fixes: e29386c8f7d71fa5 ("perf record: Add --buildid-mmap option to enable PERF_RECORD_MMAP2's build id")
Reviewed-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Link: https://lore.kernel.org/r/20250731070330.57116-1-namhyung@kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/build-id.c

index e2b295fe4d2fe5529d805515240adfdf067d8ef2..a7018a3b0437a699e5d6d4dcf857a1f380fe7a96 100644 (file)
@@ -872,7 +872,7 @@ static int dso__cache_build_id(struct dso *dso, struct machine *machine,
        char *allocated_name = NULL;
        int ret = 0;
 
-       if (!dso__has_build_id(dso))
+       if (!dso__has_build_id(dso) || !dso__hit(dso))
                return 0;
 
        if (dso__is_kcore(dso)) {