Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tuning for small system? #647

Open
infn-ke opened this issue Nov 11, 2022 · 1 comment
Open

Tuning for small system? #647

infn-ke opened this issue Nov 11, 2022 · 1 comment

Comments

@infn-ke
Copy link

infn-ke commented Nov 11, 2022

Is there any tuning parameters for optimizing mimalloc for small memory footprint? In e.g. tcmalloc there is page size, alignment etc. that can be tuned. Can the free list be returned to the system by an explicit call? Is allocation done with mmap or sbrk etc.

@daanx
Copy link
Collaborator

daanx commented Nov 22, 2022

The latest dev-slice has been improved recently with regard to memory usage so try that first. What is "small" in this case (e.g. what memory footprint are you looking at? 64MiB, 1GiB ??). Also, mimalloc reduces fragmentation by relying on the MMU to commit/decommit memory inside a larger "reserved" address space so an MMU is important.

Further tweaks in mimalloc-types.h (v2, `dev-slice):

  • Reduce the page size from 64KiB:

    #define MI_SEGMENT_SLICE_SHIFT            (13 + MI_INTPTR_SHIFT) 

    to 32KiB: (which also halves the segment size and medium page size)

    #define MI_SEGMENT_SLICE_SHIFT            (12 + MI_INTPTR_SHIFT) 
  • You can also reduce the MI_MINIMAL_COMMIT_SIZE from:

    #define MI_MINIMAL_COMMIT_SIZE      (16*MI_SEGMENT_SLICE_SIZE)       

    to

    #define MI_MINIMAL_COMMIT_SIZE      (1*MI_SEGMENT_SLICE_SIZE)       
  • Set the option MIMALLOC_DECOMMIT_EXTEND=0 to allow more aggressive decommit

  • Set the option MIMALLOC_EAGER_COMMIT=0 to always commit on-demand

Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants