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

Remove buildpath from line information #54134

Open
vchuravy opened this issue Apr 18, 2024 · 2 comments
Open

Remove buildpath from line information #54134

vchuravy opened this issue Apr 18, 2024 · 2 comments
Labels
build Build system, or building Julia or its dependencies REPL Julia's REPL (Read Eval Print Loop)

Comments

@vchuravy
Copy link
Sponsor Member

So we currently store absolut paths in debuginfo for Julia and it's library. Locally this might be fine, but for our build artifacts this is rather pointless.

@KristofferC raised this recently as:

jl_apply at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-HL2F7YQ3XH.0/build/default-honeycrisp-HL2F7YQ3XH-0/julialang/julia-release-1-dot-11/src/./julia.h:2154 [inlined]
jl_f__call_latest at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-HL2F7YQ3XH.0/build/default-honeycrisp-HL2F7YQ3XH-0/julialang/julia-release-1-dot-11/src/builtins.c:875

The buildpath of /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-HL2F7YQ3XH.0/build/default-honeycrisp-HL2F7YQ3XH-0/julialang/julia-release-1-dot-11 is long and at least for me unecessary.

There are two parts of this.

  1. Runtime and libraries
  • libjulia & co
  • libLLVM & co (this we would need to fix in BinaryBuilder)
  1. Code coming from Julia

An example for 2 comes from:

julia> Profile.print()
Overhead ╎ [+additional indent] Count File:Line; Function
=========================================================
  ╎17 @Base/client.jl:552; _start()
  ╎ 17 @Base/client.jl:333; exec_options(opts::Base.JLOptions)
  ╎  17 @Base/client.jl:416; run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool)
  ╎   17 @Base/essentials.jl:889; invokelatest
  ╎    17 @Base/essentials.jl:892; #invokelatest#2
  ╎     17 @Base/client.jl:432; (::Base.var"#1013#1015"{Bool, Bool, Bool})(REPL::Module)
  ╎    ╎ 17 …/julialang/julia-release-1-dot-10/usr/share/julia/stdlib/v1.10/REPL/src/REPL.jl:375; run_repl(repl::REPL.AbstractREPL, consumer::Any)

We already do this for Base so maybe we can change that latter path to @REPL?

The bigger challenge here is to make sure that system profilers, "click on path" in REPL and other things keep working.
So we might need to remap files to local directories for presentation.

While discussing with @KristofferC I noticed that GCC/Clang support remapping paths using -ffile-prefix-map.

I locally tried the following patch:

diff --git a/Make.inc b/Make.inc
index 56558e17bb..6e56ceca65 100644
--- a/Make.inc
+++ b/Make.inc
@@ -509,7 +509,7 @@ DEBUGFLAGS_COMMON := -O0 -DJL_DEBUG_BUILD -fstack-protector
 DEBUGFLAGS_CLANG  := $(DEBUGFLAGS_COMMON) -g
 DEBUGFLAGS_GCC    := $(DEBUGFLAGS_COMMON) -ggdb2
 
-SHIPFLAGS_COMMON  := -O3
+SHIPFLAGS_COMMON  := -O3 -ffile-prefix-map=$(BUILDDIR)/= -ffile-prefix-map=$(JULIAHOME)/=
 SHIPFLAGS_CLANG   := $(SHIPFLAGS_COMMON) -g
 SHIPFLAGS_GCC     := $(SHIPFLAGS_COMMON) -ggdb2 -falign-functions

and the test-case:

julia> using Profile

julia> @profile 1+1
2

julia> @profile rand(5);

julia> Profile.print(C=true)
 ╎    ╎    ╎    ╎    ╎    ╎    ╎    ╎    ╎    ╎ 129 src/gf.c:2571; jl_compile_method_internal
 ╎    ╎    ╎    ╎    ╎    ╎    ╎    ╎    ╎    ╎  129 src/jitlayers.cpp:483; jl_compile_codeinst_impl
 ╎    ╎    ╎    ╎    ╎    ╎    ╎    ╎    ╎    ╎   1   src/jitlayers.cpp:219; _jl_compile_codeinst
 ╎    ╎    ╎    ╎    ╎    ╎    ╎    ╎    ╎    ╎    1   src/codegen.cpp:9648; jl_emit_codeinst
 ╎    ╎    ╎    ╎    ╎    ╎    ╎    ╎    ╎    ╎     1   src/codegen.cpp:9560; jl_emit_code
 ╎    ╎    ╎    ╎    ╎    ╎    ╎    ╎    ╎    ╎    ╎ 1   src/codegen.cpp:9225; emit_function
 ╎    ╎    ╎    ╎    ╎    ╎    ╎    ╎    ╎    ╎    ╎  1   src/codegen.cpp:5736; emit_ssaval_assign
 ╎    ╎    ╎    ╎    ╎    ╎    ╎    ╎    ╎    ╎    ╎   1   src/codegen.cpp:6186; emit_expr

