timholy / SnoopCompile.jl

Provide insights about latency (TTFX) for Julia packages
https://timholy.github.io/SnoopCompile.jl/dev/
Other
309 stars 48 forks source link

Fix snoopc test #380

Closed mkitti closed 5 months ago

mkitti commented 5 months ago

With Julia 1.6, a precompile statement is generated:

julia> using SnoopCompile

julia> logfile = joinpath(tempdir(), "anon.log")
"/tmp/anon.log"

julia> @snoopc logfile begin
           map(x->x^2, [1,2,3])
       end
Launching new julia process to run commands...
done.

julia> data = SnoopCompile.read(logfile)
(UInt64[0x00000000003d57dc, 0x00000000003d590b, 0x00000000016f8738], ["Tuple{Type{Base.Generator{I, F} where F where I}, Main.var\"#1#2\", Array{Int64, 1}}", "Tuple{typeof(Base.map), Function, Array{Int64, 1}}", "Tuple{typeof(Base.collect_similar), Array{Int64, 1}, Base.Generator{Array{Int64, 1}, Main.var\"#1#2\"}}"])

julia> read(logfile, String) |> println
4020491 "Tuple{typeof(Base.map), Function, Array{Int64, 1}}"
4020188 "Tuple{Type{Base.Generator{I, F} where F where I}, Main.var"#1#2", Array{Int64, 1}}"
24086328    "Tuple{typeof(Base.collect_similar), Array{Int64, 1}, Base.Generator{Array{Int64, 1}, Main.var"#1#2"}}"

julia> pc = SnoopCompile.parcel(reverse!(data[2]))
Dict{Symbol, Vector{String}} with 1 entry:
  :Base => ["precompile(Tuple{typeof(Base.map), typeof(identity), Array{Int64, 1}})"]

With Julia 1.10, the new precompile statement is not generated:

julia> using SnoopCompile

julia> logfile = joinpath(tempdir(), "anon.log")
"/tmp/anon.log"

julia> @snoopc logfile begin
           map(x->x^2, [1,2,3])
       end
Launching new julia process to run commands...
done.

julia> data = SnoopCompile.read(logfile)
(UInt64[0x00000000003bc942, 0x00000000013bae2e], ["Tuple{Type{Base.Generator{I, F} where F where I}, Main.var\"#1#2\", Array{Int64, 1}}", "Tuple{typeof(Base.collect_similar), Array{Int64, 1}, Base.Generator{Array{Int64, 1}, Main.var\"#1#2\"}}"])

julia> read(logfile, String) |> println
3918146 "Tuple{Type{Base.Generator{I, F} where F where I}, Main.var"#1#2", Array{Int64, 1}}"
20688430    "Tuple{typeof(Base.collect_similar), Array{Int64, 1}, Base.Generator{Array{Int64, 1}, Main.var"#1#2"}}"

julia> pc = SnoopCompile.parcel(reverse!(data[2]))
Dict{Symbol, Vector{String}}()
codecov[bot] commented 5 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 85.34%. Comparing base (622b233) to head (0cfecc4). Report is 2 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #380 +/- ## ========================================== + Coverage 78.96% 85.34% +6.38% ========================================== Files 17 17 Lines 2054 2191 +137 ========================================== + Hits 1622 1870 +248 + Misses 432 321 -111 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

timholy commented 5 months ago

Thanks!