Porting mimalloc to Solo5
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 18/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- c
- Domain
- operating-systems
Research direction
Start by reading Solo5's include/solo5.h memory-range definition and toolchain/cc.in, then compare the linked OCaml sysdeps_solo5.c sbrk implementation. The open questions are stack and heap management, freestanding standard-library responsibilities, and platform detection. Done would be an agreed design and a proper porting pull request, but this issue does not define those decisions.
Written by the indexing model from the issue text.
Description
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_allocalways returnENOMEM. However, in OCaml's Solo5 toolchain (where they usedlmalloc), they implement a "dummy"sbrkwhich 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
ccis just a wrapper around the host system'scc. For now I detect that we're building for Solo5 withdefined(__STDC_HOSTED__) && __STDC_HOSTED__ == 0, which is set that way because of the-ffreestandingflag. This is not very robust, we have to check for Solo5 before any other platform (sinceccwill 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.
- Dominant language
- C
- Stars
- 13.6k
- Forks
- 1.2k
- Avg merge
- 18h 12m
- Merged PRs (30d)
- 20
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/mimalloc
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Building mimalloc with `-Wundef` compiler flag logs many warnings on undefined macrosPossibly taken @vstinner claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
microsoft/mimalloc#1506 · 5 comments ·
Maintainers usually reply within 1 day
-
stale
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
microsoft/mimalloc#1113 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
microsoft/mimalloc#886 · 4 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
microsoft/mimalloc#368 · 1 comment ·
Maintainers usually reply within 1 day
All issues in microsoft/mimalloc
Similar issues
-
needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
389ds/389-ds-base#8157 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
coolsnowwolf/lede#14305 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Needs-Triage
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 2 days