microsoft / microsoft/snmalloc
Using mmap to zero memory: performance questions and CHERI incompatibility
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 2k
- Forks
- 138
- Avg merge
- 11h 19m
- Merged PRs (30d)
- 5
Description
PALPOSIX::zero uses mmap(MAP_FIXED) to map zero pages over the top as an "optimisation". However, there are two issues here:
- This requires VMEM permission on CHERI, but that's not always present here (in particular in the finish_alloc path).
- The heuristic here seems very wrong, as it's for any range that has page-aligned boundaries. For small allocations that's likely to hurt performance, having to go all the way into the kernel (maybe even IPI to shoot down the existing mappings, depending on the architecture, but at least do something to invalidate them), and once you get to the really large allocations where that is more performant does snmalloc really try and chunk them rather than just doing a raw mmap on demand? Short of data to inform whether and when it makes sense to use this optimisation I do not think it should be enabled by default.
The net result is we will likely be #if 0'ing this code out in CheriBSD.
Contributor guide
No contributing guide indexed for this repository
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.
Research direction
Start by reading PALPOSIX::zero and the finish_alloc path, focusing on the mmap(MAP_FIXED) zeroing branch and its VMEM requirement. Measure the behavior for small and large page-aligned ranges, including mapping invalidation costs, and compare it with the allocator's handling of large allocations. Done means the performance tradeoff and CHERI behavior are established well enough to decide whether this optimization should remain enabled by default.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- operating-systems, performance
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100