microsoft / microsoft/mimalloc

Is it possible to remove the limit on MI_ALIGNMENT_MAX?

Open
#628 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
13.4k
Forks
1.2k
Avg merge
4d 45m
Merged PRs (30d)
13

Description

I'm having some problems with the restriction on max alignment size MI_ALIGNMENT_MAX in mimalloc v1.7.6. I know that this restriction is to reduce memory waste, but in our project we use memalign with alignment set to 4MiB and size set to 4MiB, which helps we get our object header fast by masking bits, just like what mimalloc does with segments. I have read this issue #576 and I know that dev-slice branch is expanding this limit to 16MiB. Still I'm wondering could we just remove this limit, and do any alignment allocation regardless of however big the alignment is? This might be a potential requirement in our project. If it is possible, what change should I do to mimalloc code? I notice that aside from the macro defined in mimalloc.h, there is also a preprocessor error in mimalloc-types.h which limit MI_ALIGNMENT_MAX to be no more than half of MI_SEGMENT_SIZE.

https://github.com/microsoft/mimalloc/blob/8d6a9df7521181afc276d94b3a6ef2a9dd60bd06/include/mimalloc-types.h#L163-L165

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the MI_ALIGNMENT_MAX definitions and validation in include/mimalloc.h and include/mimalloc-types.h, then read issue #576 and compare the dev-slice branch's expanded limit. Determine whether arbitrary alignment is compatible with the allocator's constraints; done means a supported design or a clear explanation of why the limit must remain.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
operating-systems, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.