julia-vscode
julia-vscode copied to clipboard
Excessive invalidations in notebook code (VSCodeServer)
julia> using SnoopCompileCore
julia> pushfirst!(LOAD_PATH, "/home/pfitzseb/Documents/Git/julia-vscode/scripts/packages/VSCodeServer")
4-element Vector{String}:
^[[B"/home/pfitzseb/Documents/Git/julia-vscode/scripts/packages/VSCodeServer"
"@"
"@v#.#"
"@stdlib"
julia> @snoopr using VSCodeServer
11872-element Vector{Any}:
...
julia> trees = invalidation_trees(invals)
8-element Vector{SnoopCompile.MethodInvalidations}:
inserting display(::VSCodeServer.JuliaNotebookInlineDisplay, x) in VSCodeServer at /home/pfitzseb/Documents/Git/julia-vscode/scripts/packages/VSCodeServer/src/notebookdisplay.jl:31 invalidated:
mt_backedges: 1: signature Tuple{typeof(display), AbstractDisplay, Any} triggered MethodInstance for display(::Any) (0 children)
inserting run(x::VSCodeServer.JSONRPC.JSONRPCEndpoint) in VSCodeServer.JSONRPC at /home/pfitzseb/Documents/Git/julia-vscode/scripts/packages/JSONRPC/src/core.jl:99 invalidated:
mt_backedges: 1: signature Tuple{typeof(run), Any} triggered MethodInstance for Pkg._run_precompilation_script_setup() (0 children)
inserting in(key_value::Pair, io::VSCodeServer.IJuliaCore.IJuliaStdio) in VSCodeServer.IJuliaCore at /home/pfitzseb/Documents/Git/julia-vscode/scripts/packages/IJuliaCore/src/stdio.jl:19 invalidated:
backedges: 1: superseding in(key_value::Pair, io::IO) in Base at show.jl:338 with MethodInstance for in(::Pair{Symbol, TypeVar}, ::IO) (4 children)
inserting (::Base.var"#prompt##kw")(::Any, ::typeof(Base.prompt), input::VSCodeServer.IJuliaCore.IJuliaStdio, output::VSCodeServer.IJuliaCore.IJuliaStdio, message::AbstractString) in VSCodeServer.IJuliaCore at /home/pfitzseb/Documents/Git/julia-vscode/scripts/packages/IJuliaCore/src/stdio.jl:213 invalidated:
mt_backedges: 1: signature Tuple{Base.var"#prompt##kw", NamedTuple{(:default,), Tuple{String}}, typeof(Base.prompt), Any, IO, String} triggered MethodInstance for Pkg.REPLMode.try_prompt_pkg_add(::Vector{Symbol}) (0 children)
backedges: 1: superseding (::Base.var"#prompt##kw")(::Any, ::typeof(Base.prompt), input::IO, output::IO, message::AbstractString) in Base at util.jl:312 with MethodInstance for (::Base.var"#prompt##kw")(::NamedTuple{(:default,), Tuple{String}}, ::typeof(Base.prompt), ::IO, ::IO, ::String) (5 children)
inserting lock(io::VSCodeServer.IJuliaCore.IJuliaStdio) in VSCodeServer.IJuliaCore at /home/pfitzseb/Documents/Git/julia-vscode/scripts/packages/IJuliaCore/src/stdio.jl:17 invalidated:
backedges: 1: superseding lock(::IO) in Base at io.jl:26 with MethodInstance for lock(::IO) (88 children)
inserting getpass(input::VSCodeServer.IJuliaCore.IJuliaStdio, output::VSCodeServer.IJuliaCore.IJuliaStdio, message::AbstractString) in VSCodeServer.IJuliaCore at /home/pfitzseb/Documents/Git/julia-vscode/scripts/packages/IJuliaCore/src/stdio.jl:218 invalidated:
mt_backedges: 1: signature Tuple{typeof(Base.getpass), IO, IO, String} triggered MethodInstance for Base.getpass(::String) (263 children)
inserting unlock(io::VSCodeServer.IJuliaCore.IJuliaStdio) in VSCodeServer.IJuliaCore at /home/pfitzseb/Documents/Git/julia-vscode/scripts/packages/IJuliaCore/src/stdio.jl:18 invalidated:
backedges: 1: superseding unlock(::IO) in Base at io.jl:27 with MethodInstance for unlock(::IO) (793 children)
8 mt_cache
inserting unwrapcontext(io::VSCodeServer.IJuliaCore.IJuliaStdio) in VSCodeServer.IJuliaCore at /home/pfitzseb/Documents/Git/julia-vscode/scripts/packages/IJuliaCore/src/stdio.jl:24 invalidated:
backedges: 1: superseding unwrapcontext(io::IO) in Base at show.jl:236 with MethodInstance for Base.unwrapcontext(::IO) (4736 children)
We should try to get as close to 0 invalidations here, because these increase latency by a lot -- simply commenting out all notebook related code improves a plot() call from 2.2s to 0.7s in the presence of a sysimage.
The original idea about IJuliaCore was that we move all the code that is shared between IJulia and the VS Code implementation into that package, and then IJulia would take a dependency on it. I never got to actually go through with that, but if we are revisiting IJuliaCore, it migh make sense to take another look at that at the same time.