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

Cherry-picking Ensure that new GC tests actually succeed (#49579) #33

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions test/gc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,22 @@ using Test

function run_gctest(file)
let cmd = `$(Base.julia_cmd()) --depwarn=error --rr-detach --startup-file=no $file`
for test_nthreads in (1, 2, 4)
@testset for test_nthreads in (1, 2, 4)
new_env = copy(ENV)
new_env["JULIA_NUM_THREADS"] = string(test_nthreads)
new_env["JULIA_NUM_GC_THREADS"] = string(test_nthreads)
@time run(pipeline(setenv(cmd, new_env), stdout = stdout, stderr = stderr))
@test success(run(pipeline(setenv(cmd, new_env), stdout = stdout, stderr = stderr)))
end
end
end

@time run_gctest("gc/binarytree.jl")
@time run_gctest("gc/linkedlist.jl")
@time run_gctest("gc/objarray.jl")
# !!! note:
# Since we run our tests on 32bit OS as well we confine ourselves
# to parameters that allocate about 512MB of objects. Max RSS is lower
# than that.
@testset "GC threads" begin
run_gctest("gc/binarytree.jl")
run_gctest("gc/linkedlist.jl")
run_gctest("gc/objarray.jl")
run_gctest("gc/chunks.jl")
end
3 changes: 2 additions & 1 deletion test/gc/binarytree.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ end #module

using .BinaryTreeMutable

BinaryTreeMutable.binary_trees(devnull, 20)
# Memory usage is 466MB
BinaryTreeMutable.binary_trees(devnull, 16)
GC.gc()
17 changes: 17 additions & 0 deletions test/gc/chunks.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

# MWE from https://github.com/JuliaLang/julia/issues/49501
N = 1_000_000 # or larger
T = BigFloat

struct Q{T}
a::T
b::T
end

# Memoy use is ~512MB
let
A = [Q(rand(T), rand(T)) for _ in 1:N]
end

GC.gc()
6 changes: 4 additions & 2 deletions test/gc/linkedlist.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ mutable struct ListNode
ListNode(x,y) = new(x,y);
end

function list(n=128)
function list(N=16*1024^2)
start::ListNode = ListNode(1)
current::ListNode = start
for i = 2:(n*1024^2)
for i = 2:N
current = ListNode(i,current)
end
return current.key
end

# Memory use is 512 MB
_ = list()

GC.gc()
5 changes: 3 additions & 2 deletions test/gc/objarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ end

function run(maxsize)
Threads.@threads for i in 1:maxsize
work(i*500)
work(i*375)
end
end

run(4)
# Memory usage 581 MB
@time run(4)
GC.gc()
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ move_to_node1("precompile")
move_to_node1("SharedArrays")
move_to_node1("threads")
move_to_node1("Distributed")
move_to_node1("gc")
# Ensure things like consuming all kernel pipe memory doesn't interfere with other tests
move_to_node1("stress")

Expand Down
Loading