You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Avoid write(::IO, ::String) invalidations from Stream and IO
* Avoid write(::IO, ::String) invalidations from Stream and deadline IO
Extending Base.write for String/AbstractString on a new IO type invalidates
every abstractly-inferred write(::IO, ::String) call site in the ecosystem
(~1380 instances each at using time, measured with @snoop_invalidations).
Hook Base.unsafe_write instead: Base's generic string write funnels through
it, so behavior is unchanged while the method-table impact disappears.
* Remove invalidation-prone abstract edges from write and websocket paths
- http1.jl / http_transport.jl: Int-assert length/write results where the
stream is deliberately untyped, so loop arithmetic and comparisons stay
concretely inferred instead of carrying >(::Any, ::Int) edges.
- http_server_streams.jl: write concrete Vector{UInt8}/String in the server
write path; the abstract write(io, ::AbstractVector{UInt8}) and
write(::Stream, ::AbstractString) edges get invalidated whenever any
package defines write methods for its own types (LaTeXStrings, ...).
- http_websocket_codec.jl: use a Ref instead of a closure-reassigned local;
the Core.Box capture infers Any and the resulting >(::UInt64, ::Any)
edges get invalidated by packages defining broad comparison methods
(SIMD.jl), recompiling the websocket receive path on first use.
* Define write(::Stream, ::UInt8) so generic AbstractStrings don't throw
String and SubString{String} writes route through unsafe_write, but Base's
fallbacks for other AbstractStrings (and Char) write char-by-char and bottom
out in write(io, ::UInt8), which previously threw "Stream does not support
byte I/O". Adding the byte primitive causes no invalidations (measured with
@snoop_invalidations against a loaded Bonito/Makie stack), since it is the
method every IO subtype is expected to define.
0 commit comments