Skip to content

Commit

Permalink
Adds parallelism
Browse files Browse the repository at this point in the history
  • Loading branch information
Joey Carpinelli committed Sep 13, 2024
1 parent 861b05b commit 35c5115
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
5 changes: 4 additions & 1 deletion lib/SPICEKernels/gen/Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
SHELL := /bin/bash
JULIA_NUM_THREADS = $(shell nproc --all)

all:
JULIA_DEBUG=Main,SPICEKernels julia --project=. -e 'using Pkg; Pkg.instantiate(); Pkg.develop(PackageSpec(path="..")); include("make.jl")' force
JULIA_DEBUG=Main,SPICEKernels julia --project=. --threads ${JULIA_NUM_THREADS} -e 'using Pkg; Pkg.instantiate(); Pkg.develop(PackageSpec(path="..")); include("make.jl")' force
37 changes: 26 additions & 11 deletions lib/SPICEKernels/gen/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function lynx(url::AbstractString)
end

lines = split(contents.output)
return Set(map(String, lines))
return map(String, lines)
end

"""
Expand Down Expand Up @@ -60,23 +60,37 @@ Given a top-level directory, return the set of all kernel file paths found in al
"""
function traverse(
url::AbstractString;
searched::AbstractSet{<:AbstractString} = Set{String}(),
searched::AbstractSet{<:AbstractString} = Vector{String}(),
parallel = false,
)
url = HTTP.safer_joinpath(url, "")
@debug "Searching for kernels in $url"

found = Set{String}()
found = Vector{String}()
paths = search(url)
push!(searched, url)

setdiff!(paths, searched)

for path in paths
push!(searched, path)
if any(endswith(basename(path), ext) for ext in keys(SPICEKernels.SPICE_EXTENSIONS))
push!(found, path)
elseif !occursin(".", basename(path))
union!(found, traverse(path; searched = searched))
traverse_path!(path) =
let
push!(searched, path)
if any(
endswith(basename(path), ext) for ext in keys(SPICEKernels.SPICE_EXTENSIONS)
)
push!(found, path)
elseif !occursin(".", basename(path))
union!(found, traverse(path; searched = searched, parallel = false))
end
end

if parallel
Threads.@threads for path in paths
traverse_path!(path)
end
else
for path in paths
traverse_path!(path)
end
end

Expand All @@ -86,7 +100,7 @@ end
"""
Write all current kernel paths to the provided file name.
"""
function code!(kernels::AbstractSet{<:AbstractString}; force::Bool = false)
function code!(kernels::AbstractVector{<:AbstractString}; force::Bool = false)
kernellist = collect(kernels)
oldkernels = collect(values(SPICEKernels.NAIF_KERNELS_URL))
difference = setdiff(kernellist, oldkernels)
Expand Down Expand Up @@ -246,4 +260,5 @@ end
# The script portion!
#

code!(traverse(SPICEKernels.NAIF_KERNELS_URL); force = "force" in lowercase.(ARGS))
kernels = traverse(SPICEKernels.NAIF_KERNELS_URL, parallel = true)
code!(kernels, force = "force" in lowercase.(ARGS))

2 comments on commit 35c5115

@cadojo
Copy link
Collaborator

@cadojo cadojo commented on 35c5115 Sep 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register subdir="lib/EphemerisSourcesBase"

This comment was generated with commit-comment and Register.yml.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/115108

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a EphemerisSourcesBase-v0.1.2 -m "<description of version>" 35c51151a6f5d555f2d7f9eab7e63835add69821
git push origin EphemerisSourcesBase-v0.1.2

Please sign in to comment.