diff --git a/src/gc-pages.c b/src/gc-pages.c index 40e5454136148..4c27e5a097e58 100644 --- a/src/gc-pages.c +++ b/src/gc-pages.c @@ -9,6 +9,11 @@ extern "C" { #endif +JL_DLLEXPORT uint64_t jl_get_pg_size(void) +{ + return GC_PAGE_SZ; +} + // Try to allocate memory in chunks to permit faster allocation // and improve memory locality of the pools #ifdef _P64 diff --git a/test/gc.jl b/test/gc.jl index e085c1d8658e5..330c136389a4e 100644 --- a/test/gc.jl +++ b/test/gc.jl @@ -15,6 +15,19 @@ function run_gctest(file) end end +function run_nonzero_page_utilization_test() + GC.gc() + page_utilization = Base.gc_page_utilization_data() + # at least one of the pools should have nonzero page_utilization + @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 + # !!! 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 @@ -25,3 +38,9 @@ end run_gctest("gc/objarray.jl") run_gctest("gc/chunks.jl") end + +@testset "GC page metrics" begin + run_nonzero_page_utilization_test() + run_pg_size_test() +end +