# Memory scorecard: peak RSS against go (target at most 0.7x) (/docs/experiments/runtime/memory-scorecard)

Date: 2026-11-18.

## Sources [#sources]

- macOS: the bench run of 2026-11-17 (main bd3fa968, M3 Pro), field peak_rss_bytes, go against marmot-release. Darwin values have no floor.
- Linux: the bench run of 2026-11-17 (main 961b5f85). Every value has a floor of 12 to 14 MB, because the peak RSS of the bench driver is copied into the child. Only the 16 programs above 16 MB are usable.
- Linux, no floor: rtcore.md section 18 (fork, exec, wait4, release, best of 3, main with 9917e9bc and 961b5f85).

Main at bd3fa968 has the map table release (9917e9bc) and the zeroed register buffer (961b5f85). It does not have the early collection (held, rtcore.md section 17).

## Result [#result]

21 of 45 programs are above 0.7x on the Mac. On Linux, the small programs are above 0.7x too (4.1 MB against 2.8 MB, see below).

| Program | Mac ratio | Linux ratio | Cause | Owner, next step |
| --- | --- | --- | --- | --- |
| jsondec | 1.97 | 2.12 | Dead locals in the frame of main keep the decoded result reachable. The conservative stack scan sees them. | Compiler: precise stack liveness (section 14). |
| wordfreq | 1.68 | 1.37 | bytes.growSlice uses append([]byte(nil), make([]byte, c)...). Go makes one allocation, marmot allocates the make temporary and then the append result, so each doubling allocates two full arrays and the goal counts both. MARMOT_APPENDMAKE=1 (codegen, default off): 547 to 410 MB (go 401 MB), 9 collections before and after. | frontend: audit and flip MARMOT_APPENDMAKE. |
| sortslice | 1.65 | 1.65 | Allocation volume: about 1.25 more allocations per fmt.Sprint call (argument boxing that go avoids for constant strings and small integers). 12.0 million allocations against 7.0 million. | Compiler: boxing of fmt arguments (section 18). |
| deferloop | 1.63 | 3.09 (8.5 MB against 2.8 MB) | Not analyzed yet. | rtcore: analyze. |
| mapint | 1.39 | 1.07 to 1.09 | Map tables: 144 MB to 107 MB after 9917e9bc. The rest is the table layout and the goal. | rtcore and rtgo: map layout. Mac gap: see "Open". |
| mapstr | 1.31 | 1.12 to 1.14 | As mapint. | As mapint. |
| sha256 | 1.29 | 1.79 (9.0 MB against 5.0 MB) | Not analyzed yet. | rtcore: analyze. |
| regexpbench | 1.20 | 1.26 | 1.9x go's allocations (exact counts): 4 boxing sites in the fmt.Fprintf call allocate about 149k each (go: 3 sites, 165k total), regexp.(*Regexp).pad allocates 150k (go 0), main allocates 32 bytes per line. | frontend. |
| jsonenc | 1.03 | 1.12 to 1.22 | 6.1x go's allocations, 3x the bytes: []byte(s) conversions in the encoder (3.5M), reflect.Value.MapIndex and MapIter.Key per map entry (2M, go 0), strconv.AppendFloat's buffer (0.5M). | frontend (escape analysis), reflect owner. |
| fmtout, fmtlog, fmtbuf, parse, quicksort, heapsort, transpose | 0.96 to 0.98 | 0.96 to 1.18 | At parity with go. | See "Heap-bound programs". |
| bintrees, matmul, stringsearch, mapstruct, stencil | 0.72 to 0.88 | 0.69 to 0.99 | Below go, above the target. stringsearch is 0.69 on Linux with early collection. | See "Heap-bound programs". |
| hello, fib, saxpy and 20 other small programs | 0.54 to 0.67 (pass) | 1.48 to 1.57 (4.1 MB against 2.8 MB) | Linux only: the first heap touch gets a 2 MiB transparent huge page (section 19). | rtcore: MADV_NOHUGEPAGE for the first MiB of the heap, waits for a perfcmp slot (lead slot 14). |

## Heap-bound programs [#heap-bound-programs]

For a program whose peak is its live data times the goal factor, the same GOGC pacing gives about 1.0x. 0.7x needs less live data (smaller objects, fewer headers, more data on the stack) or a lower goal, which costs collections. The runtime cannot reach 0.7x alone for these programs. I propose that the scorecard reports them against 1.0x for the runtime and against 0.7x as a project target.

## Open [#open]

- The Mac ratios of wordfreq (1.68), mapint (1.39) and mapstr (1.31) are worse than Linux (1.37, 1.09, 1.12). A possible cause: darwin counts freed pages that the runtime gave back with MADV_FREE in RSS until the system needs memory. To check with a Mac research run (not timing): peak RSS with and without MADV_FREE_REUSABLE.
- The Linux bench values have the driver floor. A fix of the bench is in progress. Until then, the Linux column comes from section 18 for programs under 16 MB.