Skip to content

Instantly share code, notes, and snippets.

View timholy's full-sized avatar

Tim Holy timholy

View GitHub Profile
@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"]
@timholy
timholy / inference_triggers.csv
Created December 21, 2020 11:48
Inference triggers from AbstractPlotting (`scatter`)
We can make this file beautiful and searchable if this error is corrected: It looks like row 9 should actually have 4 columns, instead of 3 in line 8.
ncallees,ncallers,location,codeline
1,1,convert_arguments at /home/tim/.julia/dev/AbstractPlotting/src/conversions.jl:41,ct = conversion_trait(T)
1,1,data_limits at /home/tim/.julia/dev/AbstractPlotting/src/layouting/data_limits.jl:136,bb2 = data_limits(plot)::FRect3D
1,1,collect_with_eltype at /home/tim/.julia/dev/GeometryBasics/src/geometry_primitives.jl:81,for element in iter
1,1,serialize_cycle_header at /home/tim/src/julia-master/usr/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:173,"serialize_type(s, typeof(x), true)"
1,1,serialize_cycle_header at /home/tim/src/julia-master/usr/share/julia/stdlib/v1.7/Serialization/src/Serialization.jl:172,"serialize_cycle(s, x) && return true"
1,1,AbstractPlot at /home/tim/.julia/dev/AbstractPlotting/src/interfaces.jl:454,
1,1,xyz_boundingbox at /home/tim/.julia/dev/AbstractPlotting/src/layouting/data_limits.jl:67,"return FRect3D(to_ndim(Vec3f0, mini, 0), to_ndim(Vec3f0, w, 0))"
1,1,glyph_positions at /home/tim/.julia/dev/AbstractPlotting/src/layouting/lay
@timholy
timholy / draw_axis2d_demo.jl
Created December 18, 2020 16:50
Makie/AbstractPlotting latency demos
# Run this in a fresh session
using AbstractPlotting, StaticArrays
@time precompile(AbstractPlotting.draw_axis2d, (Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, Any))
@time precompile(AbstractPlotting.draw_axis2d, (Annotations{Tuple{Vector{Tuple{String, Point{2, Float32}}}}}, LineSegments{Tuple{Vector{Point{2, Float32}}}}, Tuple{LineSegments{Tuple{Vector{Point{2, Float32}}}}, LineSegments{Tuple{Vector{Point{2, Float32}}}}}, Tuple{LineSegments{Tuple{Vector{Point{2, Float32}}}}, LineSegments{Tuple{Vector{Point{2, Float32}}}}}, SMatrix{4, 4, Float32, 16}, Float64, Tuple{Tuple{Float32, Float32}, Tuple{Float32, Float32}}, Tuple{Tuple{Vector{Float64}, Vector{Float64}}, Tuple{Vector{String}, Vector{String}}}, Tuple{Bool, Bool}, Tuple{Bool, Bool}, Tuple{Bool, Bool}, Tuple{Float64, Float64}, Tuple{Tuple{Symbol, Float64}, Tuple{Symbol, Float64}}, Tuple{Nothing,
# This file is machine-generated - editing it directly is not advised
[[Artifacts]]
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
[[ColorTypes]]
deps = ["FixedPointNumbers", "Random"]
@timholy
timholy / abstract_inference.jl
Last active June 28, 2020 15:50
Analyzing failures of abstract inference to deduce "known" constraints on the output type
using MethodAnalysis
using Base: _methods_by_ftype, get_world_counter, to_tuple_type, func_for_method_checked, remove_linenums!
using Core: CodeInfo, SSAValue, SlotNumber, SimpleVector
if isdefined(Core.Compiler, :NativeInterpreter)
getcode(meth, x, world, optimize; interp=Core.Compiler.NativeInterpreter(world)) =
Core.Compiler.typeinf_code(interp, meth, x[1], x[2], optimize)
else
getcode(meth, x, world, optimize; params=Core.Compiler.Params(world)) =
Core.Compiler.typeinf_code(meth, x[1], x[2], optimize, params)
@timholy
timholy / invalidation.log
Created May 11, 2020 01:48
DifferentialEquations invalidations
julia> using SnoopCompile
julia> invalidation_trees(@snoopr using DifferentialEquations)
insert_backedges for MethodInstance for __init__()
insert_backedges for MethodInstance for (::CompilerSupportLibraries_jll.var"#1#2")(::Dict{String,Any})
insert_backedges for MethodInstance for __init__()
insert_backedges for MethodInstance for (::OpenSpecFun_jll.var"#1#2")(::Dict{String,Any})
insert_backedges for MethodInstance for (::FiniteDiff.var"#2#5")()
insert_backedges for MethodInstance for allbindings(::Any, ::Array{Any,1})
insert_backedges for MethodInstance for (::RecursiveArrayTools.var"#46#58")()
@timholy
timholy / demo
Created May 5, 2020 18:31
Demo of invalidation
julia> unsafe_store!(cglobal(:jl_debug_method_invalidation, Cint), 1)
Ptr{Int32} @0x00007f1d93ffe180
julia> abstract type Colorant{T,N} end
julia> Base.convert(::Type{C}, c) where {C<:Colorant} = nothing
(::Type{Base.Iterators.Stateful{T, VS} where VS where T})(Base.Generator{_A, getfield(Base, Symbol("#5#6")){Base.Pair{A, B} where B where A}} where _A) (in Base.Iterators)
#shell_parse#363(String, typeof(Base.shell_parse), String, Bool) (in Base)
shell_parse##kw(NamedTuple{(:special,), Tuple{String}}, typeof(Base.shell_parse), String, Bool) (in Base)
shell_parse##kw(NamedTuple{(:special,), Tuple{String}}, typeof(Base.shell_parse), String) (in Base)