Skip to content

Commit 8b7090a

Browse files
authored
Fix doctest failures (#248)
Fixes module namespace, floating-point regex, and updates to the latest Julia nightly. This also prepares for the 2.6.1 release.
1 parent f412a41 commit 8b7090a

File tree

7 files changed

+28
-18
lines changed

7 files changed

+28
-18
lines changed

.github/workflows/Documenter.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ jobs:
2020
- uses: julia-actions/setup-julia@latest
2121
with:
2222
version: nightly
23-
- run: julia --project -e 'using Pkg; Pkg.develop([PackageSpec(path="SnoopCompileCore")])'
23+
- run: julia --project -e 'using Pkg; Pkg.develop([PackageSpec(path=joinpath(pwd(), "SnoopCompileCore"))])'
2424
- uses: julia-actions/julia-buildpkg@latest
25+
- run: julia --project=docs/ -e 'using Pkg; Pkg.develop([PackageSpec(path=joinpath(pwd(), "SnoopCompileCore"))]); Pkg.instantiate()'
2526
- uses: julia-actions/julia-docdeploy@releases/v1
2627
env:
2728
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Project.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SnoopCompile"
22
uuid = "aa65fe97-06da-5843-b5b1-d5d13cad87d2"
33
author = ["Tim Holy <[email protected]>"]
4-
version = "2.6.0"
4+
version = "2.6.1"
55

66
[deps]
77
Cthulhu = "f68482b8-f384-11e8-15f7-abe071a5a75f"
@@ -21,7 +21,7 @@ Cthulhu = "1.5"
2121
FlameGraphs = "0.2"
2222
OrderedCollections = "1"
2323
Requires = "1"
24-
SnoopCompileCore = "~2.5.2"
24+
SnoopCompileCore = "~2.6.1"
2525
YAML = "0.4"
2626
julia = "1"
2727

SnoopCompileCore/Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SnoopCompileCore"
22
uuid = "e2b509da-e806-4183-be48-004708413034"
33
author = ["Tim Holy <[email protected]>"]
4-
version = "2.5.2"
4+
version = "2.6.1"
55

66
[deps]
77
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"

SnoopCompileCore/src/snoopi_deep.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ See also: `flamegraph`, `flatten`, `inference_triggers`, `SnoopCompile.parcel`,
8282
`runtime_inferencetime`.
8383
8484
# Example
85-
```jldoctest; setup=:(using SnoopCompile), filter=r"([0-9\\.e-]+/[0-9\\.e-]+|\\d direct)"
85+
```jldoctest; setup=:(using SnoopCompile), filter=r"([0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?/[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?|\\d direct)"
8686
julia> tinf = @snoopi_deep begin
8787
sort(rand(100)) # Evaluate some code and profile julia's type inference
8888
end

docs/Project.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
[deps]
2+
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
23
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
34
MethodAnalysis = "85b6ec6f-f7df-4429-9514-a64bcd9ee824"
45
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
56

67
[compat]
7-
Documenter = "0.25"
8+
Documenter = "0.27"
89
MethodAnalysis = "0.4"
910
PyPlot = "2"

docs/src/snoopi_deep.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ FlattenDemo
4747
The main call, `packintype`, stores the input in a `struct`, and then calls functions that extract the field value and performs arithmetic on the result.
4848
To profile inference on this call, we simply do the following:
4949

50-
```jldoctest flatten-demo; setup=:(using SnoopCompile), filter=r"([0-9\\.e-]+|WARNING: replacing module FlattenDemo\.\n)"
50+
```jldoctest flatten-demo; setup=:(using SnoopCompile), filter=r"([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?|WARNING: replacing module FlattenDemo\.\n)"
5151
julia> tinf = @snoopi_deep FlattenDemo.packintype(1)
5252
InferenceTimingNode: 0.00932195/0.010080857 on InferenceFrameInfo for Core.Compiler.Timings.ROOT() with 1 direct children
5353
```
@@ -90,7 +90,7 @@ You may have noticed that this `ROOT` node prints with two numbers.
9090
It will be easier to understand their meaning if we first display the whole tree.
9191
We can do that with the [AbstractTrees](https://github.com/JuliaCollections/AbstractTrees.jl) package:
9292

93-
```jldoctest flatten-demo; filter=r"[0-9\\.e-]+"
93+
```jldoctest flatten-demo; filter=r"[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?"
9494
julia> using AbstractTrees
9595
9696
julia> print_tree(tinf)
@@ -116,10 +116,10 @@ You can extract the `MethodInstance` with
116116

117117
```jldoctest flatten-demo
118118
julia> Core.MethodInstance(tinf)
119-
MethodInstance for ROOT()
119+
MethodInstance for Core.Compiler.Timings.ROOT()
120120
121121
julia> Core.MethodInstance(tinf.children[1])
122-
MethodInstance for packintype(::Int64)
122+
MethodInstance for FlattenDemo.packintype(::Int64)
123123
```
124124

125125
Each node in this tree is accompanied by a pair of numbers.
@@ -135,7 +135,7 @@ As you will quickly discover, inference takes much more time on more complicated
135135

136136
We can also display this tree as a flame graph, using the [ProfileView](https://github.com/timholy/ProfileView.jl) package:
137137

138-
```jldoctest flatten-demo; filter=r"0:\d+"
138+
```jldoctest flatten-demo; filter=r":\d+"
139139
julia> fg = flamegraph(tinf)
140140
Node(FlameGraphs.NodeData(ROOT() at typeinfer.jl:75, 0x00, 0:10080857))
141141
```

src/parcel_snoopi_deep.jl

+15-7
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ or `nothing` to obtain them in the order they were inferred (depth-first order).
5656
5757
We'll use [`SnoopCompile.flatten_demo`](@ref), which runs `@snoopi_deep` on a workload designed to yield reproducible results:
5858
59-
```jldoctest flatten; setup=:(using SnoopCompile), filter=r"([0-9\\.e-]+/[0-9\\.e-]+|WARNING: replacing module FlattenDemo\\.\\n)"
59+
```jldoctest flatten; setup=:(using SnoopCompile), filter=r"([0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?/[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?|WARNING: replacing module FlattenDemo\\.\\n)"
6060
julia> tinf = SnoopCompile.flatten_demo()
6161
InferenceTimingNode: 0.002148974/0.002767166 on InferenceFrameInfo for Core.Compiler.Timings.ROOT() with 1 direct children
6262
@@ -75,7 +75,7 @@ Note the printing of `getproperty(::SnoopCompile.FlattenDemo.MyType{$Int}, x::Sy
7575
that `getproperty` was inferred with. This reflects constant-propagation in inference.
7676
7777
Then:
78-
```jldoctest flatten; setup=:(using SnoopCompile), filter=r"[0-9\\.e-]+/[0-9\\.e-]+"
78+
```jldoctest flatten; setup=:(using SnoopCompile), filter=r"[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?/[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?"
7979
julia> flatten(tinf; sortby=nothing)
8080
8-element Vector{SnoopCompileCore.InferenceTiming}:
8181
InferenceTiming: 0.002423543/0.0030352639999999998 on InferenceFrameInfo for Core.Compiler.Timings.ROOT()
@@ -142,12 +142,12 @@ that it is being inferred for many specializations (which might include speciali
142142
143143
We'll use [`SnoopCompile.flatten_demo`](@ref), which runs `@snoopi_deep` on a workload designed to yield reproducible results:
144144
145-
```jldoctest accum1; setup=:(using SnoopCompile), filter=r"([0-9\\.e-]+|at .*/deep_demos.jl:\\d+|WARNING: replacing module FlattenDemo\\.\\n)"
145+
```jldoctest accum1; setup=:(using SnoopCompile), filter=r"([0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?|at .*/deep_demos.jl:\\d+|at Base\\.jl:\\d+|at compiler/typeinfer\\.jl:\\d+|WARNING: replacing module FlattenDemo\\.\\n)"
146146
julia> tinf = SnoopCompile.flatten_demo()
147147
InferenceTimingNode: 0.002148974/0.002767166 on InferenceFrameInfo for Core.Compiler.Timings.ROOT() with 1 direct children
148148
149149
julia> accumulate_by_source(flatten(tinf))
150-
7-element Vector{Tuple{Float64, Method}}:
150+
7-element Vector{Tuple{Float64, Union{Method, Core.MethodInstance}}}:
151151
(6.0012999999999996e-5, getproperty(x, f::Symbol) in Base at Base.jl:33)
152152
(6.7714e-5, extract(y::SnoopCompile.FlattenDemo.MyType) in SnoopCompile.FlattenDemo at /pathto/SnoopCompile/src/deep_demos.jl:35)
153153
(9.421e-5, dostuff(y) in SnoopCompile.FlattenDemo at /pathto/SnoopCompile/src/deep_demos.jl:44)
@@ -354,7 +354,7 @@ See also: [`SnoopCompile.write`](@ref).
354354
355355
We'll use [`SnoopCompile.itrigs_demo`](@ref), which runs `@snoopi_deep` on a workload designed to yield reproducible results:
356356
357-
```jldoctest parceltree; setup=:(using SnoopCompile), filter=r"([0-9\\.e-]+|WARNING: replacing module ItrigDemo\\.\\n|UInt8|Float64)"
357+
```jldoctest parceltree; setup=:(using SnoopCompile), filter=r"([0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?|WARNING: replacing module ItrigDemo\\.\\n|UInt8|Float64|SnoopCompile\\.ItrigDemo\\.)"
358358
julia> tinf = SnoopCompile.itrigs_demo()
359359
InferenceTimingNode: 0.004490576/0.004711168 on InferenceFrameInfo for Core.Compiler.Timings.ROOT() with 2 direct children
360360
@@ -700,7 +700,7 @@ All the entries in `itrigs` are previously uninferred, or are freshly-inferred f
700700
701701
We'll use [`SnoopCompile.itrigs_demo`](@ref), which runs `@snoopi_deep` on a workload designed to yield reproducible results:
702702
703-
```jldoctest triggers; setup=:(using SnoopCompile), filter=r"([0-9\\.e-]+|.*/deep_demos\\.jl:\\d+|WARNING: replacing module ItrigDemo\\.\\n)"
703+
```jldoctest triggers; setup=:(using SnoopCompile), filter=r"([0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?|.*/deep_demos\\.jl:\\d+|WARNING: replacing module ItrigDemo\\.\\n)"
704704
julia> tinf = SnoopCompile.itrigs_demo()
705705
InferenceTimingNode: 0.004490576/0.004711168 on InferenceFrameInfo for Core.Compiler.Timings.ROOT() with 2 direct children
706706
@@ -939,6 +939,14 @@ function findparent(node::TriggerNode, bt)
939939
return findparent(node.parent, bt)
940940
end
941941

942+
"""
943+
root = trigger_tree(itrigs)
944+
945+
Organize inference triggers `itrigs` in tree format, grouping items via the call tree.
946+
947+
It is a tree rather than a more general graph due to the fact that caching inference results means that each node gets
948+
visited only once.
949+
"""
942950
function trigger_tree(itrigs::AbstractVector{InferenceTrigger})
943951
root = node = TriggerNode()
944952
for itrig in itrigs
@@ -1668,7 +1676,7 @@ each method will cause the number of specializations to be included in the frame
16681676
16691677
We'll use [`SnoopCompile.flatten_demo`](@ref), which runs `@snoopi_deep` on a workload designed to yield reproducible results:
16701678
1671-
```jldoctest flamegraph; setup=:(using SnoopCompile), filter=r"([0-9\\.e-]+/[0-9\\.e-]+|at.*typeinfer\\.jl:\\d+|0:\\d+|WARNING: replacing module FlattenDemo\\.\\n)"
1679+
```jldoctest flamegraph; setup=:(using SnoopCompile), filter=r"([0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?/[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?|at.*typeinfer\\.jl:\\d+|0:\\d+|WARNING: replacing module FlattenDemo\\.\\n)"
16721680
julia> tinf = SnoopCompile.flatten_demo()
16731681
InferenceTimingNode: 0.002148974/0.002767166 on InferenceFrameInfo for Core.Compiler.Timings.ROOT() with 1 direct children
16741682

0 commit comments

Comments
 (0)