Negative current commited stat with purge_delay=0

Offen
#1,141 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
c

Rechercherichtung

Beginne damit, den minimalen C-Reproducer mit mi_option_purge_decommits, mi_option_purge_delay, mi_collect und mi_stats_get auszuführen, und vergleiche dann den gemeldeten Wert committed.current mit den ausgegebenen Mappings. Sieh dir die bestehende Diskussion in den Duplikat-Issues #929 und #1118 an; abgeschlossen ist die Aufgabe, wenn die committed-Statistik nicht mehr negativ wird oder ihre dokumentierte Bedeutung das Ergebnis erklärt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Duplicate of #929 #1118, but I want to bump this issue up so it gains more attention. With mi_option_purge_decommits=1 and mi_option_purge_delay=0, the current commited stat becomes negative after calling mi_collect. I first assumed that this is the current amount of memory that is not yet decommited (relative to total), but it doesn't add up. So its either a bug or an undocumented feature.

Running with latest master:

#include <stdio.h>
#include <mimalloc.h>
#include <mimalloc-stats.h>

int main() {
  const int num_elements = 1000;
  void* ptrs[num_elements];

  mi_process_init();
  mi_option_set(mi_option_purge_decommits, 1);
  mi_option_set(mi_option_purge_delay, 0);
  mi_option_set(mi_option_arena_reserve, 1024000); // 1GB

  for (int i = 0; i < num_elements; i++) {
    ptrs[i] = mi_malloc(50000);
  }
  for (int i = 0; i < num_elements; i++) {
    mi_free(ptrs[i]);
  }


  mi_collect(true);

  mi_stats_t stats;
  mi_stats_get(sizeof(stats), &stats);
  printf("%d mb", stats.committed.current / 1024 / 1024);
  mi_stats_print_out(NULL, NULL);
}
[100%] Built target test
heap stats:     peak       total     current       block      total#   
  reserved:     1.0 GiB     1.0 GiB     1.0 GiB                          
 committed:     1.0 GiB     1.0 GiB  -906.8 MiB                          
     reset:     0      
    purged:     1.8 GiB
   touched:   192.7 KiB   192.7 KiB   -54.6 MiB                          
  segments:     3           3           1                                not all freed
-abandoned:     0           0           0                                ok
   -cached:     0           0           0                                ok
     pages:     0           0        -121                                not all freed
-abandoned:     0           0           0                                ok
 -extended:     0      
   -retire:     0      
    arenas:     1      
 -rollback:     0      
     mmaps:     1      
   commits:     0      
    resets:     0      
    purges:   123      
   guarded:     0      
   threads:     0           0           0                                ok
  searches:     0.0 avg
numa nodes:     1
   elapsed:     0.009 s
   process: user: 0.000 s, system: 0.009 s, faults: 0, rss: 63.5 MiB, commit: 1.0 GiB
-906 mb%
pmap -x 77734 | grep -e "total \| RSS"  
Address           Kbytes     RSS   Dirty Mode  Mapping
total kB         1051248    1868     220
Vorherrschende Sprache
C
Sterne
13.6k
Forks
1.2k
Ø Merge
18 Std. 12 Min.
Gemergte PRs (30 T.)
20

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus microsoft/mimalloc

Alle Issues in microsoft/mimalloc

Ähnliche Issues

Weitere Issues zu C

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.