Skip to content

Instantly share code, notes, and snippets.

View timholy's full-sized avatar

Tim Holy timholy

View GitHub Profile
@timholy
timholy / search_index.js
Last active February 3, 2024 10:46
Debugging Documenter's search
var documenterSearchIndex = {"docs":
[{"location":"invalidations.html#Why-does-Julia-invalidate-code?","page":"Invalidations","title":"Why does Julia invalidate code?","text":"","category":"section"},{"location":"invalidations.html","page":"Invalidations","title":"Invalidations","text":"Julia may be unique among computer languages in supporting all four of the following features:","category":"page"},{"location":"invalidations.html","page":"Invalidations","title":"Invalidations","text":"interactive development\n\"method overloading\" by packages that don't own the function\naggressive compilation\nconsistent compilation: same result no matter how you got there","category":"page"},{"location":"invalidations.html","page":"Invalidations","title":"Invalidations","text":"The combination of these features requires that you sometimes \"throw away\" code that you have previously compiled.","category":"page"},{"location":"invalidations.html","page":"Invalidations","title":"Invalidations","text":"To illustrate: suppose
@timholy
timholy / list_of_recompilations
Created January 9, 2024 12:46
Incomplete precompilation
# From --trace-compile
precompile(Tuple{REPL.LineEdit.var"#27#28"{REPL.LineEdit.var"#133#189", String}, Any, Any})
precompile(Tuple{REPL.LineEdit.var"#133#189", REPL.LineEdit.MIState, Any, Vararg{Any}})
precompile(Tuple{typeof(REPL.LineEdit.is_non_word_char), Char})
precompile(Tuple{REPL.LineEdit.var"#27#28"{REPL.LineEdit.var"#134#190", String}, Any, Any})
precompile(Tuple{REPL.LineEdit.var"#134#190", REPL.LineEdit.MIState, Any, Vararg{Any}})
precompile(Tuple{REPL.LineEdit.var"#27#28"{REPL.LineEdit.var"#147#203", String}, Any, Any})
precompile(Tuple{REPL.LineEdit.var"#147#203", REPL.LineEdit.MIState, Any, Vararg{Any}})
precompile(Tuple{typeof(Base.in!), REPL.REPLCompletions.PackageCompletion, Base.Set{REPL.REPLCompletions.Completion}})
precompile(Tuple{typeof(REPL.REPLCompletions.completion_text), REPL.REPLCompletions.PackageCompletion})
@timholy
timholy / flamegraph_base
Created May 4, 2023 12:58
Recompilation for Trixi
/tmp/pkgs/packages/DiffEqBase/ihYDa/src/solve.jl:479, MethodInstance for Core.kwcall(::NamedTuple{(:dt, :save_everystep, :callback, :maxiters), Tuple{Float64, Bool, CallbackSet{Tuple{}, Tuple{DiscreteCallback{typeof(Trixi.summary_callback), typeof(Trixi.summary_callback), typeof(Trixi.initialize_summary_callback), typeof(SciMLBase.FINALIZE_DEFAULT)}, DiscreteCallback{Trixi.var"#1131#1137"{Int64}, AnalysisCallback{Trixi.LobattoLegendreAnalyzer{Float64, 7, SVector{7, Float64}, Matrix{Float64}}, Tuple{typeof(Trixi.entropy_timederivative)}, SVector{4, Float64}, NamedTuple{(:u_local, :u_tmp1, :x_local, :x_tmp1, :jacobian_local, :jacobian_tmp1), Tuple{StrideArraysCore.StaticStrideArray{Float64, 3, (1, 2, 3), Tuple{Static.StaticInt{4}, Static.StaticInt{7}, Static.StaticInt{7}}, Tuple{Nothing, Nothing, Nothing}, Tuple{Static.StaticInt{1}, Static.StaticInt{1}, Static.StaticInt{1}}, 196}, StrideArraysCore.StaticStrideArray{Float64, 3, (1, 2, 3), Tuple{Static.StaticInt{4}, Static.StaticInt{7}, Static.StaticInt{4}}, Tupl
@timholy
timholy / Manifest.toml
Created March 16, 2022 10:12
Makie dev
# This file is machine-generated - editing it directly is not advised
julia_version = "1.9.0-DEV"
manifest_format = "2.0"
project_hash = "ea499c8374363a5ef12b75ab5c6758fdb9000a2c"
[[deps.ATK_jll]]
deps = ["Artifacts", "Glib_jll", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "58c36d8a1beeb12d63921bcfaa674baf30a1140e"
uuid = "7b86fcea-f67b-53e1-809c-8f1719c154e8"
@timholy
timholy / plots_timing.jl
Created February 24, 2022 17:49
Compile-time regression script
try
using Pkg
Pkg.precompile()
catch
exit(125) # skip if we can't precompile Plots
end
cmtname, cmtsha = string(Base.VERSION), Base.GIT_VERSION_INFO.commit
tstart = time()
using Plots
tload = time()
@timholy
timholy / CacheNative.jl
Created February 10, 2022 15:50
Demo package & commands for native-code caching
module CacheNative
using Random
const somearray = [1,2,3]
struct SomeType
str::String
end
# @noinline ensures these are compiled as stand-alone functions
@timholy
timholy / CSV.diff
Last active February 18, 2022 14:41
diff --git a/src/precompile.jl b/src/precompile.jl
index 9b72977..eba10e0 100644
--- a/src/precompile.jl
+++ b/src/precompile.jl
@@ -5,4 +5,5 @@ function _precompile_()
# CSV.Context(IOBuffer(CSV.PRECOMPILE_DATA))
# foreach(row -> row, CSV.Rows(IOBuffer(PRECOMPILE_DATA)))
CSV.Context(joinpath(dirname(pathof(CSV)), "promotions.csv"))
+ CSV.File(joinpath(pkgdir(CSV), "test", "testfiles", "precompile.csv"))
end
@timholy
timholy / build_stats.txt
Created August 22, 2021 08:03
Stats on CodeInstances
julia> using Revise
[ Info: Precompiling Revise [295af30f-e4ad-537b-8983-00126c2a3abe]
external: 0; module-thunk: 0; worklist: 1
external: 0; module-thunk: 0; worklist: 1
external: 4746; module-thunk: 0; worklist: 318
external: 6226; module-thunk: 0; worklist: 187
external: 9211; module-thunk: 0; worklist: 298
julia> using ImageCore
@timholy
timholy / select_subset_test.jl
Created July 25, 2021 13:23
DataFrames specialization and latency
using DataFrames, SnoopCompile, Statistics, ProfileView
# Note: load all packages first to prevent invalidation
d = DataFrame(n = 1:20, x = [3, 3, 3, 3, 1, 1, 1, 2, 1, 1,
2, 1, 1, 2, 2, 2, 3, 1, 1, 2]);
g = groupby(d, :x);
subset(g, :n => (n -> n .> mean(n))); # compile
select(g, :n => (n -> n .> mean(n))); # compile
@timholy
timholy / Manifest.toml
Created December 26, 2020 08:20
Pkg assertion error
# This file is machine-generated - editing it directly is not advised
[[AbstractFFTs]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "051c95d6836228d120f5f4b984dd5aba1624f716"
uuid = "621f4979-c628-5d54-868e-fcf4e3e8185c"
version = "0.5.0"
[[AbstractPlotting]]
deps = ["Animations", "ColorBrewer", "ColorSchemes", "ColorTypes", "Colors", "Contour", "Distributions", "DocStringExtensions", "FFMPEG", "FileIO", "FixedPointNumbers", "Formatting", "FreeType", "FreeTypeAbstraction", "GeometryBasics", "GridLayoutBase", "ImageIO", "IntervalSets", "Isoband", "KernelDensity", "LinearAlgebra", "Markdown", "Match", "Observables", "Packing", "PlotUtils", "PolygonOps", "Printf", "Random", "ReferenceTests", "Serialization", "Showoff", "SignedDistanceFields", "SparseArrays", "StaticArrays", "Statistics", "StatsBase", "StructArrays", "UnicodeFun"]