Support custom initialization hook in `mi_process_init`
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 35/100
Piste de recherche
Start by reading mi_process_init_once and the existing process initialization and OS memory management paths in mimalloc. The issue proposes a compile-time hook but leaves its placement and interaction with memory allocation options open, so first evaluate those constraints and discuss the design with maintainers. Done would mean an agreed hook design with a working example and tests showing initialization can use a caller-provided pool without fetching additional OS memory.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
This question is similar to #1218 and #1228 (thank you for the fixes!!) in that we want to preallocate a fixed pool for mimalloc to use (and never ask the OS for more). Since our process can potentially malloc() before main (dynamic libs, etc) we need to set up our pool when that first allocation happens. It looks like the right place to do this would be towards the end of mi_process_init_once instead of fetching OS memory.
Since application code doesn't call mi_process_init directly, I think this would have to be a compile/link time thing, something like
static void mi_process_init_once(void) {
...
#ifdef MI_PROCESS_INIT_HOOK
extern void MI_PROCESS_INIT_HOOK(void);
MI_PROCESS_INIT_HOOK();
#endif
}
We compile the mimalloc staticlib with MI_PROCESS_INIT_HOOK=our_pool_setup and link it to the real function that mmap()s the pool, calls mi_manage_os_memory_ex(), and mi_option_set(). (Maybe the hook goes before the function tries to fetch OS memory?)
Is mimalloc open to upstreaming an idea like this? I can submit a PR once we have it working but I wanted to see if there's any alternative I'm missing or reasons that this wouldn't work.
- Langage dominant
- C
- Étoiles
- 13.6k
- Forks
- 1.2k
- Merge moyen
- 18 h 12 min
- PR mergées (30 j)
- 20
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de microsoft/mimalloc
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
Building mimalloc with `-Wundef` compiler flag logs many warnings on undefined macrosPeut-être pris @vstinner l’a pris il y a 1 jour. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 64/100
microsoft/mimalloc#1506 · 5 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
stale
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
microsoft/mimalloc#1113 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
microsoft/mimalloc#886 · 4 commentaires · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 64/100
microsoft/mimalloc#368 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de microsoft/mimalloc
Issues similaires
-
needs triage
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
389ds/389-ds-base#8157 ·
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 67/100
coolsnowwolf/lede#14305 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour
-
Needs-Triage
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
Les mainteneurs répondent en général sous 2 jours