Opening this as an issue instead of a PR since I suspect this will need a larger conversation that also includes changes to BinaryBuilder.

cc: @topolarity @vtjnash @giordano @staticfloat

@vchuravy vchuravy added build Build system, or building Julia or its dependencies REPL Julia's REPL (Read Eval Print Loop) labels Apr 18, 2024
@KristofferC
Copy link
Sponsor Member

KristofferC commented Apr 18, 2024

We already do this for Base so maybe we can change that latter path to @REPL?

FWIW, we already do some dynamic rewriting of stdlib path so that they are valid on the local system:

# Path is valid locally
julia> @which REPL.symbol_latex("s")
symbol_latex(s::String)
     @ REPL ~/.julia/juliaup/julia-1.10.2+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/REPL/src/docview.jl:403

julia> m = @which REPL.symbol_latex("s");

# What is actually stored is the build path
julia> m.file
Symbol("/Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-HL2F7YQ3XH.0/build/default-honeycrisp-HL2F7YQ3XH-0/julialang/julia-release-1-dot-10/usr/share/julia/stdlib/v1.10/REPL/src/docview.jl")

@vtjnash
Copy link
Sponsor Member

vtjnash commented Apr 18, 2024

We already do this for Base so maybe we can change that latter path to @REPL?

We already do that too, but the problem is the paths are wrong for the REPL files in the distributed code (as noted in this issue exactly) so the replacement doesn't happen. And it only applies to Julia code, not native code (which may have come from binary builder or system library built on some deb-builder cluster):

julia> Profile.print(C=true)
Overhead ╎ [+additional indent] Count File:Line; Function
=========================================================
   ╎1   /Users/jameson/julia/src/jlapi.c:1059; jl_repl_entrypoint
   ╎ 1   /Users/jameson/julia/src/jlapi.c:900; true_main
   ╎  1   /Users/jameson/julia/src/./julia.h:2185; jl_apply
   ╎   1   /Users/jameson/julia/src/gf.c:2975; _jl_invoke
   ╎    1   /Users/jameson/julia/usr/lib/julia/sys.dylib:?; jfptr__start_70204
   ╎     1   @Base/client.jl:543; _start()
   ╎    ╎ 1   @Base/client.jl:569; repl_main
   ╎    ╎  1   @Base/client.jl:432; run_main_repl(interactive::Bool, quiet::Bool, banner::Symbol, history_file::Bool, color_set::Bool)
   ╎    ╎   1   @Base/essentials.jl:1027; invokelatest
   ╎    ╎    1   @Base/essentials.jl:1030; #invokelatest#2
   ╎    ╎     1   /Users/jameson/julia/src/builtins.c:875; jl_f__call_latest
   ╎    ╎    ╎ 1   /Users/jameson/julia/src/./julia.h:2185; jl_apply
   ╎    ╎    ╎  1   /Users/jameson/julia/src/gf.c:2975; _jl_invoke
   ╎    ╎    ╎   1   /Users/jameson/julia/usr/share/julia/compiled/v1.12/REPL/u0gqU_764VE.dylib:?; jfptr_YY.1159_16881
   ╎    ╎    ╎    1   @Base/client.jl:448; (::Base.var"#1159#1161"{Bool, Symbol, Bool})(REPL::Module)
   ╎    ╎    ╎     1   /Users/jameson/julia/src/gf.c:2975; _jl_invoke
   ╎    ╎    ╎    ╎ 1   /Users/jameson/julia/usr/share/julia/compiled/v1.12/REPL/u0gqU_764VE.dylib:?; jfptr_run_repl_12388
   ╎    ╎    ╎    ╎  1   @REPL/src/REPL.jl:485; run_repl(repl::AbstractREPL, consumer::Any)
   ╎    ╎    ╎    ╎   1   @REPL/src/REPL.jl:499; run_repl(repl::AbstractREPL, consumer::Any; backend_on_current_task::Bool, backend::Any)
   ╎    ╎    ╎    ╎    1   /Users/jameson/julia/src/gf.c:2975; _jl_invoke
   ╎    ╎    ╎    ╎     1   @REPL/src/REPL.jl:340; kwcall(::NamedTuple, ::typeof(REPL.start_repl_backend), backend::REPL.REPLBackend, consumer::Any)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Build system, or building Julia or its dependencies REPL Julia's REPL (Read Eval Print Loop)
Projects
None yet
Development

No branches or pull requests

3 participants