REPL in 1.11 freezes while typing on array indexing and field access

I have a very weird issue in the REPL with one of my packages. Unfortunately it’s very hard to boil it down to an MWE but I can already provide something which people can easily reproduce.

You’ll need to add our public registry and install two packages (which only depend on packages from the general registry):

julia> using Pkg; Pkg.Registry.add(); Pkg.Registry.add(RegistrySpec(url = "https://git.km3net.de/common/julia-registry"))

julia> Pkg.add(name="KM3io", version="0.18.8")

julia> Pkg.add("KM3NeTTestData")  # version doesn't matter, it's just sample files

Then the following happens in the REPL and this is all we are doing (empty startup.jl):

julia> using KM3io, KM3NeTTestData

julia> f = ROOTFile(datapath("offline", "numucc.root"))
ROOTFile{OnlineTree (0 events, 0 summaryslices), OfflineTree (10 events)}

julia> f.offline[1].

Right after typing f.offline[1]. (the dot is actually the last character which prints immediately), the REPL freezes for many seconds and only the deletion of characters is immedate, every other keystroke introduces another lag of several seconds.

Tab completion is affected as well of course, I guess that just counts as a keystroke. On some machines, the lag does not start just by typing but tab completion is extremely laggy.

Apparently there is something heavy is happening in the REPL when getindex is involved followed by the dot for field access. I can see in the activity monitor that one julia process is going to 100% CPU.

The corresponding line in KM3io.jl is here: KM3io.jl/src/root/offline.jl at db133f40af8f3681d51807ae4c2d646f3c5e259c · KM3NeT/KM3io.jl · GitHub and I even tried to add a return type hint with ::Evt, since the function is guaranteed to return an Evt, so I am wondering why the REPL cannot figure this out easily. Where does it choke?

I hope that someone who has a better understanding on what REPL.jl is doing (and the recent changes introduced in Julia 1.11) under the hood can kick me in the right direction because at this moment I have little idea where to start :wink: Maybe it’s related to some compilations triggering in the background…

The problem does not appear up to Julia v1.10.7, it starts with Julia v1.11.0. The latest I tried was 1.11.5 and also v1.12.0-beta4 on macOS 15.3 with an M1 CPU and also on Ubuntu Linux with a beefy Intel Xeon (the amount of threads does not matter, I tried with -t 128 :laughing: )

Btw. I also tried to disable the hint_tab_completes option in the ~/.julia/config/startup.jl because that was our best guess so far, but it did not help:

atreplinit() do repl
    if VERSION >= v"1.11.0-0"
        repl.options.hint_tab_completes = false
    end
end
3 Likes

This does seem very much like Very sluggish autocomplete with PyCall · Issue #54131 · JuliaLang/julia · GitHub, but that should be fixed on 1.11.5. The REPL does look at inference on getproperty (and getindex, I think) and then introspects. And that introspection can be expensive (and happens on every keystroke). That’s what was happening there.

I know that’s not much, but perhaps it’s a small carrot.

3 Likes

Thanks Matt, that’s a juicy carrot! I was unable to spot that issue.

Unfortunately we do have the problem with 1.11.5 as well so I guess I’ll go ahead with an issue there. It’s the exact same symptom as described there.

1 Like

If it’s the autocomplete issue that SymPy ran into, does julia> Base.active_repl.options.hint_tab_completes = false still stop the freezing?

I probably did something wrong because that setting did not help but just tried it again and indeed the freeze while typing is gone when I set that. Autocomplete is still unusable and has a huge lag.

I created an issue and will report there: Yet another REPL freeze issue while typing · Issue #58813 · JuliaLang/julia · GitHub