Skip to content

Commit

Permalink
more gc testing again ...
Browse files Browse the repository at this point in the history
  • Loading branch information
benlorenz committed Jul 18, 2023
1 parent d0f7ea7 commit f2c31d9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 85 deletions.
90 changes: 5 additions & 85 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,13 @@ jobs:
fail-fast: false
matrix:
julia-version:
- '1.6'
- '1.9'
- '~1.10.0-0'
- 'nightly'
os:
- ubuntu-latest
include:
# Add a few macOS jobs (not too many, the number we can run in parallel is limited)
- julia-version: 'nightly'
os: macOS-latest
threads:
- '1'
- '2'
dummy: [ 1, 2, 3, 4, 5, 6, 7, 8 ]

steps:
- uses: actions/checkout@v3
Expand All @@ -47,87 +44,10 @@ jobs:
- name: "Build package"
uses: julia-actions/julia-buildpkg@latest
- name: "limit OpenMP threads"
if: runner.os == 'macOS'
# restrict number of openMP threads on macOS due to oversubscription
run: echo "OMP_NUM_THREADS=1" >> $GITHUB_ENV
run: echo "OMP_NUM_THREADS=${{ matrix.threads }}" >> $GITHUB_ENV
- name: "Run tests"
uses: julia-actions/julia-runtest@latest
with:
annotate: ${{ matrix.julia-version == '1.9' }}
coverage: ${{ matrix.julia-version == '1.9' }}
depwarn: error
- name: "Process code coverage"
if: matrix.julia-version == '1.9'
uses: julia-actions/julia-processcoverage@v1
with:
directories: src,experimental
- name: "Upload coverage data to Codecov"
if: matrix.julia-version == '1.9'
continue-on-error: true
uses: codecov/codecov-action@v3

doctest:
runs-on: ${{ matrix.os }}
timeout-minutes: 150
continue-on-error: ${{ matrix.julia-version == 'nightly' }}
strategy:
fail-fast: false
matrix:
julia-version:
- '1.9'
- '~1.10.0-0'
- 'nightly'
os:
- ubuntu-latest
include:
# Add macOS jobs (not too many, the number we can run in parallel is limited)
- julia-version: '1.9'
os: macOS-latest

steps:
- uses: actions/checkout@v3
with:
# For Codecov, we must also fetch the parent of the HEAD commit to
# be able to properly deal with PRs / merges
fetch-depth: 2
- name: "Set up Julia"
uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.julia-version }}
- name: "Build package"
uses: julia-actions/julia-buildpkg@latest
- name: "limit OpenMP threads"
if: runner.os == 'macOS'
# restrict number of openMP threads on macOS due to oversubscription
run: echo "OMP_NUM_THREADS=1" >> $GITHUB_ENV
- name: "Run tests"
# HACK: since macOS runners are so expensive, we reuse this one to run
# both regular tests and doctests
if: runner.os == 'macOS'
uses: julia-actions/julia-runtest@latest
with:
annotate: ${{ matrix.julia-version == '1.9' }}
coverage: ${{ matrix.julia-version == '1.9' }}
depwarn: error
- name: "Setup package"
run: |
julia --project=docs --color=yes -e '
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()'
- name: "Run doctests"
run: |
julia --project=docs --depwarn=error --color=yes -e'
using Documenter
using Oscar
DocMeta.setdocmeta!(Oscar, :DocTestSetup, :(using Oscar; Oscar.AbstractAlgebra.set_current_module(@__MODULE__)); recursive = true)
doctest(Oscar)'
- name: "Process code coverage"
if: matrix.julia-version == '1.9'
uses: julia-actions/julia-processcoverage@v1
with:
directories: src,experimental
- name: "Upload coverage data to Codecov"
if: matrix.julia-version == '1.9'
continue-on-error: true
uses: codecov/codecov-action@v3
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[deps]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand Down
23 changes: 23 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ using Distributed

import Random

import InteractiveUtils

using Printf

numprocs_str = get(ENV, "NUMPROCS", "1")

if !isempty(ARGS)
Expand Down Expand Up @@ -48,6 +52,10 @@ end

@everywhere const stats_dict = Dict{String,NamedTuple}()

if VERSION >= v"1.8.0"
@everywhere GC.enable_logging(true)
end

function print_stats(io::IO; fmt=PrettyTables.tf_unicode, max=50)
sorted = sort(collect(stats_dict), by=x->x[2].time, rev=true)
println(io, "### Stats per file")
Expand All @@ -63,11 +71,22 @@ function print_stats(io::IO; fmt=PrettyTables.tf_unicode, max=50)
PrettyTables.pretty_table(io, table; tf=fmt, max_num_of_rows=max, header=header, formatters=formatters)
end

@everywhere function meminfo_julia()
# @printf "GC total: %9.3f MiB\n" Base.gc_total_bytes(Base.gc_num())/2^20
# Total bytes (above) usually underreports, thus I suggest using live bytes (below)
@printf "GC live: %9.3f MiB\n" Base.gc_live_bytes()/2^20
@printf "JIT: %9.3f MiB\n" Base.jit_total_bytes()/2^20
@printf "Max. RSS: %9.3f MiB\n" Sys.maxrss()/2^20
@printf "Free mem: %9.3f MiB\n" Sys.free_memory()/2^20
@printf "Free pmem: %9.3f MiB\n" Sys.free_physical_memory()/2^20
end

# we only want to print stats for files that run tests and not those that just
# include other files
@everywhere const innermost = Ref(true)
# redefine include to print and collect some extra stats
@everywhere function include(str::String)
meminfo_julia()
innermost[] = true
# we pass the identity to avoid recursing into this function again
@static if compiletimes
Expand Down Expand Up @@ -147,10 +166,14 @@ const testlist = [
"StraightLinePrograms/runtests.jl"
]

InteractiveUtils.versioninfo(verbose=true)

# if many workers, distribute tasks across them
# otherwise, is essentially a serial loop
pmap(include, testlist)

InteractiveUtils.versioninfo(verbose=true)

@static if compiletimes
Base.cumulative_compile_timing(false);
end
Expand Down

0 comments on commit f2c31d9

Please sign in to comment.