Community Packages

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#72131 - Missing optimization because of inconsistent relation between Julia and llvm ?

Attached to Project: Community Packages
Opened by Iago-lito (iago-lito) - Tuesday, 14 September 2021, 12:30 GMT
Last edited by Antonio Rojas (arojas) - Wednesday, 15 September 2021, 14:11 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Antonio Rojas (arojas)
Architecture x86_64
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description: The `julia` packages uses local `llvm` version 12 instead of version 11 like the official julia binary. As a (likely) consequence, one optimization is not performed.

This julia file:
```julia
using BenchmarkTools
BenchmarkTools.DEFAULT_PARAMETERS.seconds = 1

function average(collection)
cumsum = 0
for value in collection
cumsum += value
end
cumsum / length(collection)
end

r1 = 1:1_000_000
r2 = 1:2_000_000

println("ranges")
@btime average($r1)
@btime average($r2)
```

Outputs something like the following when using the official `julia` binary:
```
3.168 ns (0 allocations: 0 bytes)
2.675 ns (0 allocations: 0 bytes)
```
The time complexity has been optimized to O(1) with internal use of the triangular number `N * (N + 1) / 2`.

But with the `julia` binary obtained from vanilla `pacman` installation, I get:
```
440.674 μs (0 allocations: 0 bytes)
898.528 μs (0 allocations: 0 bytes)
```
No optimization is made, and time complexity in O(N).


The only difference I noticed is the LLVM version and the `*` next to commit number, here with the `pacman` version:
```
$ /usr/bin/julia
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.6.2 (2021-07-14)
_/ |\__'_|_|_|\__'_| |
|__/ |

julia> versioninfo()
Julia Version 1.6.2
Commit 1b93d53fc4* (2021-07-14 15:36 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-12.0.1 (ORCJIT, skylake)
```

.. and here with the official binary:
```
$ ./julia-1.6.2/bin/julia
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.6.2 (2021-07-14)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |

julia> versioninfo()
Julia Version 1.6.2
Commit 1b93d53fc4 (2021-07-14 15:36 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
```

.. should this be reported here, or at Julia's, or at LLVM?
This task depends upon

Closed by  Antonio Rojas (arojas)
Wednesday, 15 September 2021, 14:11 GMT
Reason for closing:  Fixed
Additional comments about closing:  julia 1.6.2-4
Comment by Iago-lito (iago-lito) - Tuesday, 14 September 2021, 12:31 GMT
(note: this is not an "out-of-date" problem but rather an "ahead-of-date" problem, right?)
Comment by Iago-lito (iago-lito) - Tuesday, 14 September 2021, 12:35 GMT
I realize the benchmark package may be missing. Prefix file with:
```julia
using Pkg
pkg"add BenchmarkTools"
```
to fully reproduce.
Comment by Antonio Rojas (arojas) - Tuesday, 14 September 2021, 22:46 GMT
The version is irrelevant. The difference is either some compilation flag or some of the many patches they're applying
https://github.com/JuliaLang/julia/blob/release-1.6/deps/llvm.mk

EDIT: using the bundled LLVM without any of the patches is also fast, must be some compilation flag.
Comment by Iago-lito (iago-lito) - Wednesday, 15 September 2021, 10:29 GMT
Okay, so I understand that this is not the result of some regression introduced in LLVM 12.. but I'm not sure what's the problem then. In particular, should I report upstream to Julia? Or is the problem in arch repos?
Comment by Antonio Rojas (arojas) - Wednesday, 15 September 2021, 10:59 GMT
No, this is an issue with our package.

Loading...