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

add function to query GC page size #54115

Merged
merged 1 commit into from
Apr 18, 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
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