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

select_executor is slow #76

Closed
giordano opened this issue Jan 25, 2022 · 3 comments · Fixed by #108
Closed

select_executor is slow #76

giordano opened this issue Jan 25, 2022 · 3 comments · Fixed by #108

Comments

@giordano
Copy link
Collaborator

% julia --project=/tmp --startup-file=no -q                              
julia> using Sandbox; @time @eval Sandbox.select_executor(false)
  4.016078 seconds (10.87 M allocations: 574.060 MiB, 5.55% gc time, 99.88% compilation time)
UnprivilegedUserNamespacesExecutor

For comparison:

% julia --startup-file=no -q
julia> using BinaryBuilderBase; @time @eval BinaryBuilderBase.preferred_runner()
  0.009291 seconds (1.20 k allocations: 72.375 KiB, 97.16% compilation time)
UserNSRunner

Note that by forcing the Sandbox.jl runner with

% FORCE_SANDBOX_MODE=privileged julia --project=/tmp --startup-file=no -q
julia> using Sandbox; @time @eval Sandbox.select_executor(false)
  2.859711 seconds (10.62 M allocations: 561.097 MiB, 7.55% gc time, 100.03% compilation time)
PrivilegedUserNamespacesExecutor

the time is cut from 4 to 3 seconds, still 300x slower than BinaryBuilderBase.preferred_runner. They're both type-unstable (of course), but Sandbox.select_executor seems to be particularly bad, even when forcing the runner.

@giordano
Copy link
Collaborator Author

As an extra datapoint:

% julia --compile=min --project=/tmp --startup-file=no -q
julia> using Sandbox; @time @eval Sandbox.select_executor(false)
  0.366757 seconds (838.45 k allocations: 42.643 MiB, 3.60% gc time, 81.86% compilation time)
UnprivilegedUserNamespacesExecutor

@giordano
Copy link
Collaborator Author

I believe most of the time is spent compiling

Sandbox.jl/src/Docker.jl

Lines 31 to 33 in ed87f07

return with_executor(DockerExecutor) do exe
return probe_executor(exe; test_read_only_map=true, test_read_write_map=true, verbose)
end

@giordano
Copy link
Collaborator Author

giordano commented Oct 20, 2022

For the record, with JuliaLang/julia#47184 and Sandbox.select_executor(false) precompiled:

% ./julia --startup-file=no -q --project=/tmp
julia> @timed @eval using Sandbox
(value = nothing, time = 0.180352858, bytes = -8781611, gctime = 0.0, gcstats = Base.GC_Diff(-8781611, 7, 0, 378317, 327, 0, 0, 0, 0))

julia> @time @eval Sandbox.select_executor(false)
  0.006543 seconds (8.59 k allocations: 539.896 KiB)
PrivilegedUserNamespacesExecutor

🚀

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 a pull request may close this issue.

1 participant