| @@ -149,6 +149,29 @@ Constant dictionaries account for most of it: an arithmetic operation on `Int` a |
| 149 | 149 | |
| 150 | 150 | All `tests/run` programs give the same output on both backends with no leaked block, with 1 and 4 scheduler threads and under ASan+UBSan; `tests/run/reuse.lse` and `tests/run/reuse_unwinding.lse` cover reuse of unique and shared cells, size and tag changes, borrowed parameters whose fields escape, and reuse while `final ctl` unwinds, while a `ctl` body is suspended or cancelled, and in a panicking actor. |
| 151 | 151 | |
| 152 | +## Note — 2026-10-12: borrowing does not slow `arith` or `effects` (issue #102) |
| 153 | +**Status:** for review with the section above (#44). |
| 154 | + |
| 155 | +The step table above shows `arith` +2% and `effects` +3% from "+ borrowing". That was noise: the same section puts these runs at about ±10%, and its "+ reuse" column moves `arith` by +5%, which reuse cannot affect. |
| 156 | + |
| 157 | +**Measured again by instruction counts**, which are exact (`perf stat --no-scale -e instructions:u`, one scheduler thread, release builds, the cpu_core and cpu_atom rows summed). `LOUISE_NO_BORROW=1` turns borrow inference off, so every parameter is owned: |
| 158 | + |
| 159 | +| Benchmark | Borrowing (instructions) | All owned | Change | |
| 160 | +|---|---|---|---| |
| 161 | +| `arith` | 233,534,658 | 233,534,657 | 0 | |
| 162 | +| `effects` | 219,129,049 | 219,129,064 | 0 | |
| 163 | +| `dict` | 1,701,324,920 | 1,702,216,065 | −0.05% | |
| 164 | +| `lists` | 1,974,737,231 | 1,974,737,218 | 0 | |
| 165 | + |
| 166 | +**Why nothing moves:** in the hot loops (`sum_to`, `fib`, `ticks`, `count`), borrowing only changes parameters passed along unchanged. Owned, they are moved through the self tail call (a `goto`) at no cost; borrowed, they are not counted either. What changes is outside the loops: fewer drops on exit and smaller unwinding paths. |
| 167 | + |
| 168 | +**One real cost, kept on purpose:** a tail call to a function of *another* recursive group that borrows a variable the caller owns becomes a call, a yield check and a drop. In `effects`, the handler bodies' calls of `ticks` and `count` show it. Borrow inference keeps such calls tail calls within a group, where a loop would otherwise grow the stack. Across groups, the chain of calls is bounded by the call graph, and the cost is paid once per call, not per iteration. `louise_perceus`'s module documentation now says so; it claimed drops never come after a tail call. |
| 169 | + |
| 170 | +**Targets for the remaining Perceus work** (instructions, one thread), set before doing it: |
| 171 | +- borrowing is never more than 0.5% worse than all-owned on any benchmark (`LOUISE_NO_BORROW=1` measures it); |
| 172 | +- borrowing the map of a lookup (`dict.get`) without slowing `lists` or `html`: `dict` −5%; |
| 173 | +- reuse sizes known statically (arities in Core), and drop specialisation of nested matches (`[a, b, ..rest]`): `lists` −5%. |
| 174 | + |
| 152 | 175 | ## Implementation note — 2026-10-09: mimalloc for blocks (issue #35) |
| 153 | 176 | **Status:** Accepted by the project owner on 2026-10-09 (PRs #54–#59); needs engineering review (#44). mimalloc stays on by default. |
| 154 | 177 | |