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

Add RTCallInfo for runtime calls #354

Merged
merged 6 commits into from
Mar 8, 2023
Merged

Add RTCallInfo for runtime calls #354

merged 6 commits into from
Mar 8, 2023

Conversation

timholy
Copy link
Member

@timholy timholy commented Mar 1, 2023

The list of call sites serves two purposes:

  • it gives you options to descend into
  • it summarizes the calls made by your function

Given the second purpose, I've sometimes been confused by the absence of an entry for the "worst" of all cases, runtime dispatch. This seems particularly accute for #345, but may have value even when examining the CodeInfo/IRCode.

Here's a demo: on master,

julia> function summer(list)
           s = 0      # deliberately not `zero(eltype(list))`
           for x in list
               s += x
           end
           return s
       end;

julia> @descend optimize=false summer([1.0, 2.0])
 %3 = iterate(::Vector{Float64})::Union{Nothing, Tuple{Float64, Int64}}
   %10 = call  +(::Union{Float64, Int64},::Float64)::Float64
   %11 = iterate(::Vector{Float64},::Int64)::Union{Nothing, Tuple{Float64, Int64}}
   

but

julia> @descend optimize=false summer(Any[1.0, 2.0])
 %3 = iterate(::Vector{Any})::Union{Nothing, Tuple{Any, Int64}}
   %11 = iterate(::Vector{Any},::Int64)::Union{Nothing, Tuple{Any, Int64}}
   

The absence of any "acknowledgement" of the call to + gave me pause.

In contrast, on this branch the first case is unchanged, whereas the second is

%3 = iterate(::Vector{Any})::Union{Nothing, Tuple{Any, Int64}}
   %10 = RT call +(::Any,::Any)::Any
   %11 = iterate(::Vector{Any},::Int64)::Union{Nothing, Tuple{Any, Int64}}
   

I've set it up so that attempting to descend into the RT call gives this:

   %3 = iterate(::Vector{Any})::Union{Nothing, Tuple{Any, Int64}}
 • %10 = RT call +(::Any,::Any)::Any
   %11 = iterate(::Vector{Any},::Int64)::Union{Nothing, Tuple{Any, Int64}}
   ↩
[ Info: This is a runtime call. You cannot descend into it.
Select a call to descend into or ↩ to ascend. [q]uit. [b]ookmark.
Toggles: [o]ptimize, [w]arn, [h]ide type-stable statements, [d]ebuginfo, [r]emarks, [e]ffects, [i]nlining costs, [t]ype annotations, [s]yntax highlight for Source/LLVM/Native.
Show: [S]ource code, [A]ST, [T]yped code, [L]LVM IR, [N]ative code
Actions: [E]dit source code, [R]evise and redisplay
Advanced: dump [P]arams cache.
 • %3 = iterate(::Vector{Any})::Union{Nothing, Tuple{Any, Int64}}
   %10 = RT call +(::Any,::Any)::Any
   %11 = iterate(::Vector{Any},::Int64)::Union{Nothing, Tuple{Any, Int64}}
   ↩

I think filtering out all the Core.Builtin calls will prevent this from being too "noisy," but I'd be grateful for the thoughts of those who know much more about inference than me.

@timholy timholy changed the title RFC: Add RTCallInfo for runtime calls Add RTCallInfo for runtime calls Mar 7, 2023
@timholy
Copy link
Member Author

timholy commented Mar 7, 2023

I'm planning to merge this tomorrow, too.

@vchuravy
Copy link
Member

vchuravy commented Mar 7, 2023

Maybe print it as runtime <+(::Any,::Any)::Any> or dynamic It might not be clear what RT stands for.

timholy added 5 commits March 8, 2023 07:06
The list of call sites serves two purposes:

- it gives you options to descend into
- it summarizes the calls made by your function

Given the second purpose, I've sometimes been confused by the absence
of an entry for the "worst" of all cases, runtime dispatch. This seems
particularly accute for #345, but may have value even when examining
the CodeInfo/IRCode.
@timholy timholy merged commit 3ec146d into master Mar 8, 2023
@timholy timholy deleted the teh/rtcallinfo branch March 8, 2023 13:54
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