bedevere-app · GitHub

Open

@nascheme

sergey-miryanov

@nascheme

colesbury

Asking the OS for the process memory usage doesn't work will given how
mimalloc works.  It does not promptly return memory to the OS and so the
memory doesn't drop after cyclic trash is freed.
Instead of asking the OS, use mimalloc APIs to compute how much memory
is being used by all mimalloc arenas.  We need to stop-the-world to do
this but usually we can avoid doing a collection.  So, from a
performance perspective, this is worth it.
It's probably better to call this inside of gc_collect_main().  That
way, we are not doing the STW from inside _PyObject_GC_Link() function.
This should have no significant performance impact since we hit this
only after the young object count hits the threshold.
This avoids using STW in exchange for less accurate memory usage
estimates.
Should should avoid memory contention.  Avoid casting *intptr_t
to *Py_ssize_t.  Include large and huge pages in count (promote
eagerly to MI_BIN_FULL).  Add comment noting about abandoned
pages potentially being lost (their byte count never being
subtracted).

@nascheme

@nascheme

Read the original on github.com ↗