Closed serenity4 closed 5 days ago
At a glance it looks like:
Base._join_preserve_annotations
the signature should be Tuple{typeof(read), Base.AnnotatedIOBuffer, Type{Base.AnnotatedString{String}}}
not Tuple{typeof(read), Any, Type{Base.AnnotatedString{String}}}
(is something funny happening with type inference?) Base.read(s::Stream, nb)
might want to condition nb::Integer
.Redefining Base.read(s::Stream, nb)
as Base.read(s::Stream, nb::Integer)
only shifts the invalidation to Base.read(s::Stream, args...)
defined in the same file, so that fix isn't enough.
After experimenting, I believe the invalidation is caused by defining read(io::T, ...)
where T
is not an IO
; I guess so far all io
types implementing read
with 2+ arguments subtype Base.IO
. The invalidations get fixed if we make Stream <: IO
. I submitted a PoC PR to see if this is a solution that can be deemed acceptable.
the signature should be
Tuple{typeof(read), Base.AnnotatedIOBuffer, Type{Base.AnnotatedString{String}}}
notTuple{typeof(read), Any, Type{Base.AnnotatedString{String}}}
I agree, the io
argument within the relevant part of Base._join_preserve_annotations
clearly is inferrable to a Base.AnnotatedIOBuffer
, I have no idea why the wider signature invalidates this callsite.
In nightly, loading FileIO results in lots of invalidations related to StyledStrings, see the following case:
As can be seen in the last invalidation tree, https://github.com/JuliaIO/FileIO.jl/blob/4c930733f74bc9658daa9ad98b94cb39eab785bf/src/types.jl#L157 triggers the invalidation of 8k+ children. In practice this causes lags of a few seconds in the REPL when typing common commands for the first time after loading FileIO (
pkg> st
andpkg> resolve
particularly so). The cause is perhaps related tojoin
onAnnotatedString
as discussed already in https://github.com/KristofferC/OhMyREPL.jl/issues/355. I'm not sure if there is something to be done in FileIO or if this is something to address in Base or StyledStrings.cc @tecosaur