facebookarchive / BOLT

Binary Optimization and Layout Tool - A linux command-line utility used for optimizing performance of binaries
2.51k stars 176 forks source link

perf2bolt: Assertion error and core dumped when convert perf data from ffmpeg #78

Open JingyZhu opened 4 years ago

JingyZhu commented 4 years ago

I'm trying to use BOLT to optimize the performance for ffmpeg. I compiled ffmpeg with -Wl,--emic-relocs flag, produced the perf data by running:

perf record -e cycles:u -j any,u -o perf_record/bolt/test.data /home/chenyh/eecs582/vbench/bin/ffmpeg -i /home/chenyh/eecs582/vbench/crf0/holi_854x480_30.mkv -c:v libx264 -threads 1 -crf 18 -y ../output/holi_854x480_30.mkv

However, when I'm trying to convert the test.data to test.fdata, perf2bolt has the assertion error and caused core dumped. Here is the stack trace:

PERF2BOLT: Starting data aggregation job for ../../../vbench/profiling/perf_record/bolt/test.data
PERF2BOLT: spawning perf job to read branch events
PERF2BOLT: spawning perf job to read mem events
PERF2BOLT: spawning perf job to read process events
PERF2BOLT: spawning perf job to read task events
BOLT-INFO: Target architecture: x86_64
BOLT-INFO: first alloc address is 0x400000
BOLT-INFO: creating new program header table at address 0x2000000, offset 0x1c00000
BOLT-INFO: enabling relocation mode
BOLT-INFO: binary build-id is:     3e7e741a18d630ab08f4410c701ffc838bbaa783
PERF2BOLT: spawning perf job to read buildid list
PERF2BOLT: matched build-id and file name
BOLT-INFO: enabling strict relocation mode for aggregation purposes
BOLT-INFO: spawning thread to pre-process profile
PERF2BOLT: waiting for perf mmap events collection to finish...
PERF2BOLT: parsing perf-script mmap events output
PERF2BOLT: waiting for perf task events collection to finish...
PERF2BOLT: parsing perf-script task events output
PERF2BOLT: input binary is associated with 1 PID(s)
PERF2BOLT: waiting for perf events collection to finish...
PERF2BOLT: parse branch events...
PERF2BOLT: read 27841 samples and 439687 LBR entries
PERF2BOLT: 0 samples (0.0%) were ignored
PERF2BOLT: traces mismatching disassembled function contents: 234 (0.1%)
PERF2BOLT: out of range traces involving unknown regions: 2388 (0.6%)
perf2bolt: /home/chenyh/eecs582/llvm/llvm/tools/llvm-bolt/src/BinaryFunction.cpp:1134: void llvm::bolt::BinaryFunction::disassemble(): Assertion `truncateToSize(static_cast<uint64_t>(Value), Relocation::getSizeForType(Relocation.Type)) == truncateToSize(Relocation.Value, Relocation::getSizeForType(Relocation.Type)) && "immediate value mismatch in function"' failed.
#0 0x000000000105808a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (./perf2bolt+0x105808a)
#1 0x0000000001055f1e llvm::sys::RunSignalHandlers() (./perf2bolt+0x1055f1e)
#2 0x0000000001056092 SignalHandler(int) (./perf2bolt+0x1056092)
#3 0x00007f64f3c1c390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#4 0x00007f64f292b428 gsignal /build/glibc-LK5gWL/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0
#5 0x00007f64f292d02a abort /build/glibc-LK5gWL/glibc-2.23/stdlib/abort.c:91:0
#6 0x00007f64f2923bd7 __assert_fail_base /build/glibc-LK5gWL/glibc-2.23/assert/assert.c:92:0
#7 0x00007f64f2923c82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)
#8 0x00000000004c7b08 llvm::bolt::BinaryFunction::disassemble() (./perf2bolt+0x4c7b08)
#9 0x0000000000575ca2 llvm::bolt::RewriteInstance::disassembleFunctions() (./perf2bolt+0x575ca2)
#10 0x00000000005b81e8 llvm::bolt::RewriteInstance::run() (./perf2bolt+0x5b81e8)
#11 0x00000000004467da main (./perf2bolt+0x4467da)
#12 0x00007f64f2916830 __libc_start_main /build/glibc-LK5gWL/glibc-2.23/csu/../csu/libc-start.c:325:0
#13 0x000000000048e8f9 _start (./perf2bolt+0x48e8f9)
Stack dump:
0.  Program arguments: ./perf2bolt -p ../../../vbench/profiling/perf_record/bolt/test.data -o ../../../vbench/test.fdata ../../../vbench/bin/ffmpeg
[1]    32661 abort (core dumped)  ./perf2bolt -p ../../../vbench/profiling/perf_record/bolt/test.data -o

What could be the cause of the problem? Thanks in advance!

dongAxis commented 3 years ago

any update?