microsoft / microsoft/mimalloc

Use mremap and PMD_SIZE granularity

Open
#614 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
C
Stars
13.4k
Forks
1.2k
Avg merge
4d 45m
Merged PRs (30d)
13

Description

I guess you could use mremap() on Linux for faster realloc of large blocks, since most of the process would be done by the kernel, playing with the TLB pointers, and no memmove() is actually done.

Also using PMD_SIZE = 2 MB of granularity helps a lot mremap() work.
(you may try with PUD-aligned over 1GB blocks also for really big blocks)
See https://lwn.net/Articles/833208

This is what we do for our own memory manager (written mostly in x86_64 assembly), with noticeable performance gains.
See https://github.com/synopse/mORMot2/blob/master/src/core/mormot.core.fpcx64mm.pas as reference.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading the linked LWN article and the referenced mORMot2 memory-manager implementation, then inspect mimalloc's large-block allocation paths for where Linux-specific remapping could fit. Compare behavior and performance for PMD_SIZE and PUD-aligned blocks; done requires a defined, tested improvement without regressing other platforms.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, linux
Domain
operating-systems, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.