)]}'
{
  "commit": "f74f937d3fd8303d16c71fdc33b2bcdaa932b9d2",
  "tree": "e7c9f1252660f8acce604295d73ffd432f1db11a",
  "parents": [
    "6616a307a23ffd22ccb126d8d1b3b00d11469b90"
  ],
  "author": {
    "name": "Mattias Jansson",
    "email": "mjansson@gmail.com",
    "time": "Wed Nov 18 08:22:59 2026 +0100"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Wed Nov 18 08:22:59 2026 +0100"
  },
  "message": "Decommit free pages a heap leaves unused through a decommit window (#447)\n\nA heap decommitted its free pages down to the retain count (4 small, 2\nmedium-small, 1 medium-large and 1 large page) only once it had held at\nleast the threshold (16, 8, 4 and 2 pages) through the whole decommit\ndelay of 250ms, and the delay restarted whenever the count dropped below\nthe threshold. A heap holding fewer kept them committed indefinitely,\nand a heap reusing its free pages, whose count dropped below the\nthreshold now and then, never decommitted any, so within the delay only\nthe hard limit of four times the threshold bounded its free pages. With\nmany threads that is held in every heap, and most in the heaps of\nthreads whose blocks other threads free, which get pages back faster\nthan they reuse them.\n\nEach page type of a heap holding more free pages than its retain count\nnow runs a decommit window and tracks the lowest free committed page\ncount through it. When the window ends, the pages held through the whole\nwindow, the low water mark, were not reused and are decommitted down to\nthe retain count, the oldest first, and a new window starts if the heap\nstill holds more. A heap reusing its free pages keeps them committed\nwhatever their number, and a heap getting pages back faster than it\nreuses them decommits them after one window. The hard limit within the\nwindow is unchanged.\n\nWith more threads than processors the threads wait for a processor in\nturn, the free pages of a waiting heap sit unused, and a window of 250ms\ncovers only a few turns of a thread. While more heaps freed pages in the\nlast 250ms than there are processors the process can run on (its\naffinity mask on Linux, all processor groups on Windows 7 and later),\nthe window is shortened by that ratio, to at least a quarter. Heaps that\ndid not free pages, of idle or blocked threads, are not counted, so they\ndo not make busy heaps decommit and fault in their pages. Programs with\nno more active heaps than processors are unaffected.\n\nMeasured with mimalloc-bench under LD_PRELOAD, median of 5 interleaved\nruns on an 8 core Zen 3 virtual machine (gcc 15.2, Linux 7.0), with 16\nthreads for the N thread tests and 128 for the N128 ones, built without\nand with ENABLE_THP\u003d1 (mode madvise). Peak RSS in MiB:\n\n                         ENABLE_THP\u003d0            ENABLE_THP\u003d1\n  xmalloc-testN128  461.1 -\u003e 401.5 -12.9%   637.2 -\u003e 545.5 -14.4%\n  mstressN128        3994 -\u003e  3915  -2.0%    4167 -\u003e  4096  -1.7%\n  rptestN128        905.6 -\u003e 958.1  +5.8%    1480 -\u003e  1463  -1.1%\n  xmalloc-testN      78.6 -\u003e  77.6  -1.2%    98.0 -\u003e  97.4  -0.6%\n  larsonN           181.2 -\u003e 184.3  +1.7%   218.6 -\u003e 224.7  +2.8%\n  rbstressN         128.1 -\u003e 133.4  +4.2%   126.8 -\u003e 131.6  +3.8%\n  geomean of 23                     -0.1%                   -0.5%\n\nElapsed seconds, relative time for xmalloc-testN:\n\n                         ENABLE_THP\u003d0            ENABLE_THP\u003d1\n  xmalloc-testN128  0.164 -\u003e 0.167  +1.8%   0.166 -\u003e 0.167  +0.6%\n  mstressN128       18.44 -\u003e 18.17  -1.5%   18.01 -\u003e 18.05  +0.2%\n  rptestN128        16.10 -\u003e 16.10  +0.0%   16.08 -\u003e 16.08  +0.0%\n  geomean of 23                     -0.0%                   -0.1%\n\nThe other changes are within the run to run spread, rptestN128 without\ntransparent huge pages spread 17% over the runs of develop. A heap\nholding more than the threshold through the whole delay decommitted\ndown to the retain count even when it reused some of them, and now\nkeeps those it reused, so larsonN holds 2 to 3% more.\n\nWith ENABLE_THP\u003d1, decommitting free pages in a span backed by a huge\npage splits the huge page, as on develop, which at 128 threads splits\nnearly every huge page it faults. Counted system wide over the runs,\nthis change split 224 huge pages against 243 in xmalloc-testN128, 248\nin both in mstressN128 and 33 against 34 in xmalloc-testN. In mstressN,\n16 threads on 8 cores with the window halved, it split 22 against 13\nof the 68 faulted, at the same time.\n\nShortening the window to at least an eighth instead of a quarter took\nxmalloc-testN128 to 367MiB but ran it 4.8% slower than develop, and at\nleast half took it only to 443MiB. Scaling the threshold and retain\ncount down with the number of heaps instead, and the window with the\nnumber of heaps against processors, took xmalloc-testN128 to 325MiB but\nran it 8% slower, and counting every heap, idle ones included, made a\nheap with 63 idle heaps beside it decommit and fault in its pages every\nwindow, up to 4.5 times slower.",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "f1da71333caf9cb8341c2dc29ae228a45be30ad5",
      "old_mode": 33188,
      "old_path": "CHANGELOG",
      "new_id": "6055a0307b3db51b00b3a3ae1d0d9e0e9ade8c1e",
      "new_mode": 33188,
      "new_path": "CHANGELOG"
    },
    {
      "type": "modify",
      "old_id": "d2747bf612ce4e0651d8b2c13fe310df32456634",
      "old_mode": 33188,
      "old_path": "rpmalloc/rpmalloc.c",
      "new_id": "b83cbd13af09664752272d3175da4b95790cc368",
      "new_mode": 33188,
      "new_path": "rpmalloc/rpmalloc.c"
    }
  ]
}
