Porting mimalloc to Solo5

Aperta
#1,234 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
18/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
c

Direzione di ricerca

Inizia leggendo la definizione dell’intervallo di memoria di Solo5 in include/solo5.h e toolchain/cc.in, quindi confronta l’implementazione di sbrk di sysdeps_solo5.c di OCaml collegata. Le questioni aperte riguardano la gestione di stack e heap, le responsabilità della libreria standard in un ambiente freestanding e il rilevamento della piattaforma. Il lavoro sarebbe considerato completato con un design concordato e una pull request di porting corretta, ma questa issue non definisce tali decisioni.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Solo5 is a sandboxed execution environment primarily intended for, but not limited to, running applications built using various unikernels (a.k.a. library operating systems).

I have a local branch (against dev) with a (mostly) complete port, but there are a few things I'd like to discuss before making a proper PR.

  • Solo5 is a "bare" target. At a program's entry point, it provides a flat memory range in which both the call stack and the heap will live. For now I require the user to reserve memory manually using a static stack size (i.e. mi_manage_os_memory(info->heap_start, info->heap_size - STACK_SIZE, [...])) before doing any allocation, making _mi_prim_alloc always return ENOMEM. However, in OCaml's Solo5 toolchain (where they use dlmalloc), they implement a "dummy" sbrk which dynamically checks if the heap gets too close to the call stack. My opinion is that a static stack size should be fine since processes running on an ordinary OS usually also get a limited stack. It also makes the code simpler.

  • Solo5 doesn't provide a standard C library. The headers (errno.h, string.h, ...) and functions (abort, mem*, ...) mimalloc expects must be come from somewhere. I think the user (not mimalloc) should be responsible for providing such a library. For example, I'm interested in writing unikernels in Koka which requires a lot more from the standard library, and splitting a standard library between different projects depending on their particular needs doesn't make much sense to me.

  • The Solo5 toolchain's cc is just a wrapper around the host system's cc. For now I detect that we're building for Solo5 with defined(__STDC_HOSTED__) && __STDC_HOSTED__ == 0, which is set that way because of the -ffreestanding flag. This is not very robust, we have to check for Solo5 before any other platform (since cc will still define platform-specific constants for the host, like __OpenBSD__) and maybe we'll want to add other freestanding platforms in the future.

I'd be happy to read some opinions. It's fine if this isn't wanted in the main repo, I just wanted to put it out there if anyone's interested.

Lingua principale
C
Stelle
13.6k
Fork
1.2k
Merge medio
18h 12m
PR unite (30g)
20

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/mimalloc

Tutte le issue di microsoft/mimalloc

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.