Skip to content

Meta-issue on asynchronous action handling in multicore #10915

@gadmm

Description

@gadmm

Related issues

Action points

First in any order:

  • Review the diff of finaliser.c between multicore and old trunk to make sure nothing is missing; reimplement caml_final_do_calls_exn.
  • Separate signalling from payload for inter-domain interrupts. Record the request for an interrupt separately from young_limit to distinguish the various asynchronous actions to perform when an allocation fails.
  • Discuss atomicity of young_limit (Multicore OCaml #10831 (comment)).

Then (in order):

  • caml_alloc_small_dispatch is a common entry point to the GC (restore its subtle logic)
  • Reimplement caml_do_pending_actions_exn/caml_process_pending_actions_exn
  • Minimise the diff with old trunk (check that nothing misses; preserve relevant bits of memprof implementation to avoid to forget things later on); make sure that there is no unjustified change to caml/signals.h and caml/alloc.h.

I think those are a pre-requisite for 5.0 (public API in actual use and the documented way to poll in long-running C functions). If not possible, at the very least, caml_process_pending_actions_exn should be reintroduced with a partial implementation.

Checklist for expected behaviours

The following are needed for 5.0:

  • caml_check_urgent_gc runs pending GC actions including inter-domain interrupts; no asynchronous callbacks. Idem when handling an inter-domain interrupt.
  • A function update_young_limits is used to locally set young_limit to the right value according to various pending action flags (signals, finalisers, inter-domain interrupts...), to make sure young_limit is always set to the right value.
  • caml_process_pending_actions_exn does not raise directly into OCaml.
  • caml_do_pending_actions_exn informs of possible future actions if interrupted by an exception.
  • finalisers do not run immediately when allocating from C; restore the guarantee at the top of caml/alloc.h.
  • Reintroduce caml_something_to_do and its logic?
  • Events are properly stopped in case of an asynchronous exception inside runtime/gc_ctrl.c.
  • caml_leave_blocking_section checks for signals like it used to.
  • Gc.alarms work as intended.

The following are not strictly needed for 5.0 (but most are likely fixed along with the rest).

  • OCaml signal handlers are guaranteed to be run as soon as possible.
  • No need for caml_handle_gc_interrupts_no_async.
  • caml_process_pending_actions* is the single entry point to run all pending actions (no separate caml_process_pending_signals*).
  • When recording a backtrace, no need to assume that finalisers could run.
  • The VM polls by comparing young_limit to young_ptr; investigate Use a bit-vector to record pending signals #10880 (comment).

(cc @sadiqj, @jhjourdan)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions