]> www.infradead.org Git - users/jedix/linux-maple.git/commit
perf tools: Improve startup time by reducing unnecessary stat() calls
authorKrzysztof Łopatowski <krzysztof.m.lopatowski@gmail.com>
Thu, 6 Feb 2025 11:33:15 +0000 (12:33 +0100)
committerNamhyung Kim <namhyung@kernel.org>
Wed, 19 Feb 2025 21:55:59 +0000 (13:55 -0800)
commit4bac7fb5862740087825eda3ed6168e91da8b7e6
tree8d58716be83fe1892389f1d868089a4fcf933022
parent6353255e7cfab568058580424fa0967bf4504fe5
perf tools: Improve startup time by reducing unnecessary stat() calls

When testing perf trace on NixOS, I noticed significant startup delays:
- `ls`: ~2ms
- `strace ls`: ~10ms
- `perf trace ls`: ~550ms

Profiling showed that 51% of the time is spent reading files,
26% in loading BPF programs, and 11% in `newfstatat`.

This patch optimizes module path exploration by avoiding `stat()` calls
unless necessary. For filesystems that do not implement `d_type`
(DT_UNKNOWN), it falls back to the old behavior.
See `readdir(3)` for details.

This reduces `perf trace ls` time to ~500ms.

A more thorough startup optimization based on command parameters would
be ideal, but that is a larger effort.

Signed-off-by: Krzysztof Łopatowski <krzysztof.m.lopatowski@gmail.com>
Acked-by: Howard Chu <howardchu95@gmail.com>
Link: https://lore.kernel.org/r/20250206113314.335376-2-krzysztof.m.lopatowski@gmail.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/machine.c