Skip to content

Commit a67661e

Browse files
authored
add function to query GC page size (#54115)
1 parent 148330e commit a67661e

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/gc-pages.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
extern "C" {
1010
#endif
1111

12+
JL_DLLEXPORT uint64_t jl_get_pg_size(void)
13+
{
14+
return GC_PAGE_SZ;
15+
}
16+
1217
// Try to allocate memory in chunks to permit faster allocation
1318
// and improve memory locality of the pools
1419
#ifdef _P64

test/gc.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ function run_nonzero_page_utilization_test()
2222
@test any(page_utilization .> 0)
2323
end
2424

25+
function run_pg_size_test()
26+
page_size = @ccall jl_get_pg_size()::UInt64
27+
# supported page sizes: 4KB and 16KB
28+
@test page_size == (1 << 12) || page_size == (1 << 14)
29+
end
30+
2531
# !!! note:
2632
# Since we run our tests on 32bit OS as well we confine ourselves
2733
# to parameters that allocate about 512MB of objects. Max RSS is lower
@@ -31,7 +37,11 @@ end
3137
run_gctest("gc/linkedlist.jl")
3238
run_gctest("gc/objarray.jl")
3339
run_gctest("gc/chunks.jl")
40+
end
41+
42+
@testset "GC page metrics" begin
3443
run_nonzero_page_utilization_test()
44+
run_pg_size_test()
3545
end
3646

3747
@testset "Base.GC docstrings" begin

0 commit comments

Comments
 (0)