KDAB / hotspot

The Linux perf GUI for performance analysis.
4.1k stars 254 forks source link

report issues when parsing files #42

Open milianw opened 7 years ago

milianw commented 7 years ago

parsing perf.data can often produce misleading results when anything is amiss. We need to tell the user about such situations by extending upstream error reporting:

milianw commented 7 years ago

More ideas:

milianw commented 7 years ago

some of this has been implemented now, but not enough to close this task

GitMensch commented 3 years ago

One thing to possibly do is output messages as perf report does:

 ┌─Warning:─────────────────────────────────────────────────────────┐
 │Kernel address maps (/proc/{kallsyms,modules}) were restricted.   │
 │                                                                  │
 │Check /proc/sys/kernel/kptr_restrict before running 'perf record'.│
 │                                                                  │
 │As no suitable kallsyms nor vmlinux was found, kernel samples     │
 │can't be resolved.                                                │
 │                                                                  │
 │Samples in kernel modules can't be resolved as well.              │
 │                                                                  │
 │                                                                  │
 │                                                                  │
 │Press any key...                                                  │
 └──────────────────────────────────────────────────────────────────┘
 ┌─Error:───────────────────────────┐
 │The perf.data file has no samples!│
 │                                  │
 │                                  │
 │Press any key...                  │
 └──────────────────────────────────┘

In this case there's currently an endless "Loading Results..." bar in hotspot-v1.3.0-x86_64-NoRustDemanglingForCentOS7.AppImage

milianw commented 3 years ago

thanks, could you please upload such an empty perf.data file so I can test and reproduce it locally?

GitMensch commented 3 years ago

The likely easiest way to get it is echo 1 | sudo tee /proc/sys/kernel/kptr_restrict, then running perf :-)

milianw commented 3 years ago

That still allows user samples, so my perf.data is not empty:

$ echo 1 | sudo tee /proc/sys/kernel/kptr_restrict
1
$ perf record ls
...
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.002 MB perf.data (9 samples) ]

how did you get the empty perf.data file? can you send it to me please?

GitMensch commented 5 months ago

I was able to create an empty one using:

$> echo "int main() {return 0;}" | gcc -x c -
$> perf record ./out

(note: the original program where this happened was a "real" one, but I can't remember how this happens)

File attached: perf.zip. Using this with hotspot-perfparser leads to:

FINISHED_ROUND detected. Switching to automatic buffering
QPERFSTREAM

I think this once chrashed hotspot, but that's fine now and I don't think we need a special message there.

And just because: I've tested a broken perf recording:

$> perf record none
Failed to collect 'cpu-clock:uhpppH' for the 'none' workload: No such file or directory
$> hotspot-perfparser --input perf.data
Feature announced in header but not present: PerfHeader::HOSTNAME
Feature announced in header but not present: PerfHeader::CPUDESC
Feature announced in header but not present: PerfHeader::CPUID
Feature announced in header but not present: PerfHeader::TOTAL_MEM
Feature announced in header but not present: PerfHeader::CMDLINE
Feature announced in header but not present: PerfHeader::EVENT_DESC
Feature announced in header but not present: PerfHeader::CPU_TOPOLOGY
Feature announced in header but not present: PerfHeader::NUMA_TOPOLOGY
Feature announced in header but not present: PerfHeader::PMU_MAPPINGS
Feature announced in header but not present: PerfHeader::CACHE
Feature announced in header but not present: PerfHeader::SAMPLE_TIME
Feature announced in header but not present: PerfHeader::MEM_TOPOLOGY
Feature announced in header but not present: PerfHeader::BPF_PROG_INFO
Feature announced in header but not present: PerfHeader::BPF_BTF
Feature announced in header but not present: PerfHeader::CPU_PMU_CAPS
feature not properly read PerfHeader::ARCH 13510798882111491 424
feature not properly read PerfHeader::NRCPUS 7311705240702707056 0
feature not properly read PerfHeader::OSRELEASE 9007199254741066 424
feature not properly read PerfHeader::VERSION 16711680 0

^C

hotspot loops with the file that perf "records" that way, so this should be fixed.