microsoft / microsoft/mimalloc

Adding support for tagging individual allocs

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

Description

Hi @daanx and others!

I was wondering if anyone has ever implemented, or extended mimalloc in ways that it can support `tagging` - e.g. maybe initially just a custom provided byte, or word, dword that marks the block in a way.

Now I know this comes with few gotchas - existing new/malloc interfaces do not have this, so it has to be a threadlocal "global" (not ideal), but that would be acceptable for our use case. We can have some RAII controlled scopes pushing and popping threadlocal tags.

Then later, through a tracking API we can expose some stats and have `IMG1` tag used this amount of bytes, etc.

The nasty bit here, is that this would require reading bits from the header just before that memory block is going to be deallocated... unless some scheme to keep tags on the side.

More or less, something that mimics Microsoft's Kernel ExAllocatePoolXxx functions - https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-exallocatepool2

Just pondering on ideas, thoughts before diving in.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the existing new/malloc interfaces, allocation headers, deallocation path, and any tracking API mentioned in the issue. Decide how a thread-local tag would be assigned and retained without breaking current allocation interfaces. Done means the tagging design, metadata storage, deallocation behavior, and tracking statistics are specified and implemented with suitable validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
operating-systems
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.