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 heap size hint #2774

Merged
merged 13 commits into from
Jan 23, 2024
12 changes: 11 additions & 1 deletion src/Configuration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ const CHECK_BOUNDS_DEFAULT = nothing
const MATH_MODE_DEFAULT = nothing
const STARTUP_FILE_DEFAULT = "no"
const HISTORY_FILE_DEFAULT = "no"
const HEAP_SIZE_HINT_DEFAULT = nothing

function roughly_the_number_of_physical_cpu_cores()
# https://gist.github.com/fonsp/738fe244719cae820245aa479e7b4a8d
Expand Down Expand Up @@ -233,6 +234,7 @@ These options will be passed as command line argument to newly launched processe
- `inline::Union{Nothing,String} = $INLINE_DEFAULT`
- `check_bounds::Union{Nothing,String} = $CHECK_BOUNDS_DEFAULT`
- `math_mode::Union{Nothing,String} = $MATH_MODE_DEFAULT`
- `heap_size_hint::Union{Nothing,String} = $HEAP_SIZE_HINT_DEFAULT`
- `startup_file::Union{Nothing,String} = "$STARTUP_FILE_DEFAULT"` By default, the startup file isn't loaded in notebooks.
- `history_file::Union{Nothing,String} = "$HISTORY_FILE_DEFAULT"` By default, the history isn't loaded in notebooks.
- `threads::Union{Nothing,String,Int} = default_number_of_threads()`
Expand All @@ -253,6 +255,7 @@ These options will be passed as command line argument to newly launched processe
inline::Union{Nothing,String} = INLINE_DEFAULT
check_bounds::Union{Nothing,String} = CHECK_BOUNDS_DEFAULT
math_mode::Union{Nothing,String} = MATH_MODE_DEFAULT
heap_size_hint::Union{Nothing,String} = HEAP_SIZE_HINT_DEFAULT

# notebook specified options
# the followings are different from
Expand Down Expand Up @@ -319,6 +322,7 @@ function from_flat_kwargs(;
inline::Union{Nothing,String} = INLINE_DEFAULT,
check_bounds::Union{Nothing,String} = CHECK_BOUNDS_DEFAULT,
math_mode::Union{Nothing,String} = MATH_MODE_DEFAULT,
heap_size_hint::Union{Nothing,String} = HEAP_SIZE_HINT_DEFAULT,
startup_file::Union{Nothing,String} = STARTUP_FILE_DEFAULT,
history_file::Union{Nothing,String} = HISTORY_FILE_DEFAULT,
threads::Union{Nothing,String,Int} = default_number_of_threads(),
Expand Down Expand Up @@ -370,6 +374,7 @@ function from_flat_kwargs(;
inline,
check_bounds,
math_mode,
heap_size_hint,
startup_file,
history_file,
threads,
Expand Down Expand Up @@ -397,11 +402,16 @@ end

function _convert_to_flags(options::CompilerOptions)::Vector{String}
option_list = String[]
exclude_list = String[]

if VERSION < v"1.9"
push!(exclude_list, "--heap-size-hint")
end

for name in fieldnames(CompilerOptions)
flagname = string("--", replace(String(name), "_" => "-"))
value = getfield(options, name)
if value !== nothing
if value !== nothing && flagname ∉ exclude_list
push!(option_list, string(flagname, "=", value))
end
end
Expand Down
7 changes: 3 additions & 4 deletions test/Configuration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ end
end

@testset "flag conversion" begin
@test _convert_to_flags(Configuration.CompilerOptions(threads="123")) ==
["--startup-file=no", "--history-file=no", "--threads=123"]
reference_flags = ["--startup-file=no", "--history-file=no", "--threads=123"]

@test _convert_to_flags(Configuration.CompilerOptions(threads=123)) ==
["--startup-file=no", "--history-file=no", "--threads=123"]
@test _convert_to_flags(Configuration.CompilerOptions(threads="123")) == reference_flags
@test _convert_to_flags(Configuration.CompilerOptions(threads=123)) == reference_flags

@test _convert_to_flags(Configuration.CompilerOptions()) ⊇
["--startup-file=no", "--history-file=no"]
Expand Down
Loading