-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Avoid duplicate stat calls during startup/loading #55331
Avoid duplicate stat calls during startup/loading #55331
Conversation
function entry_point_and_project_file(dir::String, name::String)::Union{Tuple{Nothing,Nothing},Tuple{String,Nothing},Tuple{String,String}} | ||
path = normpath(joinpath(dir, "$name.jl")) | ||
isfile_casesensitive(path) && return path, nothing | ||
dir_name = joinpath(dir, name) | ||
path, project_file = entry_point_and_project_file_inside(dir_name, name) | ||
path === nothing || return path, project_file | ||
dir_jl = dir_name * ".jl" | ||
path, project_file = entry_point_and_project_file_inside(dir_jl, name) | ||
path === nothing || return path, project_file | ||
# check for less likely case with a bare file and no src directory last to minimize stat calls | ||
path = normpath(joinpath(dir, "$name.jl")) | ||
isfile_casesensitive(path) && return path, nothing | ||
return nothing, nothing | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe this is a breaking change in precedence between a bare Foo.jl
and Foo.jl/src/Foo.jl
because both couldn't coexist?
base/stat.jl
Outdated
stat(path::AbstractString) = @stat_call jl_stat Cstring path | ||
lstat(path::AbstractString) = @stat_call jl_lstat Cstring path | ||
function stat(path::AbstractString) | ||
@debug "stat($(repr(path)))" exception=(ErrorException("Fake error for backtrace printing"),stacktrace()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supposed to stay in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OP says
I left the
@debug
s in as they might be useful for similar investigations.
I personally don't really like leaving these |
Agreed - they also add an inference burden, can inhibit inlining, and even introduce spurious allocations. |
This reverts commit 67f9a1251c1afefcd8318b366dfa787fd2a2deed.
5934304
to
c4b1914
Compare
@KristofferC any idea why I had to revert Prior to that I was getting lots of
|
Not sure from just looking at the code. |
Avoids immediately successive stat calls for the same path during startup & loading. According to MacOS Instruments this reduces `stat64` calls during `--start=no -e "using Pkg"` from 844 to 672. On MacOS I don't see a speed improvement, but on WSL2 @timholy reported the test from JuliaLang#55171 sees a modest improvement. This PR (10 iterations) ``` tim@diva:~/.julia/bin$ time for i in {1..10}; do ./cli --help &> /dev/null; done real 0m2.999s user 0m3.547s sys 0m6.552s ``` master ``` real 0m3.217s user 0m3.794s sys 0m6.700s ``` 1.11-rc2: ``` real 0m3.746s user 0m4.169s sys 0m6.755s ``` I left the `@debug`s in as they might be useful for similar investigations.
Avoids immediately successive stat calls for the same path during startup & loading.
According to MacOS Instruments this reduces
stat64
calls during--start=no -e "using Pkg"
from 844 to 672.On MacOS I don't see a speed improvement, but on WSL2 @timholy reported the test from #55171 sees a modest improvement.
This PR (10 iterations)
master
1.11-rc2:
I left the
@debug
s in as they might be useful for similar investigations.