Skip to content

Invalidations when loading DataFrames #1061

@timholy

Description

@timholy

Some non-inferrable code in CSV gets invalidated when you load DataFrames. This is a sister issue to JuliaData/DataFrames.jl#3248, and you can read that issue for a more complete discussion of potential ways to address the issue. In CSV's case, the only invalidations you need to care about come from DataStructures; similar to the suggestion in JuliaData/DataFrames.jl#3248, the simplest approach might be to make DataStructures an obligate part of your package. But fixing the inference failure(s) (I haven't tried) would avoid the invalidation without taking on DataStructures as a dependency.

julia> using SnoopCompileCore

julia> invs = @snoopr begin
           using DataFrames
           using CSV
       end;

julia> tinf = @snoopi_deep CSV.File(joinpath(pkgdir(CSV), "test", "testfiles", "precompile.csv"));

julia> using SnoopCompile

julia> tinf
InferenceTimingNode: 7.241082/7.613602 on Core.Compiler.Timings.ROOT() with 15 direct children

julia> trees = invalidation_trees(invs);

julia> staletrees = precompile_blockers(trees, tinf)
1-element Vector{SnoopCompile.StaleTree}:
 inserting iterate(v::Union{Base.KeySet{<:Any, <:DataStructures.SwissDict}, Base.ValueIterator{<:DataStructures.SwissDict}}, state) @ DataStructures ~/.julia/packages/DataStructures/59MD0/src/swiss_dict.jl:646 invalidated:
   mt_backedges: 1: MethodInstance for CSV.Context(::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg, ::CSV.Arg) at depth 1 with 2 children blocked InferenceTimingNode: 0.000292/0.246068 on CSV.File(::String) with 2 direct children

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions