Skip to content

Instantly share code, notes, and snippets.

View timholy's full-sized avatar

Tim Holy timholy

View GitHub Profile
@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)
-- isequal(REPL.LineEdit.Prompt, REPL.LineEdit.Prompt)
-- isequal(Method, Method)
-- isequal(Distributed.RemoteChannel{Base.Channel{Any}}, WeakRef)
-- isequal(Distributed.RemoteChannel{Base.Channel{Any}}, Distributed.RemoteChannel{Base.Channel{Any}})
-- isequal(Core.TypeName, Core.TypeName)
-- isequal(Symbol, Symbol)
-- isequal(String, Int64)
-- isequal(String, Char)
-- isequal(String, String)
-- isequal(Char, Char)
@timholy
timholy / nspecializations.jl
Created March 16, 2020 17:20
Counting the number of specializations of a method
function nspecializations(m::Method)
return isdefined(m, :specializations) ? nspecializations(m.specializations) : 0
end
nspecializations(::Nothing) = 0
function nspecializations(tme::Core.TypeMapEntry)
n = 0
while tme !== nothing
n += 1
tme = tme.next
end
@timholy
timholy / expandci.jl
Created March 11, 2020 13:59
A demo of external compiler passes in Julia
using Base.Meta: isexpr
# Grabbing the inferred code
function disable_pass!(src)
for (line, stmt) in enumerate(src.code)
if isexpr(stmt, :meta, 1)
a = stmt.args[1]
if isexpr(a, :external_pass)
mode = a.args[1]
@timholy
timholy / imfilter.jl
Last active March 4, 2020 23:38
ImageFiltering and LoopVectorization, perfect together
using ImageFiltering, ImageCore, OffsetArrays
using ImageFiltering: safehead, safetail, safe_for_prod
using LoopVectorization
function old!(out, A, kern, R=CartesianIndices(out), z=zero(eltype(out)))
Rk = CartesianIndices(axes(kern))
for I in safetail(R), i in safehead(R)
tmp = z
@inbounds for J in safetail(Rk), j in safehead(Rk)
tmp += safe_for_prod(A[i+j,I+J], tmp)*kern[j,J]