llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.15k stars 12.03k forks source link

[BOLT] BOLT optimised shared library causes segmentation fault #64143

Open R1chterScale opened 1 year ago

R1chterScale commented 1 year ago

I attempted to use BOLT to optimise SVT-AV1 (also the latest git) for encoding video through ffmpeg, running ffmpeg after BOLT optimising libSvtAv1Enc.so.1.6.0 results in a segfault unfortunately. The steps taken were as follows:

  1. Compile SVT-AV1 with the following flags added to the Arch Linux PKGBUILD, might be of note that this was done on Clang 15.0.6 as it's the current version in the Arch Linux repo: -march=native -mtune=native -Ofast -flto -fprofile-instr-use

  2. Collect PGO profile data by encoding a 1 minute long file with the following encode options ffmpeg -i EncodeSpeedTest.mkv -c:v libsvtav1 -crf 10 -preset 4 -g 240 -svtav1-params tune=0:enable-overlays=1:scd=1:rc=0:keyint=240:input-depth=10:film-grain=10:film-grain-denoise=0 -pix_fmt yuv420p10le -c:a copy ESTPGO.mkv

  3. Rebuild with profile data used, binary stripping disabled, and emitting relocs. (It runs at this point with a notable performance uplift)

4: Add instrumentation with llvm-bolt

5: Collect BOLT profile data with a repeat of the previous encode

6: Optimise with BOLT using the example command

7: Attempt to encode once again, a segfault occurs

I attempted to grab the backtrace from the core dump but I'm very much a novice with these things so I'm not sure if this is useful:

(gdb) bt
#0  0x00007f9bca0f2640 in svt_aom_highbd_h_predictor_4x16_sse2 () at /usr/lib/libSvtAv1Enc.so.1
#1  0x00007f9bca0e6f61 in svt_dav1d_inv_txfm_add_avx2 () at /usr/lib/libSvtAv1Enc.so.1
#2  0x00007f9bca070a4d in svt_aom_full_loop_uv () at /usr/lib/libSvtAv1Enc.so.1
#3  0x00007f9bca05f860 in full_loop_core () at /usr/lib/libSvtAv1Enc.so.1
#4  0x00007f9bca055ce8 in md_encode_block () at /usr/lib/libSvtAv1Enc.so.1
#5  0x00007f9bca0476ee in svt_aom_mode_decision_sb () at /usr/lib/libSvtAv1Enc.so.1
#6  0x00007f9bca0439ea in svt_aom_mode_decision_kernel () at /usr/lib/libSvtAv1Enc.so.1
#7  0x00007f9bcd6970af in  () at /usr/lib/libc.so.6
#8  0x00007f9bcd7299f0 in  () at /usr/lib/libc.so.6
llvmbot commented 1 year ago

@llvm/issue-subscribers-bolt

aaupov commented 1 year ago

Can you please post BOLT instrumentation and optimization logs?