Aggressively propagate constant bases through ndigits and string(::Integer)#62222
Conversation
bd4950d to
b9dbdab
Compare
ndigitsndigits and string
ndigits and stringndigits and string(::Integer)
|
Ok, the first test failure seems unrelated to the PR, but now all 4 JuliaC tests are failing after the It's not because of the union-splitting with |
|
Try rebasing on master. The failure really does look unrelated. |
|
I threw an agent at the problem. Here's what it came up with (paraphrased by me):
This is not an issue with your PR, even though it maybe is triggered by your PR. |
Have already done that, the PR is currently sitting on the latest master commit.
Probably not,
I really think that a slight change in inlining due to the constant propagation in My first thought was in agreement with the conclusion that something in Also this iteration over |
|
Anyway the same error can be reproduced by building Julia with this PR and running something like (after substituting appropriate directories) It does succeed without EDIT: after further research, it's probably related to #60331, which was closed after some lines were added to JuliaC. Unfortunately while they are still there, it doesn't seem to help now... |
d3b8508 to
6ff20b3
Compare
|
After further investigation, I confirmed that it's indeed possible to make some trim errors go away by manually inlining certain functions in the call chain of these errors, but it's not realistic to do that as there are too many e.g. functions with exceptions that interpolate integers into error messages. I think the inlining simply enables the optimizer to elide the error branches in these cases that call I've removed the commit that did away with the Signed/Unsigned small union since it's not the issue. Hopefully someone sees fit to investigate the trimming issues that the constant propagation causes 🙏 FWIW, the micro-benchmarks with this PR look great vs master (1d641c7). I imagine it makes the compiled code for the functions that inline them nicer as well. It also doesn't bloat the sysimage that much, the julia> @btime string(5);
9.910 ns (1 allocation: 32 bytes) # PR
11.046 ns (1 allocation: 32 bytes) # master
julia> @btime string("foo", 5);
86.316 ns (4 allocations: 160 bytes) # PR
110.577 ns (4 allocations: 160 bytes) # master
julia> @btime string("foo", 5, 6);
118.666 ns (5 allocations: 192 bytes) # PR
168.307 ns (5 allocations: 192 bytes) # master |
|
Sorry for the The cryptic (seemingly unrelated) IMO we need to fix this in the 1.14 timeframe - #61983 is an attempt, but @vtjnash wants us to merge a more proper solution that will re-work our inference cache more completely |
|
Must be quite unlucky to hit that... |
|
@topolarity Thanks for the input.
I would argue 1. is probably preferable, since in practice, choosing 2. will lead to lots of time wasted, and anyone hitting a trim error in CI will say "well, trimming CI is broken anyway so we should merge this regardless", so keeping in JuliaC CI won't really buy much. But maybe that's reckless? By the way, we should merge this since the only failures are JuliaC ;) |
a7fe84c to
8fd1fc3
Compare
|
@topolarity are you ok with merging this? Should we temp disable JuliaC CI? Don't want to block PRs like this for weeks while there is deliberation how to fix some a bug in a separate system. |
I think I am - I'd like to try to merge #61983 ASAP but it may not be until next week that I can get to that. I am OK with temporary regressions to fix until then
We should (can't break CI) Appreciate the follow-up ping BTW - sorry for not responding sooner @jakobnissen you caught me on vacation |
8fd1fc3 to
8f5f57f
Compare
|
|
The macOS build / test failures are probably not related, since it's the same for other recent PRs. Also the intermittent i686-w64-mingw32 failures, although that's a bit more concerning because
Another is "spawn and wait lots of tasks". but idk. |
Annotated `ndigits0zpb` and `ndigits0z` with `@constprop :aggressive`.
make clear that `split_sign` returns a tuple
8f5f57f to
7d02fcf
Compare
|
No ball. Same error. Aside, what is happening with the macOS build / test failures... |
Looks good to me: https://buildkite.com/julialang/julia-pr/builds/267#019f4972-13c6-4b68-9f78-594b96c9328c/L959 Maybe you were looking at the old build?
CI is volatile / has some regressions right now while the infrastructure is recovering from a security issue a couple weeks ago. You can peek at |
|
Right, probably was looking at the old one. I'm pretty sure I did click in from GitHub though...sighs |
|
Been there haha - Glad you might be unblocked here👍 |
|
All green! Good to merge now? 🙂 |
By annotating
ndigits0zpb,ndigits0z, andstring(::Integer)with@constprop :aggressive.This helps
ndigits(x; base)with the common constant bases of 10 or a small power of 2, removing two extra function calls (ndigits0z,ndigits0zpb) when optimized.Also does the same with
string(::Integer; base)for constant bases 2, 8, 16, and 10 (the default), so the function would then be inlined to just a call tobin,oct,hex, ordec.On 1.13-rc1:
PR: