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

snoop_inference is broken on latest after stackless inference change #56115

Open
NHDaly opened this issue Oct 11, 2024 · 6 comments · Fixed by #57074
Open

snoop_inference is broken on latest after stackless inference change #56115

NHDaly opened this issue Oct 11, 2024 · 6 comments · Fixed by #57074
Assignees
Labels
caching compiler:precompilation Precompilation of modules observability metrics, timing, understandability, reflection, logging, ...
Milestone

Comments

@NHDaly
Copy link
Member

NHDaly commented Oct 11, 2024

We should be able to restore basically the old behavior with the new stack.

I wasn't certain how to maintain the old code, since it was working with incomplete and inaccurate information available. Now all required information is available in function typeinf(interp::AbstractInterpreter, frame::InferenceState), so this could be reimplemented there in some form.

Originally posted by @vtjnash in #55575 (comment)

@NHDaly NHDaly added this to the 1.12 milestone Oct 11, 2024
@NHDaly NHDaly added the observability metrics, timing, understandability, reflection, logging, ... label Oct 11, 2024
@NHDaly
Copy link
Member Author

NHDaly commented Oct 18, 2024

CC: @timholy

@timholy timholy assigned timholy and NHDaly and unassigned NHDaly Oct 21, 2024
@maleadt
Copy link
Member

maleadt commented Nov 27, 2024

FWIW, this also affects PrecompileTools.jl.

@KristofferC
Copy link
Member

Can we confirm that PrecompileTools and SnoopCompile works properly brute closing this?

@KristofferC KristofferC reopened this Mar 17, 2025
@IanButterworth
Copy link
Member

IanButterworth commented Mar 17, 2025

Attempts to validate this:

% ./julia --trace-compile=stderr --trace-compile-timing --start=no -q
julia> #=   17.3 ms =# precompile(Tuple{Base.var"#readcb_specialized#uv_readcb##0", Base.TTY, Int64, UInt64})
#=   16.5 ms =# precompile(Tuple{typeof(Base.peek), Base.TTY, Type{UInt8}})
#=    6.8 ms =# precompile(Tuple{typeof(Base.get), Base.Dict{Char, Any}, Char, Nothing})
#=   11.2 ms =# precompile(Tuple{typeof(Base.Compiler.scan_specified_partitions), Base.Compiler.var"#global_assignment_rt_exct##0#global_assignment_rt_exct##1"{Type{Float64}}, Base.Compiler.var"#scan_partitions##0#scan_partitions##1", Base.Compiler.NativeInterpreter, GlobalRef, Base.Compiler.WorldWithRange})
#=   16.6 ms =# precompile(Tuple{typeof(REPL.Pkg_promptf)})
#=    1.4 ms =# precompile(Tuple{typeof(Base.Unicode.textwidth), String})
(@v1.13) pkg> #=    3.2 ms =# precompile(Tuple{REPL.var"#setup_interface##26#setup_interface##27"{REPL.LineEdit.MIState, REPL.LineEditREPL, REPL.LineEdit.Prompt}})
#=    5.4 ms =# precompile(Tuple{REPL.var"#setup_interface##28#setup_interface##29"{Module, REPL.LineEditREPL, REPL.LineEdit.Prompt}, REPL.LineEdit.MIState})
#=    2.9 ms =# precompile(Tuple{REPL.var"#setup_interface##30#setup_interface##31"{REPL.LineEdit.MIState, REPL.LineEdit.Prompt}})
(@v1.13) pkg> s#=   20.2 ms =# precompile(Tuple{typeof(Core.kwcall), NamedTuple{names, T} where T<:Tuple where names, typeof(REPL.LineEdit.complete_line), REPL.LineEdit.CompletionProvider, Any, Module})
#=    9.5 ms =# precompile(Tuple{typeof(Base.filter), REPLExt.var"#47#48", Array{String, 1}})
(@v1.13) pkg> sta#=   67.9 ms =# precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:color,), Tuple{Symbol}}, typeof(Base.printstyled), REPL.Terminals.TTYTerminal, String})
tus#=    1.6 ms =# precompile(Tuple{typeof(REPL.Terminals.cmove_left), REPL.Terminals.TTYTerminal, Int64})
(@v1.13) pkg> status
#=    6.0 ms =# precompile(Tuple{Base.Returns{Symbol}, Any})
#=    5.7 ms =# precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Base.GenericIOBuffer{Memory{UInt8}}, Bool, Bool}, Int64})
#=    5.3 ms =# precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Base.GenericIOBuffer{Memory{UInt8}}, Bool, Bool}, Int64, Int64})
#=    4.0 ms =# precompile(Tuple{REPLExt.var"#create_mode##0#create_mode##1"{REPL.LineEditREPL}, REPL.LineEdit.MIState, Base.GenericIOBuffer{Memory{UInt8}}, Bool})
#=    2.7 ms =# precompile(Tuple{typeof(Base.length), Array{Pkg.Types.PackageSpec, 1}})
#=   12.9 ms =# precompile(Tuple{Pkg.API.var"##status#108", Base.IOContext{IO}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, typeof(Pkg.API.status), Array{Pkg.Types.PackageSpec, 1}})
#=    2.9 ms =# precompile(Tuple{Base.var"#698#699"{Base.Process}})
#=    3.0 ms =# precompile(Tuple{Type{Array{Dates.DateTime, 1}}, UndefInitializer, Tuple{Int64}})
#=    1.5 ms =# precompile(Tuple{Type{Pair{A, B} where B where A}, String, Dates.DateTime})
#=    2.5 ms =# precompile(Tuple{typeof(Base.similar), Array{Any, 1}})
#=    2.2 ms =# precompile(Tuple{typeof(Base.similar), Array{String, 1}})
#=    1.3 ms =# precompile(Tuple{typeof(Base.Iterators.enumerate), Array{String, 1}})
#=    1.7 ms =# precompile(Tuple{typeof(Base.setindex!), Array{String, 1}, String, Int64})
#=    1.9 ms =# precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:io,), Tuple{Base.IOContext{IO}}}, typeof(Pkg.API.status), Pkg.Types.Context, Array{Pkg.Types.PackageSpec, 1}})
#=    1.1 ms =# precompile(Tuple{typeof(Base.print), Base.IOContext{Base.GenericIOBuffer{Memory{UInt8}}}, Char})
Status#=    2.1 ms =# precompile(Tuple{typeof(Base.lock), Base.TTY})
 `~/.julia/environments/v1.13/Project.toml`
#=    2.4 ms =# precompile(Tuple{typeof(Base.unlock), Base.TTY})
#=    1.3 ms =# precompile(Tuple{typeof(Base.values), Base.Dict{String, Any}})
#=   10.2 ms =# precompile(Tuple{typeof(Base.Broadcast.broadcasted), Type{Base.UUID}, Base.ValueIterator{Base.Dict{String, Any}}})
#=    9.8 ms =# precompile(Tuple{typeof(Base.Broadcast.materialize), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, Type{Base.UUID}, Tuple{Array{Any, 1}}}})

@IanButterworth
Copy link
Member

Looks like it's still broken JuliaGPU/GPUCompiler.jl#676 (comment)

KristofferC pushed a commit that referenced this issue Mar 21, 2025
Adds 4 new Float16 fields to CodeInstance to replace Compiler.Timings
with continually collected and available measurements.

Sample results on a novel method signature:

julia> @time code_native(devnull, ÷, dump_module=false, (Int32,
UInt16));
0.006262 seconds (3.62 k allocations: 186.641 KiB, 75.53% compilation
time)

    julia> b = which(÷, (Int32, UInt16)).specializations[6].cache
    CodeInstance for MethodInstance for div(::Int32, ::UInt16)

    julia> reinterpret(Float16, b.time_infer_self)
    Float16(0.0002766)

    julia> reinterpret(Float16, b.time_infer_total)
    Float16(0.00049)

    julia> reinterpret(Float16, b.time_infer_cache_saved)
    Float16(0.02774)

    julia> reinterpret(Float16, b.time_compile)
    Float16(0.003773)

Closes #56115

(cherry picked from commit 18b5d8f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
caching compiler:precompilation Precompilation of modules observability metrics, timing, understandability, reflection, logging, ...
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants