Skip to content

Commit

Permalink
Add heap size hint (#2774)
Browse files Browse the repository at this point in the history
Co-authored-by: Kirill Kondrashov <[email protected]>
Co-authored-by: Fons van der Plas <[email protected]>
  • Loading branch information
3 people authored Jan 23, 2024
1 parent 2307d84 commit eb2ee11
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
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

0 comments on commit eb2ee11

Please sign in to comment.