python / python/cpython

Inc GC in 3.14t can defer too much, resulting in high memory use

Abierto
#148,937 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

interpreter-core performance topic-free-threading type-bug
Lenguaje dominante
Python
Estrellas
77.2k
Forks
35.9k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

Bug report

Bug description:

In the process of testing the default build incremental GC, I noticed a problem with the 3.14t GC. Shortly before the 3.14.0 release, I added some additional logic to defer GC triggering if the process memory use has not increased by 10% since the last collection. Unfortunately that does not work well with how mimalloc handles memory. It does not promptly return memory to the OS or mark pages as unused (e.g. with madvise). So, the process size from the point of view of the OS does not decrease after the GC frees cyclic trash.

For programs that create even modest amounts of cyclic garbage, this is a major problem. It acts as if the GC threshold has been set to 40x the "threshold0" value. By default, that means full GC collection every 80,000 net new objects. This is not a continuous memory leak but it means the process uses uses way more memory than it should.

The simple fix would be to just remove that process size based defer. However, that would result in regressing on the GH-132917 issue, so I wouldn't recommend that. I have a fairly simple fix that "asks mimalloc" how much memory is being used, rather than asking the OS. Based on my testing, that works well.

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Linked PRs
  • gh-148940
  • gh-149371
  • gh-149475

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza revisando los PRs enlazados gh-148940, gh-149371 y gh-149475; después, sigue el aplazamiento basado en el tamaño del proceso del GC incremental de 3.14 en Linux. Compara su comprobación del uso de memoria con el uso informado por mimalloc y verifica que se recolecte la basura cíclica sin el crecimiento excesivo de memoria descrito en el informe.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
performance
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.