Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable link time optimization for ffmpeg #65

Merged
merged 1 commit into from
Dec 27, 2021
Merged

Enable link time optimization for ffmpeg #65

merged 1 commit into from
Dec 27, 2021

Conversation

Bond-009
Copy link
Member

@Bond-009 Bond-009 commented Apr 8, 2021

No description provided.

docker-build.sh Outdated Show resolved Hide resolved
@joshuaboniface
Copy link
Member

What is the benefit/drawback/impact of this?

@nyanmisaka
Copy link
Member

nyanmisaka commented Apr 13, 2021

What is the benefit/drawback/impact of this?

https://johnysswlab.com/link-time-optimizations-new-way-to-do-compiler-optimizations/

Compilation takes double the time with LTO enabled for both compilers. Linking time is huge with LTO for both compilers, on GCC it’s 86 times slower, on CLANG 48 times slower.

This experiment has shown that, for ffmpeg at least, enabling LTO doesn’t bring expected speed ups.

@Bond-009
Copy link
Member Author

What is the benefit/drawback/impact of this?

All my test are done on ffmpeg master commit 33db0cb
with gcc (GCC) 10.2.0 and clang version 11.1.0
on a Ryzen 7 2700 with 32GB of ram

GCC GCC LTO Clang
build time (s) 105 4,813 95
ffmpeg size 279,584 279,576 275,480
ffprobe size 168,040 155,712 180,344
Benchmark #1: ./ffmpeg_gcc -threads 1 -i BigBuckBunny-AV1.webm -benchmark -f null -
  Time (mean ± σ):      1.188 s ±  0.015 s    [User: 1.175 s, System: 0.013 s]
  Range (min … max):    1.163 s …  1.212 s    10 runs
Benchmark #1: ./ffmpeg_gcc_lto -threads 1 -i BigBuckBunny-AV1.webm -benchmark -f null -
  Time (mean ± σ):      1.180 s ±  0.014 s    [User: 1.167 s, System: 0.012 s]
  Range (min … max):    1.156 s …  1.201 s    10 runs
Benchmark #1: ./ffmpeg_clang -threads 1 -i BigBuckBunny-AV1.webm -benchmark -f null -
  Time (mean ± σ):      1.165 s ±  0.013 s    [User: 1.156 s, System: 0.009 s]
  Range (min … max):    1.150 s …  1.188 s    10 runs

The build time difference on GitHub actions was an increase of 3-5min (on a 20min build)

I'd say it's worth it, even if the advantages are (currently) limited, they will only improve with newer compilers.

@nyanmisaka
Copy link
Member

Don't forget to add it for windows build.

--enable-gpl \

Copy link
Member

@nyanmisaka nyanmisaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LTGM, even though it will slow down the build speed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants