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

Fix kwarg pass-through #38

Merged
merged 1 commit into from
Aug 24, 2021
Merged

Fix kwarg pass-through #38

merged 1 commit into from
Aug 24, 2021

Conversation

timholy
Copy link
Member

@timholy timholy commented Aug 24, 2021

No description provided.

Copy link
Member

@johnnychen94 johnnychen94 left a comment

Choose a reason for hiding this comment

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

Looking at the git blame, nobody noticed this until we actually hit it 😄

@timholy
Copy link
Member Author

timholy commented Aug 24, 2021

We should use JET on some of our packages...I can add that to my TODO list.

@johnnychen94
Copy link
Member

Do you mean @test_nodispatch?

@timholy
Copy link
Member Author

timholy commented Aug 24, 2021

No, more the report_file("runtests.jl"). For looking for inference problems, I think SnoopCompile is currently a better approach (it gets all the runtime dispatches, whereas JET does not).

As awesome as JET is, it still sometimes throws its own errors (it seems to on this package's tests). So those might need fixing too.

@timholy
Copy link
Member Author

timholy commented Aug 24, 2021

Also see timholy/SnoopCompile.jl#253

@timholy
Copy link
Member Author

timholy commented Aug 24, 2021

That one worker seems stuck, I'll just merge and release a new version.

@timholy timholy merged commit 392e58a into master Aug 24, 2021
@timholy timholy deleted the teh/kwargs branch August 24, 2021 13:09
@johnnychen94
Copy link
Member

johnnychen94 commented Aug 24, 2021

Just to make sure if I understand it right, so your idea is to put static method analysis as a part of the test? Something like

JET_reports = report_package(ImageIO)
@test JET_reports.nreported == 0

? This would definitely improve the code quality.

@timholy
Copy link
Member Author

timholy commented Aug 24, 2021

No doubt about it. However, for a thorough analysis, that JET/SnoopCompile integration is going to be handy. Currently:

julia> using JET

shell> cd test
/home/tim/.julia/dev/ImageIO/test

julia> report_file("runtests.jl")
[toplevel-info] virtualized the context of Main (took 0.018 sec)
[toplevel-info] entered into runtests.jl
[toplevel-info]  exited from runtests.jl (took 13.994 sec)
═════ 1 toplevel error found ═════
┌ @ runtests.jl:8 
│ UndefVarError: ret not defined
└─────────────────

I couldn't even figure out where ret is, but I'm guessing it's in Test. And this was on the previous master branch of this package, and JET missed the kwargs problem in this PR. That's basically because it was hidden behind an inference failure.

But if you start a fresh session, use that SnoopCompile branch, and do this:

julia> using JET, SnoopCompile

shell> cd test
/home/tim/.julia/dev/ImageIO/test

julia> tinf = @snoopi_deep include("runtests.jl")
[ Info: Threads.nthreads() = 1, multithread tests will be disabled
Test Summary: | Pass  Total
ImageIO       |   64     64
InferenceTimingNode: 7.032328/12.149364 on Core.Compiler.Timings.ROOT() with 358 direct children

julia> itrigs = inference_triggers(tinf);

julia> for itrig in itrigs
           display(report_callee(itrig))
       end
No errors !

═════ 1 possible error found ═════
┌ @ /home/tim/src/julia-master/usr/share/julia/stdlib/v1.8/Logging/src/ConsoleLogger.jl:76 Base.contractuser(file)
│┌ @ path.jl:500 Base.Filesystem.==(path, home)
││┌ @ strings/basic.jl:324 Base.cmp(a, b)
│││┌ @ strings/basic.jl:302 Base.iterate(Base.zip(a, b))
││││┌ @ iterators.jl:340 Base.Iterators._zip_iterate_all(Base.getproperty(z, :is), Base.map(#5, Base.getproperty(z, :is)))
│││││┌ @ iterators.jl:348 Base.Iterators._zip_isdone(is, ss)
││││││┌ @ iterators.jl:380 Base.Iterators.tail(ss)
│││││││┌ @ iterators.jl:380 Base.Iterators._zip_isdone(Base.Iterators.tail(is), Base.Iterators.tail(ss))
││││││││┌ @ iterators.jl:379 Base.getindex(is, 1)
│││││││││┌ @ tuple.jl:29 Base.getfield(t, i, $(Expr(:boundscheck)))
││││││││││ invalid builtin function call: Base.getfield(t::Tuple{}, i::Int64, $(Expr(:boundscheck)))
│││││││││└───────────────

No errors !

No errors !

═════ 1 possible error found ═════
┌ @ strings/io.jl:142 Base.print(s, x)
│┌ @ strings/io.jl:35 Base.show(io, x)
││┌ @ show.jl:881 Base._show_type(io, Base.inferencebarrier(x))
│││┌ @ show.jl:886 Base.show_typealias(io, x)
││││┌ @ show.jl:723 Base.make_typealias(properx)
│││││┌ @ show.jl:533 Base.modulesof!(Core.apply_type(Base.Set, Base.Module)(), x)
││││││┌ @ show.jl:504 Base.push!(s, Base.getproperty(Base.getproperty(x, :name), :module))
│││││││┌ @ set.jl:59 Base.setindex!(Base.getproperty(s, :dict), Base.nothing, x)
││││││││┌ @ dict.jl:382 Base.ht_keyindex2!(h, key)
│││││││││┌ @ dict.jl:349 Base.rehash!(h, _13)
││││││││││┌ @ error.jl:229 Base.getproperty(Main.Base, :string)(msg)
│││││││││││┌ @ strings/io.jl:183 Base.print_to_string(xs...)
││││││││││││┌ @ strings/io.jl:142 Base.print(s, x)
│││││││││││││┌ @ show.jl:1283 Base.show_unquoted(Base.IOContext(io, Base.=>(:unquote_fallback, false)), ex, 0, -1)
││││││││││││││┌ @ show.jl:1758 #self#(io, ex, indent, prec, 0)
│││││││││││││││┌ @ show.jl:2058 Base.mapany(Base.allow_macroname, args)
││││││││││││││││┌ @ abstractarray.jl:2855 Base.map!(f, Core.apply_type(Base.Vector, Base.Any)(Base.undef, Base.length(A)), A)
│││││││││││││││││┌ @ abstractarray.jl:2845 Base.iterate(Base.zip(Base.eachindex(dest), Base.eachindex(A)))
││││││││││││││││││┌ @ iterators.jl:340 Base.Iterators._zip_iterate_all(Base.getproperty(z, :is), Base.map(#5, Base.getproperty(z, :is)))
│││││││││││││││││││┌ @ iterators.jl:348 Base.Iterators._zip_isdone(is, ss)
││││││││││││││││││││┌ @ iterators.jl:380 Base.Iterators._zip_isdone(Base.Iterators.tail(is), Base.Iterators.tail(ss))
│││││││││││││││││││││┌ @ iterators.jl:380 Base.Iterators._zip_isdone(Base.Iterators.tail(is), Base.Iterators.tail(ss))
││││││││││││││││││││││┌ @ iterators.jl:379 Base.getindex(is, 1)
│││││││││││││││││││││││┌ @ tuple.jl:29 Base.getfield(t, i, $(Expr(:boundscheck)))
││││││││││││││││││││││││ invalid builtin function call: Base.getfield(t::Tuple{}, i::Int64, $(Expr(:boundscheck)))
│││││││││││││││││││││││└───────────────

No errors !

═════ 1 possible error found ═════
┌ @ cartesian.jl:44 Base.Cartesian._nloops(Core.tuple(N, itersym, Core._expr(:->, d, Core._expr(:block, $(QuoteNode(:(#= cartesian.jl:44 =#))), Core._expr(:call, $(Expr(:copyast, :($(QuoteNode(:(Base.axes)))))), arraysym, d)))), args...)
│┌ @ cartesian.jl:52 Base.string("number of arguments must be 1 ≤ length(args) ≤ 3, got ", Base.Cartesian.nargs)
││ variable Base.Cartesian.nargs is not defined: Base.string("number of arguments must be 1 ≤ length(args) ≤ 3, got ", Base.Cartesian.nargs)
│└───────────────────

... (goes on for a long time!)

you get a much more comprehensive report.

CC @aviatesk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants