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

Investigate why build artifacts are significantly slower with gcc than with clang #14

Closed
mhx opened this issue Nov 30, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@mhx
Copy link
Owner

mhx commented Nov 30, 2020

No description provided.

@mhx mhx added the investigation Likely a can of worms label Nov 30, 2020
@mhx mhx self-assigned this Nov 30, 2020
@mhx mhx added this to the v0.4.1 milestone Mar 9, 2021
@mhx mhx added enhancement New feature or request and removed investigation Likely a can of worms labels Mar 9, 2021
@mhx
Copy link
Owner Author

mhx commented Mar 9, 2021

Found the problem: gcc -O3 is a bad idea. Funnily enough, I was aware that -O3 can cause problems, and that it's for some reason CMake's default. However, I never seemed to connect the dots until now.

mhx@sauron ~ $ hyperfine -L prog git/github/dwarfs/build-clang-11/mkdwarfs,git/github/dwarfs/build-clang-11-O2/mkdwarfs,git/github/dwarfs/build-gcc-10/mkdwarfs,git/github/dwarfs/build-gcc-10-O2/mkdwarfs '{prog} -i install-medium -o /dev
/null -l0 --order=nilsimsa:255:20000:20000 -S24 --window-size=12'                                                                                                                                                                           
Benchmark #1: git/github/dwarfs/build-clang-11/mkdwarfs -i install-medium -o /dev/null -l0 --order=nilsimsa:255:20000:20000 -S24 --window-size=12                                                                                           
  Time (mean ± σ):     14.460 s ±  0.335 s    [User: 85.348 s, System: 13.218 s]                                                                                                                                                            
  Range (min … max):   14.001 s … 14.996 s    10 runs                                                                                                                                                                                       
                                                                                                                                                                                                                                            
Benchmark #2: git/github/dwarfs/build-clang-11-O2/mkdwarfs -i install-medium -o /dev/null -l0 --order=nilsimsa:255:20000:20000 -S24 --window-size=12                                                                              
  Time (mean ± σ):     14.764 s ±  0.177 s    [User: 88.102 s, System: 13.452 s]
  Range (min … max):   14.444 s … 15.117 s    10 runs
  
Benchmark #3: git/github/dwarfs/build-gcc-10/mkdwarfs -i install-medium -o /dev/null -l0 --order=nilsimsa:255:20000:20000 -S24 --window-size=12
  Time (mean ± σ):     20.201 s ±  0.126 s    [User: 93.495 s, System: 13.381 s]
  Range (min … max):   20.087 s … 20.487 s    10 runs
  
Benchmark #4: git/github/dwarfs/build-gcc-10-O2/mkdwarfs -i install-medium -o /dev/null -l0 --order=nilsimsa:255:20000:20000 -S24 --window-size=12
  Time (mean ± σ):     15.253 s ±  0.162 s    [User: 89.495 s, System: 13.316 s]
  Range (min … max):   14.915 s … 15.522 s    10 runs
  
Summary
  'git/github/dwarfs/build-clang-11/mkdwarfs -i install-medium -o /dev/null -l0 --order=nilsimsa:255:20000:20000 -S24 --window-size=12' ran
    1.02 ± 0.03 times faster than 'git/github/dwarfs/build-clang-11-O2/mkdwarfs -i install-medium -o /dev/null -l0 --order=nilsimsa:255:20000:20000 -S24 --window-size=12'
    1.05 ± 0.03 times faster than 'git/github/dwarfs/build-gcc-10-O2/mkdwarfs -i install-medium -o /dev/null -l0 --order=nilsimsa:255:20000:20000 -S24 --window-size=12'
    1.40 ± 0.03 times faster than 'git/github/dwarfs/build-gcc-10/mkdwarfs -i install-medium -o /dev/null -l0 --order=nilsimsa:255:20000:20000 -S24 --window-size=12'

There's some extremely hot code in one particular function that gcc -O3 messes up completely. It's not that clang is without flaws [1], but in general it seems to do a reasonable job with -O3 (and it generates faster code than gcc anyway).

[1] When given the chance to choose between popcount and a set of AVX instruction, clang picks AVX, which turns out to be a lot slower than popcount.

@mhx
Copy link
Owner Author

mhx commented Mar 13, 2021

Fixed in dwarfs-0.4.1.

@mhx mhx closed this as completed Mar 13, 2021
gentoo-bot pushed a commit to gentoo/guru that referenced this issue Mar 15, 2021
New:
* The segmenting code now uses a bloom filter to
  discard unsuccessful matches as early and quickly as possible
* nilsimsa similarity computation has been improved

Fixed:
* GCC builds mhx/dwarfs#14
* Libarchive mhx/dwarfs#36
* mkdwarfs catch certain exceptions correctly

Package-Manager: Portage-3.0.13, Repoman-3.0.2
Signed-off-by: Denis Reva <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant