Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic repl interaction not fully precompiled #54080

Open
LilithHafner opened this issue Apr 14, 2024 · 6 comments
Open

Basic repl interaction not fully precompiled #54080

LilithHafner opened this issue Apr 14, 2024 · 6 comments
Labels
compiler:precompilation Precompilation of modules stdlib:REPL Julia's REPL (Read Eval Print Loop)

Comments

@LilithHafner
Copy link
Member

LilithHafner commented Apr 14, 2024

If I type this at the repl: 1+1[up][up][enter]1[up][down][left][right][down][home][backspace][del]one([tab], I get a lot of precomilations

This test

export JULIA_DEPOT_PATH="~/this_file_does_not_exist"
julia --trace-compile=precompiles -q --startup-file=no
[ type the following: "1+1[up][up][enter]1[up][down][left][right][down][home][backspace][del]one([tab]"  ]
cat precompiles

Yields

precompile(Tuple{typeof(Base.repeat), Char, Int64})
precompile(Tuple{typeof(Base.seek), Base.GenericIOBuffer{GenericMemory{:not_atomic, UInt8, Core.AddrSpace{Core}(0x00)}}, Int64})
precompile(Tuple{typeof(Base.setindex!), Array{String, 1}, String, Int64})
precompile(Tuple{REPL.LineEdit.var"#27#28"{REPL.LineEdit.var"#156#212", String}, Any, Any})
precompile(Tuple{REPL.LineEdit.var"#156#212", REPL.LineEdit.MIState, Any, Vararg{Any}})
precompile(Tuple{REPL.LineEdit.var"#27#28"{REPL.LineEdit.var"#155#211", String}, Any, Any})
precompile(Tuple{REPL.LineEdit.var"#155#211", REPL.LineEdit.MIState, Any, Vararg{Any}})
precompile(Tuple{REPL.LineEdit.var"#27#28"{REPL.LineEdit.var"#265#269"{REPL.LineEdit.PrefixHistoryPrompt}, String}, Any, Any})
precompile(Tuple{typeof(Base.isequal), UInt8})
precompile(Tuple{REPL.LineEdit.var"#265#269"{REPL.LineEdit.PrefixHistoryPrompt}, REPL.LineEdit.MIState, Any, Vararg{Any}})
precompile(Tuple{REPL.LineEdit.var"#27#28"{REPL.LineEdit.var"#148#204", String}, Any, Any})
precompile(Tuple{REPL.LineEdit.var"#148#204", REPL.LineEdit.MIState, Any, Vararg{Any}})
precompile(Tuple{typeof(Base.min), Float64, Float64})
precompile(Tuple{REPL.LineEdit.var"#27#28"{REPL.LineEdit.var"#161#217", String}, Any, Any})
precompile(Tuple{REPL.LineEdit.var"#161#217", REPL.LineEdit.MIState, Any, Vararg{Any}})
precompile(Tuple{typeof(Base.show), Base.GenericIOBuffer{GenericMemory{:not_atomic, UInt8, Core.AddrSpace{Core}(0x00)}}, Method})
precompile(Tuple{typeof(Base.show), Base.IOContext{Base.GenericIOBuffer{GenericMemory{:not_atomic, UInt8, Core.AddrSpace{Core}(0x00)}}}, Core.TypeofBottom})
precompile(Tuple{typeof(Base.show_signature_function), Base.IOContext{Base.GenericIOBuffer{GenericMemory{:not_atomic, UInt8, Core.AddrSpace{Core}(0x00)}}}, Any, Bool, String, Bool})
precompile(Tuple{Type{Pair{A, B} where B where A}, Symbol, TypeVar})
precompile(Tuple{typeof(Base.string_with_env), Base.ImmutableDict{Symbol, Any}, TypeVar})
precompile(Tuple{typeof(REPL.Terminals.cmove_down), REPL.Terminals.TTYTerminal, Int64})
precompile(Tuple{typeof(REPL.Terminals.cmove_col), REPL.Terminals.TTYTerminal, Int64})
precompile(Tuple{typeof(Base.write), Base.TTY, Char})
precompile(Tuple{REPL.LineEdit.var"#27#28"{REPL.LineEdit.var"#248#256", String}, Any, Any})
precompile(Tuple{REPL.LineEdit.var"#248#256", REPL.LineEdit.MIState, REPL.LineEdit.ModeState, Any})
precompile(Tuple{typeof(Base.print), Base.TTY, String})

On Julia 1.11

julia> versioninfo()
Julia Version 1.11.0-beta1
Commit 08e1fc0abb9 (2024-04-10 08:40 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (aarch64-linux-gnu)
  CPU: 8 × unknown
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, apple-m2)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)
Environment:
  JULIA_DEPOT_PATH = ~/this_file_does_not_exist

See also #52783, #51532

I find these precompilations annoying when I'm trying to determine whether my packages are fully precompiled at the REPL and have to parse out what is my fault and what is just the REPL.

@LilithHafner LilithHafner added stdlib:REPL Julia's REPL (Read Eval Print Loop) compiler:precompilation Precompilation of modules labels Apr 14, 2024
@IanButterworth
Copy link
Sponsor Member

This might just take entering your cheat code into this script

repl_script = """
2+2
print("")
printstyled("a", "b")
display([1])
display([1 2; 3 4])
foo(x) = 1
@time @eval foo(1)
; pwd
$CTRL_C
$CTRL_R$CTRL_C#
? reinterpret
using Ra\t$CTRL_C
\\alpha\t$CTRL_C
\e[200~paste here ;)\e[201~"$CTRL_C
$UP_ARROW$DOWN_ARROW$CTRL_C
123\b\b\b$CTRL_C
\b\b$CTRL_C
f(x) = x03
f(1,2)
[][1]
cd("complete_path\t\t$CTRL_C
"""

@LilithHafner
Copy link
Member Author

Thank you! This is why I opened an issue instead of a PR. PR forthcoming.

@LilithHafner
Copy link
Member Author

LilithHafner commented Apr 15, 2024

Unfortunately, that won't be enough. For example, typing 2+2 at the REPL currently triggers compilation even though it is already in the precompile script.

x@fedora:~/.julia/dev/SplitREPL$ julia +nightly --startup-file=no --trace-compile=stderr
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _' |  |
  | | |_| | | | (_| |  |  Version 1.12.0-DEV.344 (2024-04-15)
 _/ |\__'_|_|_|\__'_|  |  Commit 7ba1b332f87 (0 days old master)
|__/                   |

julia> 2+precompile(Tuple{typeof(Base.repeat), Char, Int64})
2

@IanButterworth
Copy link
Sponsor Member

#51106 would be helpful for diagnosing that, but it needs a rebase (cc. @JeffBezanson)

@KristofferC
Copy link
Sponsor Member

The time these take are all of the order of where they take less time than is perceptible by a human and since this is for interactive work they don't really make a difference. If something is found that takes a long time it can be added to the script.

@LilithHafner
Copy link
Member Author

As I mentioned in the OP, the runtime isn't what bothers me; it's the noise when I'm trying to test the precompilation of my own packages. An alternative solution would be to suppress or provide an option to suppress these precomiplation statements from being emitted.

The fact that 2+2 is in the precompile script and yet typing 2+2 in the REPL is not fully precompiled is bad. As @KristofferC correctly notes, it is not a catastrophic bug, but it should still be fixed.

@LilithHafner LilithHafner reopened this Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:precompilation Precompilation of modules stdlib:REPL Julia's REPL (Read Eval Print Loop)
Projects
None yet
Development

No branches or pull requests

3 participants