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 gc tests #469

Merged
merged 37 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
33ef48a
Initial Gc test
jmid Aug 27, 2024
485c5c4
Add Gc.minor_words and allocated_bytes and a cmd to alloc a string
jmid Aug 27, 2024
70f58a6
Add Gc.major_slice n and Gc.get_minor_free
jmid Aug 27, 2024
083caf9
Add Gc.major
jmid Aug 27, 2024
4e452ec
Add List allocation
jmid Aug 27, 2024
e78444c
Add list reversal cmd
jmid Aug 27, 2024
1ac1991
Remove stress test as the parallel test is positive and hence stress …
jmid Aug 29, 2024
1f3fd9f
Rename len_gen generator
jmid Sep 3, 2024
e68b4ae
Just use Gen.nat for major_slice and list allocation
jmid Sep 3, 2024
832fe18
Add initial stresstest for parent-child GC interaction
jmid Sep 3, 2024
0101559
Add CatStr, combining strings potentially from different major heaps
jmid Sep 5, 2024
d928093
Add stat and quick_stat commands
jmid Sep 8, 2024
6fb6723
Add Gc.get command
jmid Sep 9, 2024
863cd20
Avoid triggering Gc.counters memory unsafety on 5.2 and earlier
jmid Sep 9, 2024
dafcbca
Initial support for Gc.set cmd
jmid Sep 17, 2024
cc48f8f
Test polishing
jmid Sep 23, 2024
c43a127
unused vars
jmid Sep 23, 2024
8223bf7
Factor stat/quick_stat property
jmid Sep 23, 2024
026ca59
Support (O)CAMLRUNPARAM
jmid Sep 23, 2024
f6030af
Add PreAllocStr cmd
jmid Sep 24, 2024
553f996
Add PreAllocList cmd
jmid Sep 24, 2024
400ea85
Silence warnings
jmid Sep 24, 2024
5387696
Factor configuration into a separate module and adjust dune file
jmid Sep 24, 2024
113f092
Support v=63 under runtime-variant=d
jmid Sep 24, 2024
1be49aa
Adjust minor_heap_size test to be pagesize-aware
jmid Sep 25, 2024
d6e5353
Fix attempt for pagesize headers on MSVC
jmid Sep 25, 2024
1d5d96e
Factor Gc tests into two: with and without explicit Gc invocations
jmid Sep 27, 2024
48f7116
Adjust frequencies
jmid Sep 27, 2024
0cf33f8
Add Bigarray support
jmid Sep 27, 2024
ef02d55
Silence explicit GC test under the debug runtime, which by default wi…
jmid Oct 23, 2024
6280cd8
Remove implicit GC stress test, as the parallel test is positive
jmid Dec 11, 2024
ca1031d
Split src/gc/stm_tests_impl.ml in three, to start each from a clean-s…
jmid Dec 11, 2024
db1d58c
Split src/gc/stm_tests.ml in four, to start each from a clean-state heap
jmid Dec 11, 2024
7b50586
Rename GCConf to stm_tests_spec for consistency
jmid Dec 21, 2024
c3563f4
Code clean-ups
jmid Dec 21, 2024
bd4d6dc
Experiment: replace Gc.compact in 'cleanup' with Gc.full_major
jmid Dec 21, 2024
d7ab558
Temporarily omit Gc.compact to silence the remaining issues: #470 and…
jmid Jan 8, 2025
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
81 changes: 81 additions & 0 deletions src/gc/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
;; Tests of the stdlib Gc module

(library
(name pagesize)
(modules pagesize)
(foreign_stubs
(language c)
(names pagesizestub)
(flags (:standard)))
)

(test
(name stm_tests_seq)
(modules stm_tests_spec stm_tests_seq)
(package multicoretests)
(flags (:standard -w -37))
(libraries pagesize qcheck-stm.sequential)
(action
(setenv OCAMLRUNPARAM "%{env:OCAMLRUNPARAM=b},v=1"
(run %{test} --verbose)))
)

