-
Notifications
You must be signed in to change notification settings - Fork 28
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
Improving @require
performance
#39
Comments
Likely similar to timholy/Revise.jl#50. |
Thanks, much better with just 1 julia> @time using FilePaths
0.090361 seconds (40.75 k allocations: 2.667 MiB) The downside is that it introduces race conditions. |
Alright, I think part of my issue is still just that my glue code can't get precompiled with the rest of my package. I tried just optionally evaluating the code in my |
Can I take a look at how you're doing this? Couldn't see a branch on your repo. |
My branch is kind of a mess right now, but in my function __init__()
@sync begin
@async begin
if Base.isbindingresolved(Main, :Glob)
Glob = getfield(Main, :Glob)
@eval begin
"""
glob{T<:AbstractPath}(path::T, pattern::AbstractString) -> Array{T}
Returns all subpaths along the provided `path` which match the glob `pattern`.
# Example
```
julia> glob(p"src", "*.jl")
9-element Array{FilePaths.PosixPath,1}:
p"src/FilePaths.jl"
p"src/constants.jl"
p"src/deprecates.jl"
p"src/libc.jl"
p"src/mode.jl"
p"src/path.jl"
p"src/posix.jl"
p"src/status.jl"
p"src/windows.jl"
```
"""
function $(Glob).glob{T<:AbstractPath}(path::T, pattern::AbstractString)
matches = $(Glob).glob(pattern, String(path))
map(T, matches)
end
end
end
end
@async begin
if Base.isbindingresolved(Main, :URIParser)
URIParser = getfield(Main, :URIParser)
@eval begin
"""
uri(path::AbstractPath) -> AbstractPath
Creates a `file://` `URI` from the `path`.
"""
function uri(path::AbstractPath)
if isempty(root(path))
error("$path is not an absolute path")
end
uri_str = "file://$(String(path))"
return $(URIParser).URI(uri_str)
end
end
end
end
end
end I was previously just wrapping those 2 function definitions ( |
There's been a lot of performance work done on this package. |
I'm not sure if there's much that can be done, but the
@require
appears be hurting my load times by an order of magnitude. I'm guessing this has something to do with what code is able to be cached between julia sessions?Loading Glob.jl and URIParser.jl w/ the appropriate glue code:
Using 2
@require
blocks for the Glob.jl and URIParser.jl glue code (not loading those packages):NOTES: I have precompile enabled and this is after the cache has been updated between changes. I also ran it a few times for each and got fairly consistent results.
The text was updated successfully, but these errors were encountered: