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

docs! #192

Merged
merged 2 commits into from
Jan 5, 2021
Merged

docs! #192

merged 2 commits into from
Jan 5, 2021

Conversation

timholy
Copy link
Owner

@timholy timholy commented Dec 29, 2020

Yay, the long wait is over! This isn't even comprehensive (it barely touches on flatten, accumulate_by_source, etc.) but it should get everyone going. I've also found that many of those earlier utilities are not as useful as more focused tools like inference_triggers and parcel.

This is currently based on top of #191.

Copy link

@tpapp tpapp left a comment

Choose a reason for hiding this comment

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

trivial suggestion: doc refs

There are many different ways of inspecting and using the data stored in `tinf`.
The simplest is to load the `AbstracTrees` package and display the tree with
`AbstractTrees.print_tree(tinf)`.
See also: `flamegraph`, `flatten`, `inference_triggers`, `SnoopCompile.parcel`,
Copy link

Choose a reason for hiding this comment

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

Suggested change
See also: `flamegraph`, `flatten`, `inference_triggers`, `SnoopCompile.parcel`,
See also: [`flamegraph`](@ref), [`flatten`](@ref), [`inference_triggers`](@ref), `SnoopCompile.parcel`,

Copy link
Owner Author

Choose a reason for hiding this comment

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

Good idea, but the problem is that this is in SnoopCompileCore and those methods are in SnoopCompile. Documenter doesn't yet like cross-package references. I need to finish up JuliaDocs/Documenter.jl#1352

The simplest is to load the `AbstracTrees` package and display the tree with
`AbstractTrees.print_tree(tinf)`.
See also: `flamegraph`, `flatten`, `inference_triggers`, `SnoopCompile.parcel`,
`runtime_inferencetime`.
Copy link

Choose a reason for hiding this comment

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

Suggested change
`runtime_inferencetime`.
[`runtime_inferencetime`](@ref).

@tpapp
Copy link

tpapp commented Jan 3, 2021

Which branch should one use to test it out? I removed SnoopCompilerCore as a separate package (which seems to be part of this one now), but from this branch it does not load the _deep tools:

(@v1.6) pkg> st SnoopCompile
Status `~/.julia/environments/v1.6/Project.toml`
  [aa65fe97] SnoopCompile v2.1.2 `https://github.com/timholy/SnoopCompile.jl.git#teh/docs`

julia> using SnoopCompile

julia> names(SnoopCompile)
10-element Vector{Symbol}:
 Symbol("@snoopc")
 Symbol("@snoopi")
 Symbol("@snoopr")
 :SnoopCompile
 :ascend
 :filtermod
 :findcaller
 :invalidation_trees
 :read_snoopl
 :uinvalidated

julia> VERSION
v"1.6.0-DEV.1780"

@timholy
Copy link
Owner Author

timholy commented Jan 3, 2021

It's both separate and together: the usual dependency rules mean you get SnoopCompileCore if you install SnoopCompile. But the oddity is that if you dev SnoopCompile but not SnoopCompileCore, you can get a mismatch because SnoopCompileCore lives in the same repo as SnoopCompile. So just make sure you dev both and it should be good---let me know if not!

@timholy
Copy link
Owner Author

timholy commented Jan 3, 2021

For anyone wondering about any more changes, I do expect to slightly rework the internals of InferenceTrigger and support the creation of flamegraphs from child nodes. I just pushed the teh/subflames branch that encapsulates this PR and the remaining changes I envision.

@tpapp
Copy link

tpapp commented Jan 3, 2021

Thanks, it is working now.

@timholy
Copy link
Owner Author

timholy commented Jan 4, 2021

Note to all: barring feedback, merge day is Tuesday, Jan5 in the very early hours of the morning (UTC-6).

@tpapp
Copy link

tpapp commented Jan 4, 2021

What's still not very clear to me is how to get a MethodInstance from the output of @snoopi_deep (or its flattened version). Sorry if I missed it.

@timholy
Copy link
Owner Author

timholy commented Jan 4, 2021

Sorry if I missed it.

No worries, and thanks for the feedback!

What's still not very clear to me is how to get a MethodInstance from the output of @snoopi_deep (or its flattened version)

Hmm, that could indeed be clarified. So you don't have to wait, here's a demo:

julia> using SnoopCompile

julia> tinf = SnoopCompile.flatten_demo()
InferenceTimingNode: 0.002332952/0.0030147330000000003 on InferenceFrameInfo for Core.Compiler.Timings.ROOT() with 1 direct children

julia> using AbstractTrees

julia> print_tree(tinf)
InferenceTimingNode: 0.00233295/0.00301473 on InferenceFrameInfo for Core.Compiler.Timings.ROOT() with 1 direct children
└─ InferenceTimingNode: 0.000179361/0.000681781 on InferenceFrameInfo for SnoopCompile.FlattenDemo.packintype(::Int64) with 2 direct children
   ├─ InferenceTimingNode: 0.000119137/0.000119137 on InferenceFrameInfo for MyType{Int64}(::Int64) with 0 direct children
   └─ InferenceTimingNode: 0.000105458/0.000383283 on InferenceFrameInfo for SnoopCompile.FlattenDemo.dostuff(::MyType{Int64}) with 2 direct children
      ├─ InferenceTimingNode: 7.3179e-5/0.0001366 on InferenceFrameInfo for SnoopCompile.FlattenDemo.extract(::MyType{Int64}) with 2 direct children
      │  ├─ InferenceTimingNode: 3.7388e-5/3.7388e-5 on InferenceFrameInfo for getproperty(::MyType{Int64}, ::Symbol) with 0 direct children
      │  └─ InferenceTimingNode: 2.6033e-5/2.6033e-5 on InferenceFrameInfo for getproperty(::MyType{Int64}, x::Symbol) with 0 direct children
      └─ InferenceTimingNode: 0.000141225/0.000141225 on InferenceFrameInfo for SnoopCompile.FlattenDemo.domath(::Int64) with 0 direct children

julia> Core.MethodInstance(tinf)
MethodInstance for ROOT()

julia> Core.MethodInstance(tinf.children[1])
MethodInstance for packintype(::Int64)

julia> Core.MethodInstance(tinf.children[2])
ERROR: BoundsError: attempt to access 1-element Vector{SnoopCompileCore.InferenceTimingNode} at index [2]
Stacktrace:
 [1] getindex(A::Vector{SnoopCompileCore.InferenceTimingNode}, i1::Int64)
   @ Base ./array.jl:787
 [2] top-level scope
   @ REPL[7]:1

julia> Core.MethodInstance(tinf.children[1].children[2])
MethodInstance for dostuff(::SnoopCompile.FlattenDemo.MyType{Int64})

@timholy timholy merged commit 89e7561 into master Jan 5, 2021
@timholy timholy deleted the teh/docs branch January 5, 2021 10:14
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