Skip to content

Commit d3205e8

Browse files
stedolanncik-roberts
authored andcommitted
5.2 multicore markdelay (#3029)
* Markdelay support for multi-domain programs - Domains now begin marking simultaneously at some minor GC during the major cycle - Before marking, the write barrier is disabled and fresh allocations are UNMARKED - Change to ephemeron logic: per-cycle ephemeron data structure reset is now done at marking start rather than at the start of the cycle. (In particular, this makes orphaned work simpler to deal with) * Re-enable parallel tests Includes several systhreads tests that rely on the interaction between systhreads, domains and backup threads. * Add a new test (tests/parallel/churn.ml) stressing cross-domain promotion
1 parent 69c0427 commit d3205e8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+343
-233
lines changed

ocaml/otherlibs/str/str.ml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -607,16 +607,6 @@ external re_search_forward: regexp -> string -> int -> int array
607607
external re_search_backward: regexp -> string -> int -> int array
608608
= "re_search_backward"
609609

610-
module Domain = struct
611-
module DLS = struct
612-
613-
(* CR ocaml 5 domains: Remove this proxy and use the real Domain.DLS *)
614-
let[@inline always] new_key f = ref (f ())
615-
let[@inline always] set k s = k := s
616-
let[@inline always] get k = !k
617-
end
618-
end
619-
620610
let last_search_result_key = Domain.DLS.new_key (fun () -> [||])
621611

622612
let string_match re s pos =

ocaml/runtime/caml/domain.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ int caml_try_run_on_all_domains_with_spin_work(
109109
int sync,
110110
void (*handler)(caml_domain_state*, void*, int, caml_domain_state**),
111111
void* data,
112-
void (*leader_setup)(caml_domain_state*),
112+
void (*leader_setup)(caml_domain_state*, void*),
113113
/* return nonzero if there may still be useful work to do while spinning */
114114
int (*enter_spin_callback)(caml_domain_state*, void*),
115115
void* enter_spin_data);
116116
int caml_try_run_on_all_domains(
117117
void (*handler)(caml_domain_state*, void*, int, caml_domain_state**),
118118
void*,
119-
void (*leader_setup)(caml_domain_state*));
119+
void (*leader_setup)(caml_domain_state*, void*));
120120

121121
/* Function naming conventions for STW callbacks and STW critical sections.
122122

ocaml/runtime/caml/major_gc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ extern gc_phase_t caml_gc_phase;
3030
Caml_inline int caml_marking_started(void) {
3131
return caml_gc_phase != Phase_sweep_main;
3232
}
33+
extern atomic_uintnat caml_gc_mark_phase_requested;
3334

3435
intnat caml_opportunistic_major_work_available (caml_domain_state*);
3536
void caml_opportunistic_major_collection_slice (intnat);
@@ -45,7 +46,7 @@ void caml_teardown_major_gc(void);
4546
void caml_darken(void*, value, volatile value* ignored);
4647
void caml_darken_cont(value);
4748
void caml_mark_root(value, value*);
48-
void caml_empty_mark_stack(void);
49+
void caml_mark_roots_stw(int, caml_domain_state**);
4950
void caml_finish_major_cycle(int force_compaction);
5051
#ifdef DEBUG
5152
int caml_mark_stack_is_empty(void);

ocaml/runtime/caml/minor_gc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ extern void caml_realloc_ephe_ref_table (struct caml_ephe_ref_table *);
8787
extern void caml_realloc_custom_table (struct caml_custom_table *);
8888
struct caml_minor_tables* caml_alloc_minor_tables(void);
8989
void caml_free_minor_tables(struct caml_minor_tables*);
90-
void caml_empty_minor_heap_setup(caml_domain_state* domain);
90+
void caml_empty_minor_heap_setup(caml_domain_state* domain, void*);
9191

9292
#ifdef DEBUG
9393
extern int caml_debug_is_minor(value val);

ocaml/runtime/domain.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,8 +1031,6 @@ struct domain_startup_params {
10311031

10321032
static void* backup_thread_func(void* v)
10331033
{
1034-
// single-domain hack
1035-
caml_fatal_error("backup thread not allowed to run");
10361034
dom_internal* di = (dom_internal*)v;
10371035
uintnat msg;
10381036
struct interruptor* s = &di->interruptor;
@@ -1591,7 +1589,7 @@ int caml_try_run_on_all_domains_with_spin_work(
15911589
int sync,
15921590
void (*handler)(caml_domain_state*, void*, int, caml_domain_state**),
15931591
void* data,
1594-
void (*leader_setup)(caml_domain_state*),
1592+
void (*leader_setup)(caml_domain_state*, void*),
15951593
int (*enter_spin_callback)(caml_domain_state*, void*),
15961594
void* enter_spin_data)
15971595
{
@@ -1659,7 +1657,7 @@ int caml_try_run_on_all_domains_with_spin_work(
16591657
}
16601658

16611659
if( leader_setup ) {
1662-
leader_setup(domain_state);
1660+
leader_setup(domain_state, data);
16631661
}
16641662

16651663
#ifdef DEBUG
@@ -1726,7 +1724,7 @@ int caml_try_run_on_all_domains_with_spin_work(
17261724
int caml_try_run_on_all_domains(
17271725
void (*handler)(caml_domain_state*, void*, int, caml_domain_state**),
17281726
void* data,
1729-
void (*leader_setup)(caml_domain_state*))
1727+
void (*leader_setup)(caml_domain_state*, void*))
17301728
{
17311729
return
17321730
caml_try_run_on_all_domains_with_spin_work(1,
@@ -1738,7 +1736,7 @@ int caml_try_run_on_all_domains(
17381736
int caml_try_run_on_all_domains_async(
17391737
void (*handler)(caml_domain_state*, void*, int, caml_domain_state**),
17401738
void* data,
1741-
void (*leader_setup)(caml_domain_state*))
1739+
void (*leader_setup)(caml_domain_state*, void*))
17421740
{
17431741
return
17441742
caml_try_run_on_all_domains_with_spin_work(0,

0 commit comments

Comments
 (0)