You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 91218f3
Browse filesBrowse the repository at this point in the historyBrowse files
heap: a heap that is being released abandons its pages unmapped
`mi_heap_delete` and `mi_heap_destroy` abandon every page of the heap
(step 2 of the teardown) and then claim each one back through the
`arena_pages->pages` bitmap (step 3). With the per-bin abandoned maps
allocated on first abandon, step 2 allocated a map for every size class
the heap had used, from the meta-data heap and under its lock, only to
free them with the heap a moment later. A process that creates and
destroys a heap per job on several threads (bun creates one per
transpile, on a thread pool) paid that on every job, and the threads
contended on the meta lock: with 300 imports, bun used about 4 ms more
CPU than with the maps allocated up front.
The heap now records that its release has started (`heap->releasing`).
`_mi_arenas_page_abandon` leaves the pages of such a heap out of the
per-bin maps, as it already does for a full page, and a concurrent free
does not re-map them. Step 3 finds them through `pages` as before, and
`_mi_arenas_page_unabandon` already handles an unmapped page. A heap
that lives only to be released now never allocates a map, and its
`arena_pages` block holds just the `pages` bitmap.
test-abandoned-lazy counts the maps published while heaps are created,
used, destroyed and deleted on one thread (a debug-build counter, as
test-heap-teardown uses a debug hook): 0 now, 600 without this change.
It also deletes heaps on four threads while four other threads free
their blocks during the delete.
0 commit comments