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

Add precompile statement for Base.Ryu.writefixed from Float64 to Int64 #50416

Conversation

mkitti
Copy link
Contributor

@mkitti mkitti commented Jul 5, 2023

@time Pkg.activate seems to use Base.Ryu.writefixed on Julia master.

$ ./julia -e 'using Pkg; for i in 1:5; @time Pkg.activate("~/.julia/dev/ScriptUtils"); end' --trace-compile=stderr;
  Activating project at `~/.julia/dev/ScriptUtils`
precompile(Tuple{typeof(Base.Ryu.writefixed), Float64, Int64})
  0.003745 seconds (5.75 k allocations: 541.180 KiB)
  Activating project at `~/.julia/dev/ScriptUtils`
  0.002678 seconds (5.06 k allocations: 492.125 KiB)
  Activating project at `~/.julia/dev/ScriptUtils`
  0.002498 seconds (5.06 k allocations: 492.125 KiB)
  Activating project at `~/.julia/dev/ScriptUtils`
  0.002476 seconds (5.06 k allocations: 492.094 KiB)
  Activating project at `~/.julia/dev/ScriptUtils`
  0.002553 seconds (5.06 k allocations: 492.391 KiB)

Since environment activation is a common operation, we should precompile this statement.

precompile(Tuple{typeof(Base.Ryu.writefixed), Float64, Int64})

I had added this by hard coding it in contrib/generate_precompile.jl.

Edit: Revised to more clearly indicate that @time Pkg.activate() triggers the compilation, but either alone.

@KristofferC
Copy link
Sponsor Member

KristofferC commented Jul 5, 2023

Doesn't make much sense to me to add this add at such a low level. If you want Pkg.activate to be precompiled, then just precompile that? If Pkg.activate changes then maybe it won't use this anymore.

@mkitti
Copy link
Contributor Author

mkitti commented Jul 5, 2023

I'm not sure why. I just know this statement seems to appear still even after adding the precompile statements in the other pull request to Julia master.

@KristofferC
Copy link
Sponsor Member

KristofferC commented Jul 5, 2023

Isn't this related to the @time call in JuliaLang/Pkg.jl#3540 (specifically when printing out compilation time)?

@KristofferC
Copy link
Sponsor Member

Fixed by #49585

@KristofferC KristofferC closed this Jul 5, 2023
@mkitti
Copy link
Contributor Author

mkitti commented Jul 5, 2023

It does appear related to @time. However, it appeared with Julia master branch, so I'm not clear if it is fixed for @time there.

@KristofferC
Copy link
Sponsor Member

And adding this fixed it?

@mkitti
Copy link
Contributor Author

mkitti commented Jul 5, 2023

Confirming that

  1. This precompile statement is associated with @time Pkg.activate()
  2. This precompile statement does not occur with with @time Pkg.activate() alone
  3. This precompile statement does not occur with with @time 5+5
$ ./julia -e "using Pkg; @time Pkg.activate();" --trace-compile=stderr
precompile(Tuple{Pkg.API.var"##activate#305", Bool, Bool, Bool, Base.TTY, typeof(Pkg.API.activate)})
  Activating project at `/tmp/tmp.298dOvl2Nq/environments/v1.11`
precompile(Tuple{typeof(Base.Ryu.writefixed), Float64, Int64})
  0.015479 seconds (6.80 k allocations: 547.344 KiB, 95.73% compilation time)

$ ./julia -e "using Pkg; Pkg.activate();" --trace-compile=stderr
precompile(Tuple{typeof(Pkg.API.activate)})
precompile(Tuple{Pkg.API.var"##activate#305", Bool, Bool, Bool, Base.TTY, typeof(Pkg.API.activate)})
  Activating project at `/tmp/tmp.298dOvl2Nq/environments/v1.11`

$ ./julia -e "using Pkg; @time 5+5;" --trace-compile=stderr --startup-file=no
  0.000001 seconds

I will rebuild with this branch to confirm that adding the precompile statement resolves the issue.

@mkitti
Copy link
Contributor Author