(test
(name stm_tests_seq_child)
(modules stm_tests_spec stm_tests_seq_child)
(package multicoretests)
(flags (:standard -w -37))
(libraries pagesize qcheck-stm.sequential)
(action
(setenv OCAMLRUNPARAM "%{env:OCAMLRUNPARAM=b},v=1"
(run %{test} --verbose)))
)

(test
(name stm_tests_par)
(modules stm_tests_spec stm_tests_par)
(package multicoretests)
(flags (:standard -w -37))
(libraries pagesize qcheck-stm.domain)
(action
(setenv OCAMLRUNPARAM "%{env:OCAMLRUNPARAM=b},v=1"
(run %{test} --verbose)))
)

(test
(name stm_tests_par_stress)
(modules stm_tests_spec stm_tests_par_stress)
(package multicoretests)
(flags (:standard -w -37))
(libraries pagesize qcheck-stm.domain)
(action
(setenv OCAMLRUNPARAM "%{env:OCAMLRUNPARAM=b},v=1"
(run %{test} --verbose)))
)

(test
(name stm_tests_impl_seq)
(modules stm_tests_spec stm_tests_impl_seq)
(package multicoretests)
(flags (:standard -w -37))
(libraries pagesize qcheck-stm.sequential)
(action (run %{test} --verbose))
)

(test
(name stm_tests_impl_seq_child)
(modules stm_tests_spec stm_tests_impl_seq_child)
(package multicoretests)
(flags (:standard -w -37))
(libraries pagesize qcheck-stm.sequential)
(action (run %{test} --verbose))
)

(test
(name stm_tests_impl_par)
(modules stm_tests_spec stm_tests_impl_par)
(package multicoretests)
(flags (:standard -w -37))
(libraries pagesize qcheck-stm.domain)
(action (run %{test} --verbose))
)
1 change: 1 addition & 0 deletions src/gc/pagesize.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
external get : unit -> int = "page_size"
27 changes: 27 additions & 0 deletions src/gc/pagesizestub.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <sysinfoapi.h>
#else
#include <unistd.h>
#endif

#include "caml/mlvalues.h"
#include "caml/memory.h"

CAMLprim value page_size(value ignored) {
CAMLparam1(ignored);
CAMLlocal1(result);

long ps;
#ifdef _WIN32
SYSTEM_INFO si;
GetSystemInfo(&si);
ps = si.dwPageSize;
#else
ps = sysconf(_SC_PAGESIZE); // page size in bytes
#endif

result = Val_int(ps);
CAMLreturn(result);
}
15 changes: 15 additions & 0 deletions src/gc/stm_tests_impl_par.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
(* parallel tests of the GC, without explicit Gc invocations *)

module ImplGCConf =
struct
include Stm_tests_spec
let arb_cmd = arb_alloc_cmd
end

module GC_STM_dom = STM_domain.Make(ImplGCConf)

let _ =
Printf.printf "Page size: %i\n" (Pagesize.get ());
QCheck_base_runner.run_tests_main [
GC_STM_dom.agree_test_par ~count:1000 ~name:"STM implicit Gc test parallel";
]
25 changes: 25 additions & 0 deletions src/gc/stm_tests_impl_seq.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
open QCheck

(* sequential tests of the GC, without explicit Gc invocations *)

module ImplGCConf =
struct
include Stm_tests_spec
let arb_cmd = arb_alloc_cmd
end

module GC_STM_seq = STM_sequential.Make(ImplGCConf)

let agree_prop cs = match Util.protect GC_STM_seq.agree_prop cs with
| Ok r -> r
| Error Stack_overflow -> true (* Stack_overflow is accepted behaviour *)
| Error e -> raise e

let agree_test ~count ~name =
Test.make ~name ~count (GC_STM_seq.arb_cmds ImplGCConf.init_state) agree_prop

