-
Notifications
You must be signed in to change notification settings - Fork 4
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 more precompile methods #130
Comments
I still see the same issue as in #90: making It is probably related to type instability! By adding # Current no precompilation:
julia> @benchmark readvariable(meta, "CellID")
BenchmarkTools.Trial: 10000 samples with 9 evaluations.
Range (min … max): 2.723 μs … 7.401 μs ┊ GC (min … max): 0.00% … 0.00%
Time (median): 2.853 μs ┊ GC (median): 0.00%
Time (mean ± σ): 2.938 μs ± 284.272 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
▃█▄
▂███▅▃▃▆▅▅▆▅▄▃▃▃▃▃▃▂▁▁▁▂▂▁▁▁▁▂▁▁▁▂▄▃▂▁▁▁▂▂▂▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁ ▂
2.72 μs Histogram: frequency by time 3.6 μs <
Memory estimate: 320 bytes, allocs estimate: 9.
# Precompile `readvariable`:
BenchmarkTools.Trial: 10000 samples with 8 evaluations.
Range (min … max): 2.932 μs … 8.017 μs ┊ GC (min … max): 0.00% … 0.00%
Time (median): 3.159 μs ┊ GC (median): 0.00%
Time (mean ± σ): 3.254 μs ± 381.799 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
█▃ ▃
▇███▇▆█▆▅▅▄▄▃▅▅▃▄▄▃▃▃▃▂▂▂▂▂▂▂▂▂▁▂▂▂▂▂▂▂▁▂▁▂▂▂▂▂▂▂▂▂▂▁▁▂▁▂▂▂ ▃
2.93 μs Histogram: frequency by time 5.3 μs <
Memory estimate: 464 bytes, allocs estimate: 11. file = "test/init.vlsv"
meta = load(file)
# no precompilation
julia> @time Vlasiator.fillmesh(meta, ["proton/vg_v", "CellID"], skipghosttype=true, maxamronly=true);
0.328785 seconds (405.75 k allocations: 27.188 MiB)
julia> @time Vlasiator.fillmesh(meta, ["proton/vg_v", "CellID"], skipghosttype=true, maxamronly=true);
0.000142 seconds (69 allocations: 2.859 KiB)
# with precompilation
julia> @time Vlasiator.fillmesh(meta, ["proton/vg_v", "CellID"], skipghosttype=true, maxamronly=true);
0.000564 seconds (607 allocations: 35.359 KiB)
julia> @time Vlasiator.fillmesh(meta, ["proton/vg_v", "CellID"], skipghosttype=true, maxamronly=true);
0.000104 seconds (73 allocations: 3.141 KiB) Related to #127 |
Checking invalidations
using SnoopCompileCore
invalidations = @snoopr using Vlasiator;
tinf = @snoopi_deep begin
file = "bulk.0000006.vlsv"
meta = load(file)
v = readvariable(meta, "proton/vg_rho")
end
using SnoopCompile
trees = invalidation_trees(invalidations)
staletrees = precompile_blockers(trees, tinf)
@show length(uinvalidated(invalidations)) # show total invalidations
show(trees[end]) # show the most invalidating method
# Count number of children (number of invalidations per invalidated method)
n_invalidations = map(SnoopCompile.countchildren, trees)
#=
# (optional) plot the number of children per method invalidations
import Plots
Plots.plot(
1:length(trees),
n_invalidations;
markershape=:circle,
xlabel="i-th method invalidation",
label="Number of children per method invalidations"
)
=#
# (optional) report invalidations summary
using PrettyTables # needed for `report_invalidations` to be defined
SnoopCompile.report_invalidations(;
invalidations,
process_filename = x -> last(split(x, ".julia/packages/")),
n_rows = 0, # no-limit (show all invalidations)
) [ Info: 160 methods invalidated for 18 functions
None of these comes within the package. What shall I do? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now we only have
load
in precompilation. We need more to take advantage of Julia 1.9.readvariable
fillmesh
getxxx
Maybe first take a look at how other packages handle this.
The text was updated successfully, but these errors were encountered: