From fb9029dc47e6113c09c27ca54c55a0610566ee81 Mon Sep 17 00:00:00 2001 From: Eduardo Souza Date: Thu, 23 Jan 2025 19:34:46 +0000 Subject: [PATCH] Skipping some tests that are currently incompatible with MMTk --- base/Base.jl | 2 ++ base/timing.jl | 6 ++-- stdlib/Profile/test/allocs.jl | 13 +++++++-- stdlib/Profile/test/runtests.jl | 3 ++ test/cmdlineargs.jl | 49 +++++++++++++++++++-------------- test/gc.jl | 24 +++++++++------- test/misc.jl | 4 ++- 7 files changed, 64 insertions(+), 37 deletions(-) diff --git a/base/Base.jl b/base/Base.jl index 04f732a4309c9..63898854b9fac 100644 --- a/base/Base.jl +++ b/base/Base.jl @@ -128,6 +128,8 @@ include("sysinfo.jl") include("libc.jl") using .Libc: getpid, gethostname, time, memcpy, memset, memmove, memcmp +const USING_STOCK_GC = occursin("stock", unsafe_string(ccall(:jl_gc_active_impl, Ptr{UInt8}, ()))) + # These used to be in build_h.jl and are retained for backwards compatibility. # NOTE: keep in sync with `libblastrampoline_jll.libblastrampoline`. const libblas_name = "libblastrampoline" * (Sys.iswindows() ? "-5" : "") diff --git a/base/timing.jl b/base/timing.jl index 65c2a643d6a52..61fa73f2eff62 100644 --- a/base/timing.jl +++ b/base/timing.jl @@ -109,10 +109,8 @@ function gc_page_utilization_data() return Base.unsafe_wrap(Array, page_utilization_raw, JL_GC_N_MAX_POOLS, own=false) end - -const USING_STOCK_GC = occursin("stock", unsafe_string(ccall(:jl_gc_active_impl, Ptr{UInt8}, ()))) # Full sweep reasons are currently only available for the stock GC -@static if USING_STOCK_GC +@static if Base.USING_STOCK_GC # must be kept in sync with `src/gc-stock.h`` const FULL_SWEEP_REASONS = [:FULL_SWEEP_REASON_SWEEP_ALWAYS_FULL, :FULL_SWEEP_REASON_FORCED_FULL_SWEEP, :FULL_SWEEP_REASON_USER_MAX_EXCEEDED, :FULL_SWEEP_REASON_LARGE_PROMOTION_RATE] @@ -135,7 +133,7 @@ function full_sweep_reasons() d = Dict{Symbol, Int64}() # populate the dictionary according to the reasons above for the stock GC # otherwise return an empty dictionary for now - @static if USING_STOCK_GC + @static if Base.USING_STOCK_GC reason = cglobal(:jl_full_sweep_reasons, UInt64) reasons_as_array = Base.unsafe_wrap(Vector{UInt64}, reason, length(FULL_SWEEP_REASONS), own=false) for (i, r) in enumerate(FULL_SWEEP_REASONS) diff --git a/stdlib/Profile/test/allocs.jl b/stdlib/Profile/test/allocs.jl index d4930a2b7f5ed..5607783c782f9 100644 --- a/stdlib/Profile/test/allocs.jl +++ b/stdlib/Profile/test/allocs.jl @@ -73,8 +73,14 @@ end @test length(first_alloc.stacktrace) > 0 @test length(string(first_alloc.type)) > 0 - @testset for type in (Task, Vector{Float64},) - @test length(filter(a->a.type <: type, profile.allocs)) >= NUM_TASKS + # Issue #57103: This test does not work with MMTk because of fastpath + # allocation which never calls the allocation profiler. + # TODO: We should port these observability tools (e.g. allocation + # profiler and heap snapshot) to MMTk + @static if Base.USING_STOCK_GC + @testset for type in (Task, Vector{Float64},) + @test length(filter(a->a.type <: type, profile.allocs)) >= NUM_TASKS + end end # TODO: it would be nice to assert that these tasks @@ -143,6 +149,8 @@ end @test length([a for a in prof.allocs if a.type == String]) >= 1 end +# FIXME: Issue #57103 disabling test for MMTk. +@static if Base.USING_STOCK_GC @testset "alloc profiler catches allocs from codegen" begin @eval begin struct MyType x::Int; y::Int end @@ -162,6 +170,7 @@ end @test length(prof.allocs) >= 1 @test length([a for a in prof.allocs if a.type == MyType]) >= 1 end +end @testset "alloc profiler catches allocs from buffer resize" begin f(a) = for _ in 1:100; push!(a, 1); end diff --git a/stdlib/Profile/test/runtests.jl b/stdlib/Profile/test/runtests.jl index b73a2a618011b..a5a604d7923d0 100644 --- a/stdlib/Profile/test/runtests.jl +++ b/stdlib/Profile/test/runtests.jl @@ -344,6 +344,8 @@ end @test only(node.down).first == lidict[8] end +# FIXME: Issue #57103: heap snapshots is not currently supported in MMTk +@static if Base.USING_STOCK_GC @testset "HeapSnapshot" begin tmpdir = mktempdir() @@ -374,6 +376,7 @@ end rm(fname) rm(tmpdir, force = true, recursive = true) end +end @testset "PageProfile" begin fname = "$(getpid())_$(time_ns())" diff --git a/test/cmdlineargs.jl b/test/cmdlineargs.jl index 3ff7836223b84..ec7a51e804d3f 100644 --- a/test/cmdlineargs.jl +++ b/test/cmdlineargs.jl @@ -383,29 +383,33 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no` @test p.exitcode == 1 && p.termsignal == 0 end - # --gcthreads - code = "print(Threads.ngcthreads())" - cpu_threads = ccall(:jl_effective_threads, Int32, ()) - @test string(cpu_threads) == - read(`$exename --threads auto -e $code`, String) == - read(`$exename --threads=auto -e $code`, String) == - read(`$exename -tauto -e $code`, String) == - read(`$exename -t auto -e $code`, String) - for nt in (nothing, "1") - withenv("JULIA_NUM_GC_THREADS" => nt) do - @test read(`$exename --gcthreads=2 -e $code`, String) == "2" - end - withenv("JULIA_NUM_GC_THREADS" => nt) do - @test read(`$exename --gcthreads=2,1 -e $code`, String) == "3" + # FIXME: Issue #57103 --gcthreads does not have the same semantics + # for Stock GC and MMTk, so the tests below are specific to the Stock GC + @static if Base.USING_STOCK_GC + # --gcthreads + code = "print(Threads.ngcthreads())" + cpu_threads = ccall(:jl_effective_threads, Int32, ()) + @test string(cpu_threads) == + read(`$exename --threads auto -e $code`, String) == + read(`$exename --threads=auto -e $code`, String) == + read(`$exename -tauto -e $code`, String) == + read(`$exename -t auto -e $code`, String) + for nt in (nothing, "1") + withenv("JULIA_NUM_GC_THREADS" => nt) do + @test read(`$exename --gcthreads=2 -e $code`, String) == "2" + end + withenv("JULIA_NUM_GC_THREADS" => nt) do + @test read(`$exename --gcthreads=2,1 -e $code`, String) == "3" + end end - end - withenv("JULIA_NUM_GC_THREADS" => 2) do - @test read(`$exename -e $code`, String) == "2" - end + withenv("JULIA_NUM_GC_THREADS" => 2) do + @test read(`$exename -e $code`, String) == "2" + end - withenv("JULIA_NUM_GC_THREADS" => "2,1") do - @test read(`$exename -e $code`, String) == "3" + withenv("JULIA_NUM_GC_THREADS" => "2,1") do + @test read(`$exename -e $code`, String) == "3" + end end # --machine-file @@ -1182,6 +1186,10 @@ end end end +# FIXME: Issue #57103: MMTK currently does not use --heap-size-hint since it only +# supports setting up a hard limit unlike the Stock GC +# which takes it as a soft limit. For now, we skip the tests below for MMTk +@static if Base.USING_STOCK_GC @testset "heap size hint" begin #heap-size-hint, we reserve 250 MB for non GC memory (llvm, etc.) @test readchomp(`$(Base.julia_cmd()) --startup-file=no --heap-size-hint=500M -e "println(@ccall jl_gc_get_max_memory()::UInt64)"`) == "$((500-250)*1024*1024)" @@ -1201,6 +1209,7 @@ end @test readchomp(`$(Base.julia_cmd()) --startup-file=no --heap-size-hint=10M -e "println(@ccall jl_gc_get_max_memory()::UInt64)"`) == "$(1*1024*1024)" end +end ## `Main.main` entrypoint diff --git a/test/gc.jl b/test/gc.jl index c532f17f04eb5..18a3a3aa54ffc 100644 --- a/test/gc.jl +++ b/test/gc.jl @@ -17,6 +17,9 @@ function run_gctest(file) end end +#FIXME: Issue #57103 disabling tests for MMTk, since +# they rely on information that is specific to the stock GC. +@static if Base.USING_STOCK_GC function run_nonzero_page_utilization_test() GC.gc() page_utilization = Base.gc_page_utilization_data() @@ -24,16 +27,6 @@ function run_nonzero_page_utilization_test() @test any(page_utilization .> 0) end -function run_pg_size_test() - page_size = @ccall jl_get_pg_size()::UInt64 - # supported page sizes: 4KB and 16KB - @test page_size == (1 << 12) || page_size == (1 << 14) -end - -function issue_54275_alloc_string() - String(UInt8['a' for i in 1:10000000]) -end - function issue_54275_test() GC.gc(true) baseline = Base.gc_live_bytes() @@ -55,6 +48,17 @@ function full_sweep_reasons_test() @test reasons[:FULL_SWEEP_REASON_FORCED_FULL_SWEEP] >= 1 @test keys(reasons) == Set(Base.FULL_SWEEP_REASONS) end +end + +function run_pg_size_test() + page_size = @ccall jl_get_pg_size()::UInt64 + # supported page sizes: 4KB and 16KB + @test page_size == (1 << 12) || page_size == (1 << 14) +end + +function issue_54275_alloc_string() + String(UInt8['a' for i in 1:10000000]) +end # !!! note: # Since we run our tests on 32bit OS as well we confine ourselves diff --git a/test/misc.jl b/test/misc.jl index 7070fd49f5f36..070952db89032 100644 --- a/test/misc.jl +++ b/test/misc.jl @@ -1453,7 +1453,8 @@ end @test_throws ErrorException finalizer(x->nothing, 1) @test_throws ErrorException finalizer(C_NULL, 1) - +# FIXME: Issue #57103 Test is specific to Stock GC +@static if Base.USING_STOCK_GC @testset "GC utilities" begin GC.gc() GC.gc(true); GC.gc(false) @@ -1473,6 +1474,7 @@ end @test occursin("GC: pause", read(tmppath, String)) end end +end @testset "fieldtypes Module" begin @test fieldtypes(Module) === ()