let _ =
Printf.printf "Page size: %i\n" (Pagesize.get ());
QCheck_base_runner.run_tests_main [
agree_test ~count:1000 ~name:"STM implicit Gc test sequential";
]
26 changes: 26 additions & 0 deletions src/gc/stm_tests_impl_seq_child.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
open QCheck

(* sequential tests of the GC, without explicit Gc invocations *)

module ImplGCConf =
struct
include Stm_tests_spec
let arb_cmd = arb_alloc_cmd
end

module GC_STM_seq = STM_sequential.Make(ImplGCConf)

(* Run seq. property in a child domain to stresstest parent-child GC *)
let agree_child_prop cs = match Domain.spawn (fun () -> Util.protect GC_STM_seq.agree_prop cs) |> Domain.join with
| Ok r -> r
| Error Stack_overflow -> true (* Stack_overflow is accepted behaviour *)
| Error e -> raise e

let agree_child_test ~count ~name =
Test.make ~name ~count (GC_STM_seq.arb_cmds ImplGCConf.init_state) agree_child_prop

let _ =
Printf.printf "Page size: %i\n" (Pagesize.get ());
QCheck_base_runner.run_tests_main [
agree_child_test ~count:1000 ~name:"STM implicit Gc test sequential in child domain";
]
9 changes: 9 additions & 0 deletions src/gc/stm_tests_par.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(* parallel tests of the GC with explicit Gc invocations *)

module GC_STM_dom = STM_domain.Make(Stm_tests_spec)

let _ =
Printf.printf "Page size: %i\n" (Pagesize.get ());
QCheck_base_runner.run_tests_main [
GC_STM_dom.neg_agree_test_par ~count:1000 ~name:"STM Gc test parallel";
]
9 changes: 9 additions & 0 deletions src/gc/stm_tests_par_stress.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(* parallel stress tests of the GC with explicit Gc invocations *)

module GC_STM_dom = STM_domain.Make(Stm_tests_spec)

let _ =
Printf.printf "Page size: %i\n" (Pagesize.get ());
QCheck_base_runner.run_tests_main [
GC_STM_dom.stress_test_par ~count:1000 ~name:"STM Gc stress test parallel";
]
19 changes: 19 additions & 0 deletions src/gc/stm_tests_seq.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
open QCheck

(* sequential tests of the GC with explicit Gc invocations *)

module GC_STM_seq = STM_sequential.Make(Stm_tests_spec)

let agree_prop cs = match Util.protect GC_STM_seq.agree_prop cs with
| Ok r -> r
| Error Stack_overflow -> true (* Stack_overflow is accepted behaviour *)
| Error e -> raise e

let agree_test ~count ~name =
Test.make ~name ~count (GC_STM_seq.arb_cmds Stm_tests_spec.init_state) agree_prop

let _ =
Printf.printf "Page size: %i\n" (Pagesize.get ());
QCheck_base_runner.run_tests_main [
agree_test ~count:1000 ~name:"STM Gc test sequential";
]
20 changes: 20 additions & 0 deletions src/gc/stm_tests_seq_child.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
open QCheck

(* sequential tests of the GC with explicit Gc invocations *)

module GC_STM_seq = STM_sequential.Make(Stm_tests_spec)

(* Run seq. property in a child domain to stresstest parent-child GC *)
let agree_child_prop cs = match Domain.spawn (fun () -> Util.protect GC_STM_seq.agree_prop cs) |> Domain.join with
| Ok r -> r
| Error Stack_overflow -> true (* Stack_overflow is accepted behaviour *)
| Error e -> raise e

let agree_child_test ~count ~name =
Test.make ~name ~count (GC_STM_seq.arb_cmds Stm_tests_spec.init_state) agree_child_prop

let _ =
Printf.printf "Page size: %i\n" (Pagesize.get ());
QCheck_base_runner.run_tests_main [
agree_child_test ~count:1000 ~name:"STM Gc test sequential in child domain";
]
Loading
Loading