| @@ -51,14 +51,14 @@ That is about 9.5 KiB per actor, 0.95 GB for 100,000, against about 2.6 KB per B |
| 51 | 51 | |
| 52 | 52 | ## Decision |
| 53 | 53 | 1. **Keep the per-actor lock for links, monitors and exits.** They are rare, and their ordering with exits is simplest under one lock. |
| 54 | | −2. **Replace the mailbox's lock by a lock-free inbox with an owner-private mailbox (proposed, to implement and measure):** |
| 54 | +2. **Replace the mailbox's lock by a lock-free inbox with an owner-private mailbox** (to implement and measure: issue #136): |
| 55 | 55 | - The inbox is one atomic word, CAF's design: an intrusive LIFO of message nodes, pushed with a CAS, with tag values for "empty", "closed" (the actor exited: a push fails and the message goes back to its sender, as now) and "owner waiting". |
| 56 | 56 | - The push that replaces "owner waiting" schedules the actor. This replaces the sender's look at `waiting_tags` and `RunState.queued` for messages. |
| 57 | 57 | - The owner takes the whole list with one swap, reverses it (push order), and files it into the tag map it already has (`Mailbox`), which only it touches. Arrival numbers are assigned then. Per-sender order is kept. |
| 58 | 58 | - Before parking, the owner swaps "empty" for "owner waiting"; if the swap fails, messages arrived and it files them first. That swap happens on the scheduler side, after the fiber is suspended (as `RunState::stop` does today), so no thread resumes a fiber still on its way out. |
| 59 | 59 | - A message on a tag the owner does not wait for wakes it, as in BEAM; it files the message and parks again. |
| 60 | 60 | - Timers and kills wake a waiting owner the same way, by pushing a signal node: a timeout carries its wait number, so the owner drops a stale one, as `Proc::time_out` does now. A kill still sets the kill flag and marks the actor exited under its lock first. |
| 61 | | −3. **Make memory per actor its own work, with a budget of 2 KiB per idle actor** (issue to be opened). The candidates are smaller, packed stack reservations, which share page tables; giving back the pages of parked and pooled stacks; and moving an idle actor's stack out of its own mapping. Each changes how deep a compiled actor can recurse, which ADR 0004 matched to the interpreter, and needs its own ADR. |
| 61 | +3. **Make memory per actor its own work, with a budget of 2 KiB per idle actor** (issue #137). The candidates are smaller, packed stack reservations, which share page tables; giving back the pages of parked and pooled stacks; and moving an idle actor's stack out of its own mapping. Each changes how deep a compiled actor can recurse, which ADR 0004 matched to the interpreter, and needs its own ADR. |
| 62 | 62 | |
| 63 | 63 | `--features lock-stats` (off by default) counts, per scheduler thread, actor-lock acquisitions and those that found the lock taken, and prints them at exit with `LOUISE_LEAKS`. It is how the contention above was measured, and how the change in point 2 is checked. |
| 64 | 64 | |