From e3474fcdcb07c0e0b405a1af6bcfcfd94859a069 Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Sat, 11 Jul 2026 13:39:35 -0300 Subject: [PATCH 1/5] Temp memory stats --- src/ParallelTestRunner.jl | 60 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/src/ParallelTestRunner.jl b/src/ParallelTestRunner.jl index 35f332b..db80fce 100644 --- a/src/ParallelTestRunner.jl +++ b/src/ParallelTestRunner.jl @@ -490,10 +490,70 @@ function available_memory() return (Int(vms[].free_count) + Int(vms[].inactive_count) + Int(vms[].purgeable_count) + Int(vms[].compressor_page_count)) * page_size end +function print_memory_stats(io::IO=stdout) + vms = Ref{VmStatistics64}(VmStatistics64()) + mach_host_self = @ccall mach_host_self()::UInt32 + count = UInt32(sizeof(VmStatistics64) รท sizeof(Int32)) + ref_count = Ref(count) + @ccall host_statistics64(mach_host_self::UInt32, 4::Int64, pointer_from_objref(vms[])::Ptr{Int64}, ref_count::Ref{UInt32})::Int64 + + page_size = Int(@ccall sysconf(29::UInt32)::UInt32) + println(io, "VmStatistics64: ") + println(io, " Available memory: ", Base.format_bytes((vms[].free_count + vms[].inactive_count + vms[].purgeable_count + vms[].compressor_page_count) * page_size)) + println(io, "\n free_count: ", Base.format_bytes(vms[].free_count * page_size)) + println(io, " active_count: ", Base.format_bytes(vms[].active_count * page_size)) + println(io, " inactive_count: ", Base.format_bytes(vms[].inactive_count * page_size)) + println(io, " wire_count: ", Base.format_bytes(vms[].wire_count * page_size)) + println(io, " purgeable_count: ", Base.format_bytes(vms[].purgeable_count * page_size)) + println(io, " speculative_count: ", Base.format_bytes(vms[].speculative_count * page_size)) + println(io, " compressor_page_count: ", Base.format_bytes(vms[].compressor_page_count * page_size)) + println(io, " throttled_count: ", Base.format_bytes(vms[].throttled_count * page_size)) + println(io, " external_page_count: ", Base.format_bytes(vms[].external_page_count * page_size)) + println(io, " internal_page_count: ", Base.format_bytes(vms[].internal_page_count * page_size)) + println(io, " total_uncompressed_pages_in_compressor: ", Base.format_bytes(vms[].total_uncompressed_pages_in_compressor * page_size)) +end + else available_memory() = Sys.free_memory() +if Sys.islinux() + +function read_meminfo() + fields = Dict{SubString{String}, UInt64}() + for line in eachline("/proc/meminfo") + key, rest = split(line, ':'; limit=2) + fields[key] = parse(UInt64, match(r"\d+", rest).match) * UInt64(1024) + end + return fields +end + + +function print_memory_stats(io::IO=stdout) + fields = read_meminfo() + println(io, "/proc/meminfo: ") + println(io, " Available memory: ", Base.format_bytes(available_memory())) + println(io, "\n MemTotal: ", Base.format_bytes(get(fields, "MemTotal", 0))) + println(io, " MemFree: ", Base.format_bytes(get(fields, "MemFree", 0))) + println(io, " Buffers: ", Base.format_bytes(get(fields, "Buffers", 0))) + println(io, " Cached: ", Base.format_bytes(get(fields, "Cached", 0))) + println(io, " SwapCached: ", Base.format_bytes(get(fields, "SwapCached", 0))) + println(io, " SwapTotal: ", Base.format_bytes(get(fields, "SwapTotal", 0))) + println(io, " SwapFree: ", Base.format_bytes(get(fields, "SwapFree", 0))) + println(io, " Active: ", Base.format_bytes(get(fields, "Active", 0))) + println(io, " Inactive: ", Base.format_bytes(get(fields, "Inactive", 0))) + println(io, " Dirty: ", Base.format_bytes(get(fields, "Dirty", 0))) + println(io, " Writeback: ", Base.format_bytes(get(fields, "Writeback", 0))) + println(io, " Slab: ", Base.format_bytes(get(fields, "Slab", 0))) + println(io, " Shmem: ", Base.format_bytes(get(fields, "Shmem", 0))) +end + +else + +function print_memory_stats(io::IO=stdout) + println(io, "Available memory: ", Base.format_bytes(available_memory())) +end + end # This is an internal function, not to be used by end users. The keyword From 8b14eb1fe13f02f2e1fdc300d64ebc90dd9431a7 Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Sat, 11 Jul 2026 13:41:51 -0300 Subject: [PATCH 2/5] Format --- src/ParallelTestRunner.jl | 61 +++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/src/ParallelTestRunner.jl b/src/ParallelTestRunner.jl index db80fce..587b89d 100644 --- a/src/ParallelTestRunner.jl +++ b/src/ParallelTestRunner.jl @@ -519,41 +519,38 @@ available_memory() = Sys.free_memory() if Sys.islinux() -function read_meminfo() - fields = Dict{SubString{String}, UInt64}() - for line in eachline("/proc/meminfo") - key, rest = split(line, ':'; limit=2) - fields[key] = parse(UInt64, match(r"\d+", rest).match) * UInt64(1024) - end - return fields -end - - -function print_memory_stats(io::IO=stdout) - fields = read_meminfo() - println(io, "/proc/meminfo: ") - println(io, " Available memory: ", Base.format_bytes(available_memory())) - println(io, "\n MemTotal: ", Base.format_bytes(get(fields, "MemTotal", 0))) - println(io, " MemFree: ", Base.format_bytes(get(fields, "MemFree", 0))) - println(io, " Buffers: ", Base.format_bytes(get(fields, "Buffers", 0))) - println(io, " Cached: ", Base.format_bytes(get(fields, "Cached", 0))) - println(io, " SwapCached: ", Base.format_bytes(get(fields, "SwapCached", 0))) - println(io, " SwapTotal: ", Base.format_bytes(get(fields, "SwapTotal", 0))) - println(io, " SwapFree: ", Base.format_bytes(get(fields, "SwapFree", 0))) - println(io, " Active: ", Base.format_bytes(get(fields, "Active", 0))) - println(io, " Inactive: ", Base.format_bytes(get(fields, "Inactive", 0))) - println(io, " Dirty: ", Base.format_bytes(get(fields, "Dirty", 0))) - println(io, " Writeback: ", Base.format_bytes(get(fields, "Writeback", 0))) - println(io, " Slab: ", Base.format_bytes(get(fields, "Slab", 0))) - println(io, " Shmem: ", Base.format_bytes(get(fields, "Shmem", 0))) -end + function read_meminfo() + fields = Dict{SubString{String}, UInt64}() + for line in eachline("/proc/meminfo") + key, rest = split(line, ':'; limit=2) + fields[key] = parse(UInt64, match(r"\d+", rest).match) * UInt64(1024) + end + return fields + end + function print_memory_stats(io::IO=stdout) + fields = read_meminfo() + println(io, "/proc/meminfo: ") + println(io, " Available memory: ", Base.format_bytes(available_memory())) + println(io, "\n MemTotal: ", Base.format_bytes(get(fields, "MemTotal", 0))) + println(io, " MemFree: ", Base.format_bytes(get(fields, "MemFree", 0))) + println(io, " Buffers: ", Base.format_bytes(get(fields, "Buffers", 0))) + println(io, " Cached: ", Base.format_bytes(get(fields, "Cached", 0))) + println(io, " SwapCached: ", Base.format_bytes(get(fields, "SwapCached", 0))) + println(io, " SwapTotal: ", Base.format_bytes(get(fields, "SwapTotal", 0))) + println(io, " SwapFree: ", Base.format_bytes(get(fields, "SwapFree", 0))) + println(io, " Active: ", Base.format_bytes(get(fields, "Active", 0))) + println(io, " Inactive: ", Base.format_bytes(get(fields, "Inactive", 0))) + println(io, " Dirty: ", Base.format_bytes(get(fields, "Dirty", 0))) + println(io, " Writeback: ", Base.format_bytes(get(fields, "Writeback", 0))) + println(io, " Slab: ", Base.format_bytes(get(fields, "Slab", 0))) + println(io, " Shmem: ", Base.format_bytes(get(fields, "Shmem", 0))) + end else - -function print_memory_stats(io::IO=stdout) - println(io, "Available memory: ", Base.format_bytes(available_memory())) + function print_memory_stats(io::IO=stdout) + println(io, "Available memory: ", Base.format_bytes(available_memory())) + end end - end # This is an internal function, not to be used by end users. The keyword From 5473e8c7ef2fd91d71433513a0e742292a792cc0 Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Sat, 11 Jul 2026 13:47:15 -0300 Subject: [PATCH 3/5] Remove --- src/ParallelTestRunner.jl | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/ParallelTestRunner.jl b/src/ParallelTestRunner.jl index 587b89d..138d8f1 100644 --- a/src/ParallelTestRunner.jl +++ b/src/ParallelTestRunner.jl @@ -536,9 +536,6 @@ if Sys.islinux() println(io, " MemFree: ", Base.format_bytes(get(fields, "MemFree", 0))) println(io, " Buffers: ", Base.format_bytes(get(fields, "Buffers", 0))) println(io, " Cached: ", Base.format_bytes(get(fields, "Cached", 0))) - println(io, " SwapCached: ", Base.format_bytes(get(fields, "SwapCached", 0))) - println(io, " SwapTotal: ", Base.format_bytes(get(fields, "SwapTotal", 0))) - println(io, " SwapFree: ", Base.format_bytes(get(fields, "SwapFree", 0))) println(io, " Active: ", Base.format_bytes(get(fields, "Active", 0))) println(io, " Inactive: ", Base.format_bytes(get(fields, "Inactive", 0))) println(io, " Dirty: ", Base.format_bytes(get(fields, "Dirty", 0))) From 6e64c0e0a8672bbf59db64381bfc1d065a448813 Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Sat, 11 Jul 2026 13:48:11 -0300 Subject: [PATCH 4/5] Print during tests --- test/runtests.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index 888ecb0..714157c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,6 +5,8 @@ cd(@__DIR__) include(joinpath(@__DIR__, "utils.jl")) +ParallelTestRunner.print_memory_stats() + @testset "ParallelTestRunner" verbose=true begin @testset "basic use" begin From 16dd1502bdfc53657ae7c7b1cca46c243274f087 Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Sat, 11 Jul 2026 13:57:49 -0300 Subject: [PATCH 5/5] Test --- src/ParallelTestRunner.jl | 4 ++++ test/runtests.jl | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ParallelTestRunner.jl b/src/ParallelTestRunner.jl index 138d8f1..87acb96 100644 --- a/src/ParallelTestRunner.jl +++ b/src/ParallelTestRunner.jl @@ -1038,6 +1038,10 @@ function _runtests(mod::Module, args::ParsedArgs; ) # determine parallelism + print_memory_stats() + GC.gc() + print_memory_stats() + jobs = something(args.jobs, default_njobs()) jobs = clamp(jobs, 1, length(tests)) println(stdout, "Running $(length(tests)) tests using $jobs parallel jobs. If this is too many concurrent jobs, specify the `--jobs=N` argument to the tests, or set the `JULIA_CPU_THREADS` environment variable.") diff --git a/test/runtests.jl b/test/runtests.jl index 714157c..888ecb0 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,8 +5,6 @@ cd(@__DIR__) include(joinpath(@__DIR__, "utils.jl")) -ParallelTestRunner.print_memory_stats() - @testset "ParallelTestRunner" verbose=true begin @testset "basic use" begin