#Release Builds Slower than Debug by a lot.

1 messages · Page 1 of 1 (latest)

minor storm
#

I was working on solving project euler problems in zig 0.15.2
this problem where i had to find the first 1000 digit fib. so this is the code that i could come up with, (i dont know any optimisations yet)
Even the building time is greater than 1min.
(I use Nushell)
These are the benchmarks.(sorry if its a little vague)

~/Desktop/Programming/zig/Project-Euler> zig build-exe 1000-digit_fib.zig ; mv 1000-digit_fib fib_n_digit

~/Desktop/Programming/zig/Project-Euler> timeit {./fib_n_digit 3}
first 3 digit fib: 144
1ms 664µs 348ns

~/Desktop/Programming/zig/Project-Euler> timeit {./fib_n_digit 100}
first 100 digit fib: 1344719667586153181419716641724567886890850696275767987106294472017884974410332069524504824747437757
87ms 551µs 749ns

~/Desktop/Programming/zig/Project-Euler> zig build-exe -OReleaseFast 1000-digit_fib.zig ; mv 1000-digit_fib fib_n_digit

~/Desktop/Programming/zig/Project-Euler> timeit {./fib_n_digit 3}
first 3 digit fib: 144
1ms 747µs 496ns

~/Desktop/Programming/zig/Project-Euler> timeit {./fib_n_digit 100}
first 100 digit fib: 1344719667586153181419716641724567886890850696275767987106294472017884974410332069524504824747437757
8sec 687ms 467µs 890ns

~/Desktop/Programming/zig/Project-Euler> zig build-exe -OReleaseSafe 1000-digit_fib.zig ; mv 1000-digit_fib fib_n_digit

~/Desktop/Programming/zig/Project-Euler> timeit {./fib_n_digit 3}
first 3 digit fib: 144
3ms 377µs 501ns

~/Desktop/Programming/zig/Project-Euler> timeit {./fib_n_digit 100}
first 100 digit fib: 1344719667586153181419716641724567886890850696275767987106294472017884974410332069524504824747437757
8sec 843ms 478µs 807ns

keen thunder
#

llvm isn't good with with the large unsigned numbers you are using the the default debug mode on x86_64 linux and macos is to build without llvm
the release modes use llvm

you will see the same problem if you build in debug but use llvm
zig build-exe -fllvm file-name.zig

#

if you want to know why the native zig backend is much better at those very large sizes I couldn't tell you exactly

keen thunder
#

debug with llvm seemed to never actually finish building for me at least after waiting like 5-10 mins (I just came back and it wasn't done)

sweet shadow
#

Native backend doesn't really try to do anything as far as I'm aware so it just gets better performance by default

minor storm
sweet shadow
# minor storm Will it get updated in the future versions. or are we stuck if we want to releas...

The bug here is on LLVM's side. Zig's core team could try and submit some PRs but they're likely too busy. There's a couple issues that have been open for a little bit now. Unsure of what's happening with them. What I found from some brief searching, if you're interested in tracking this, or whatever you want:
https://github.com/llvm/llvm-project/issues/96488
https://github.com/llvm/llvm-project/issues/126383
https://github.com/llvm/llvm-project/issues/126384
Possibly https://github.com/llvm/llvm-project/issues/164632