mkitti commented Jul 5, 2023

With an empty default environment, I get the following when doing @time Pkg.activate(). We see Tuple{typeof(Base.Ryu.writefixed), Float64, Int64} compiled on Julia 1.9.2 and nightly. With this branch, I no longer see that.

I conclude that this is not fixed by #49585 .

Julia 1.9.2 official build

julia-1.9.2/bin$ ./julia -e "using Pkg; @time Pkg.activate();" --trace-compile=stderr --startup-file=no
precompile(Tuple{Pkg.API.var"##activate#295", Bool, Bool, Bool, Base.TTY, typeof(Pkg.API.activate)})
  Activating project at `/tmp/tmp.298dOvl2Nq/environments/v1.9`
precompile(Tuple{typeof(Base.prettyprint_getunits), Int64, Int64, Int64})
precompile(Tuple{typeof(Base.Ryu.writefixed), Float64, Int64})
  0.017992 seconds (7.77 k allocations: 600.562 KiB, 96.10% compilation time)
Julia Version 1.9.2
Commit e4ee485e909 (2023-07-05 09:39 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 8 × AMD FX(tm)-8350 Eight-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, bdver1)
  Threads: 1 on 8 virtual cores
Environment:
  JULIA_DEPOT_PATH = /tmp/tmp.298dOvl2Nq

Julia Nightly

julia-23c0418899/bin$ ./julia -e "using Pkg; @time Pkg.activate();" --trace-compile=stderr --startup-file=no
precompile(Tuple{Pkg.API.var"##activate#305", Bool, Bool, Bool, Base.TTY, typeof(Pkg.API.activate)})
  Activating project at `/tmp/tmp.298dOvl2Nq/environments/v1.11`
precompile(Tuple{typeof(Base.Ryu.writefixed), Float64, Int64})
  0.015608 seconds (6.93 k allocations: 558.617 KiB, 95.55% compilation time)
Julia Version 1.11.0-DEV.14
Commit 23c04188996 (2023-07-05 13:30 UTC)
Platform Info:
  OS: precompile(Tuple{typeof(Base.print), Base.TTY, Symbol})
Linux (x86_64-linux-gnu)
  CPU: precompile(Tuple{typeof(Base.print), Base.TTY, Int64})
8 × AMD FX(tm)-8350 Eight-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-precompile(Tuple{typeof(Base.print), Base.TTY, Base.VersionNumber})
15.0.7 (ORCJIT, bdver1)
  Threads: 1 on 8 virtual cores
Environment:
  JULIA_DEPOT_PATH = /tmp/tmp.298dOvl2Nq

This Branch

$ ./julia -e "using Pkg; @time Pkg.activate();" --trace-compile=stderr --startup-file=no
precompile(Tuple{Pkg.API.var"##activate#305", Bool, Bool, Bool, Base.TTY, typeof(Pkg.API.activate)})
  Activating project at `/tmp/tmp.298dOvl2Nq/environments/v1.11`
  0.015410 seconds (6.93 k allocations: 558.500 KiB, 95.46% compilation time)
Julia Version 1.11.0-DEV.15
Commit b4c502b877* (2023-07-05 18:01 UTC)
Platform Info:
  OS: precompile(Tuple{typeof(Base.print), Base.TTY, Symbol})
Linux (x86_64-linux-gnu)
  CPU: precompile(Tuple{typeof(Base.print), Base.TTY, Int64})
8 × AMD FX(tm)-8350 Eight-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-precompile(Tuple{typeof(Base.print), Base.TTY, Base.VersionNumber})
15.0.7 (ORCJIT, bdver1)
  Threads: 1 on 8 virtual cores
Environment:
  JULIA_DEPOT_PATH = /tmp/tmp.298dOvl2Nq

@mkitti
Copy link
Contributor Author

mkitti commented Jul 6, 2023

Could we reopen this or more clearly identify why it was closed?

@mkitti
Copy link
Contributor Author

mkitti commented Jul 6, 2023

@IanButterworth , do you also observe this compilation taking place with @time Pkg.activate()?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants