Skip to content

Commit

Permalink
Switch to SnoopPrecompile (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy authored Mar 3, 2023
1 parent 9a97bbd commit 7694c1f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 37 deletions.
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ProfileView"
uuid = "c46f51b8-102a-5cf2-8d2c-8597cb0e0da7"
author = ["Tim Holy <[email protected]>"]
version = "1.5.2"
version = "1.6.0"

[deps]
Cairo = "159f3aea-2a34-519c-b102-8c37f9878175"
Expand All @@ -17,6 +17,7 @@ IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
MethodAnalysis = "85b6ec6f-f7df-4429-9514-a64bcd9ee824"
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
Profile = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"
SnoopPrecompile = "66db9d55-30c0-4569-8b51-7e840670fc0c"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[compat]
Expand All @@ -30,6 +31,7 @@ GtkObservables = "1"
IntervalSets = "0.2, 0.3, 0.4, 0.5, 0.6, 0.7"
MethodAnalysis = "0.4"
Preferences = "1.2"
SnoopPrecompile = "1"
julia = "1.6"

[extras]
Expand Down
38 changes: 35 additions & 3 deletions src/ProfileView.jl
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,41 @@ end
discardfirstcol(A) = A[:,2:end]
discardfirstcol(A::IndirectArray) = IndirectArray(A.index[:,2:end], A.values)

if ccall(:jl_generating_output, Cint, ()) == 1
include("precompile.jl")
_precompile_()
using SnoopPrecompile

let
@precompile_setup begin
stackframe(func, file, line; C=false) = StackFrame(Symbol(func), Symbol(file), line, nothing, C, false, 0)

backtraces = UInt64[0, 4, 3, 2, 1, # order: calles then caller
0, 6, 5, 1,
0, 8, 7,
0, 4, 3, 2, 1,
0]
if isdefined(Profile, :add_fake_meta)
backtraces = Profile.add_fake_meta(backtraces)
end
lidict = Dict{UInt64,StackFrame}(1=>stackframe(:f1, :file1, 1),
2=>stackframe(:f2, :file1, 5),
3=>stackframe(:f3, :file2, 1),
4=>stackframe(:f2, :file1, 15),
5=>stackframe(:f4, :file1, 20),
6=>stackframe(:f5, :file3, 1),
7=>stackframe(:f1, :file1, 2),
8=>stackframe(:f6, :file3, 10))
@precompile_all_calls begin
g = flamegraph(backtraces; lidict=lidict)
gdict = Dict(tabname_allthreads => Dict(tabname_alltasks => g))
win, c, fdraw = viewgui(FlameGraphs.default_colors, gdict)
for obs in c.preserved
if isa(obs, Observable) || isa(obs, Observables.ObserverFunction)
precompile(obs)
end
end
precompile(fdraw)
closeall() # necessary to prevent serialization of stale references (including the internal `empty!`)
end
end
end

end
33 changes: 0 additions & 33 deletions src/precompile.jl

This file was deleted.

2 comments on commit 7694c1f

@timholy
Copy link
Owner Author

@timholy timholy commented on 7694c1f Mar 3, 2023

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/78865

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.6.0 -m "<description of version>" 7694c1f524def2dfa69525d30b100af191093a38
git push origin v1.6.0

Please sign in to comment.