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

[release-0.6] help #24383 inference and load time regression #24399

Merged
merged 1 commit into from
Nov 14, 2017

Conversation

JeffBezanson
Copy link
Member

If this works, a similar version is applicable to master.

This change has two parts. First, I modified the union-splitting logic in method lookup to only infer split signatures that are concrete. This prunes a bunch of the inference tree, reducing BandedMatrices.ji from ~100MB to ~40MB.

Next there is a load time problem where jl_recache_types is O(n^2). (A lot of time is also spent inserting methods and backedges, but if the jl_recache_types change works it's an easy fix.) @vtjnash will have to review to see if this is valid. If it's not, it can be dropped from the patch and there's still a significant improvement.

With this, using BandedMatrices (including precompilation) takes ~3 minutes for me instead of ~20.

ref #24383

@JeffBezanson JeffBezanson added compiler:inference Type inference performance Must go faster compiler:precompilation Precompilation of modules labels Oct 29, 2017
@ararslan ararslan requested a review from vtjnash October 29, 2017 21:42
@vtjnash
Copy link
Member

vtjnash commented Oct 30, 2017

will have to review to see if this is valid

Yeah, that looks fine. In my analysis of all packages on my system, this list had ~10-1000 items originally (edit: usually around 10 originally, and now usually in the low hundreds), so I didn't worry about optimizing it (and the assertion there was pretty helpful in shaking out latent problems that it used to have).

The change to the union-splitting logic seems less advisable though (it's covering for subtyping returning incorrect type variable bounds, leading to incorrect eltype deductions), but also valid.

@JeffBezanson
Copy link
Member Author

I'll work on that. We should really make sure the inferred static parameter values are sound no matter what.

@JeffBezanson JeffBezanson force-pushed the jb/0.6-load-time branch 2 times, most recently from c3f5f5f to 931b322 Compare October 30, 2017 17:46
@JeffBezanson
Copy link
Member Author

Ok, I think this might be good now. I would say a PkgEval run is warranted however.

if (!oldval || !jl_is_typevar(oldval) || !jl_is_long(val))
if (oldval && !jl_egal(oldval, val))
e->envout[e->envidx] = (jl_value_t*)u->var;
else
Copy link
Member

Choose a reason for hiding this comment

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

this commit should probably be put on master first

let T1 = Array{Float64}, T2 = Array{_1,2} where _1
inference_test_copy(a::T) where {T<:Array} = ccall(:jl_array_copy, Ref{T}, (Any,), a)
rt = Base.return_types(inference_test_copy, (Union{T1,T2},))[1]
@test rt >: T1 && rt >: T2
Copy link
Member

Choose a reason for hiding this comment

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

This should be testing for equality to something. I know you only want to test for strongly valid properties, but as written, I can't verify that this test is testing for the reported issue. And it could also break again later without noticing that this test was later rendered ineffectual.

Copy link
Member Author

Choose a reason for hiding this comment

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

The brokenness before was that rt >: T1 && rt >: T2 did not hold. So if it broke again the test would fail.

JeffBezanson added a commit that referenced this pull request Oct 30, 2017
JeffBezanson added a commit that referenced this pull request Oct 30, 2017
…g of large precompiled packages.

extracted from #24399
JeffBezanson added a commit that referenced this pull request Oct 31, 2017
…g of large precompiled packages. (#24407)

extracted from #24399
@ViralBShah
Copy link
Member

Would be great if @ChrisRackauckas can try this out.

@ChrisRackauckas
Copy link
Member

I don't have the setup to build everything right now, but my test would be to just check using BandedMatrices like @JeffBezanson did, so since that worked, 👍 .

ararslan pushed a commit that referenced this pull request Nov 4, 2017
JeffBezanson added a commit that referenced this pull request Nov 7, 2017
ararslan pushed a commit that referenced this pull request Nov 7, 2017
…g of large precompiled packages. (#24407)

extracted from #24399

(cherry picked from commit b8d42d4)
ararslan pushed a commit that referenced this pull request Nov 8, 2017
…g of large precompiled packages. (#24407)

extracted from #24399

(cherry picked from commit b8d42d4)
ararslan pushed a commit that referenced this pull request Nov 8, 2017
…g of large precompiled packages. (#24407)

extracted from #24399

(cherry picked from commit b8d42d4)
ararslan pushed a commit that referenced this pull request Nov 8, 2017
…g of large precompiled packages. (#24407)

extracted from #24399

(cherry picked from commit b8d42d4)
ararslan pushed a commit that referenced this pull request Nov 8, 2017
…g of large precompiled packages. (#24407)

extracted from #24399

(cherry picked from commit b8d42d4)
ararslan pushed a commit that referenced this pull request Nov 9, 2017
…g of large precompiled packages. (#24407)

extracted from #24399

(cherry picked from commit b8d42d4)
@ararslan
Copy link
Member

Bump @JeffBezanson. It would be great if we could get this merged so that it can go into 0.6.2.

reduce O(n^2) behavior of `jl_recache_types`

improve soundness of inferred typevar bounds in subtyping

these help #24383
@JeffBezanson
Copy link
Member Author

Rebased. Merge when ready if the test failures are expected.

@ararslan
Copy link
Member

Yep, they are. The release-0.6 branch doesn't have the CircleCI configuration file, any of the commits that got Julia building on FreeBSD, or the fixes for Travis that allow IPv6. (The Travis change is being backported.) Thanks Jeff!

@ararslan ararslan merged commit cf2ed66 into release-0.6 Nov 14, 2017
@ararslan ararslan deleted the jb/0.6-load-time branch November 14, 2017 19:43
@ararslan
Copy link
Member

This appears to have broken JuliaDB (based on a git bisect). Should it be reverted from the release-0.6 branch, or would you rather submit some kind of fix for the case it's hitting?

@JeffBezanson
Copy link
Member Author

How can I get more info on the failure?

ararslan added a commit that referenced this pull request Nov 20, 2017
…erence (#24399)"

This reverts commit cf2ed66.
It was determined to cause package regressions.
@ararslan
Copy link
Member

Build the release-0.6 branch and run Pkg.test("JuliaDB"). The log from PkgEval is also available here.

ararslan added a commit that referenced this pull request Nov 21, 2017
…erence (#24399)"

This reverts commit cf2ed66.
It was determined to cause package regressions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:inference Type inference compiler:precompilation Precompilation of modules performance Must go faster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants