-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Check issimpleenoughtype before stripping off type parameters in tmerge #39980
Check issimpleenoughtype before stripping off type parameters in tmerge #39980
Conversation
With
To look into the problem, I tweaked the test a bit diff --git a/test/compiler/codegen.jl b/test/compiler/codegen.jl
index 2b7b266751..3a7d7f0557 100644
--- a/test/compiler/codegen.jl
+++ b/test/compiler/codegen.jl
@@ -68,7 +68,8 @@ end
# This function tests if a toplevel thunk is output if jl_dump_compiles is enabled.
# The eval statement creates the toplevel thunk.
function test_jl_dump_compiles_toplevel_thunks()
- tfile = tempname()
+ # tfile = tempname()
+ tfile = "dump"
io = open(tfile, "w")
# Make sure to cause compilation of the eval function
# before calling it below.
@@ -80,7 +81,8 @@ function test_jl_dump_compiles_toplevel_thunks()
close(io)
tstats = stat(tfile)
tempty = tstats.size == 0
- rm(tfile)
+ # rm(tfile)
@test tempty == true
end and the $ cat test/dump
4123865 "Tuple{Base.var"#582#583"{Base.WeakKeyDict{Distributed.AbstractRemoteRef, Nothing}}, Distributed.Future}" Looking at its method julia> methods(Base.var"#582#583"{Nothing}.instance)
# 1 method for anonymous function "#582":
[1] (::Base.var"#582#583")(k) in Base at weakkeydict.jl:25 suggests that this is from a finalizer Line 25 in caf10d7
So, I added a patch to disable GC in diff --git a/test/compiler/codegen.jl b/test/compiler/codegen.jl
index 2b7b266751..47f419d993 100644
--- a/test/compiler/codegen.jl
+++ b/test/compiler/codegen.jl
@@ -73,11 +73,13 @@ function test_jl_dump_compiles_toplevel_thunks()
# Make sure to cause compilation of the eval function
# before calling it below.
Core.eval(Main, Any[:(nothing)][1])
+ GC.enable(false) # avoid finalizers to be compiled
topthunk = Meta.lower(Main, :(for i in 1:10; end))
ccall(:jl_dump_compiles, Cvoid, (Ptr{Cvoid},), io.handle)
Core.eval(Main, topthunk)
ccall(:jl_dump_compiles, Cvoid, (Ptr{Cvoid},), C_NULL)
close(io)
+ GC.enable(true)
tstats = stat(tfile)
tempty = tstats.size == 0
rm(tfile) This fixes the problem for me. (Edit: included in the PR: 72fb012) Ref: #27086 where " |
Yeah, I encountered that error too before, and it's better to be fixed, I think. |
Actually, my suggestion is to include GC off/on as in my last comment: 72fb012. Is there a downside of turning off GC during this test? Other thing I tried was calling
Yeah I agree we should run it 👍, if the core devs are OK with this patch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd been mildly avoiding this, because of the potential for increased Union exploration time, but I think it does improve associativity, so we perhaps should do it
299d907
to
5239b25
Compare
@nanosoldier |
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @christopher-dG |
So far this doesn't seem to change compile times much, so let's try it. |
…ge (JuliaLang#39980) * Check issimpleenoughtype before stripping off type parameters * Avoid finalizer to be compiled during test_jl_dump_compiles_toplevel_thunks
…ge (JuliaLang#39980) * Check issimpleenoughtype before stripping off type parameters * Avoid finalizer to be compiled during test_jl_dump_compiles_toplevel_thunks
Removing from backports due to #42007 (comment). |
This patch makes the following code inferable
while before we had
This was due to
tmerge
was treating wrapped types specially:after this PR:
This is done simply by checking the complexity of the Union before removing the type constraints of the wrapper types.
I think reducing the difference between the behavior of union of parametric and non-parametric types is nice since it makes easier for Julia programmers to have consistent expectation for when union splitting happens.
My motivation behind this is that Transducers.jl creates "FSMs" at the type level to generate non-trivial reductions, using nested parameterized types. So, it'd be great if we can improve the type inference of small unions of wrapped types. This is particularly useful on GPU where I need to make sure to remove all dynamic dispatches.