Skip to content

Commit

Permalink
add function to query GC page size
Browse files Browse the repository at this point in the history
  • Loading branch information
d-netto committed Apr 18, 2024
1 parent c741bd3 commit 352fc02
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/gc-pages.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions test/gc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ 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

# !!! 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
Expand All @@ -31,7 +37,11 @@ end
run_gctest("gc/linkedlist.jl")
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

@testset "Base.GC docstrings" begin
Expand Down

0 comments on commit 352fc02

Please sign in to comment.