Skip to content

Added support crossplatform low-level allocator mimalloc#21474

Closed
GermanAizek wants to merge 1 commit intohrydgard:masterfrom
GermanAizek:mimalloc
Closed

Added support crossplatform low-level allocator mimalloc#21474
GermanAizek wants to merge 1 commit intohrydgard:masterfrom
GermanAizek:mimalloc

Conversation

@GermanAizek
Copy link
Copy Markdown
Contributor

@GermanAizek GermanAizek commented Mar 22, 2026

@hrydgard,

My benchmarks on AMD HD 7750 2GB I'll upload tomorrow with video difference in frametime graph and Mangohud metrics.

For those who need even more performance in working with memory at the expense of RAM consumption, you can build a project with CMake parameter -Dmimalloc mimalloc allocator was originally designed as a performance-first solution.

  • Fast paths: In mimalloc, memory allocation and deallocation typically occur in the minimum number of processor cycles
  • Free list sharding: It uses segmented lists of free memory, which drastically reduces the load on the processor cache

Not my Benchmarks:

For those who need even more performance in working with memory at the expense of RAM consumption, you can build a project with CMake parameter -Dmimalloc
mimalloc allocator was originally designed as a performance-first solution.

- Fast paths: In mimalloc, memory allocation and deallocation typically occur in the minimum number of processor cycles
- Free list sharding: It uses segmented lists of free memory, which drastically reduces the load on the processor cache

Benchmarks:
- https://dustri.org/b/files/blackalps_2022.pdf
- https://forums.factorio.com/viewtopic.php?t=83875
- https://lf-hyperledger.atlassian.net/wiki/spaces/BESU/pages/22156632/Reduce+Memory+usage+by+choosing+a+different+low+level+allocator
- https://www.reddit.com/r/cpp/comments/1k30fcd/reasons_to_use_the_system_allocator_instead_of_a/
@hrydgard
Copy link
Copy Markdown
Owner

If this makes a noticable difference in performance, we need to fix that by reducing allocations made per frame, which is certainly possible. I don't really like the idea of replacing the memory allocator without understanding why our allocator usage is bad and trying to fix that first.

@fp64
Copy link
Copy Markdown
Contributor

fp64 commented Mar 26, 2026

Hmm... this doesn't replace operator new, does it?
Am I right that currently PPSSPP doesn't have a global function through which all allocations are funneled and uses a mixture of standard new/malloc?
It could be helpful (if only for logging and investigating allocator usage; even when the allocator just calls malloc() anyway).
Replacing malloc via #define seems kind of risky. Does everything include "Common.h"?
Then there's, of course, 3rd party stuff that just does its own thing.

@hrydgard
Copy link
Copy Markdown
Owner

hrydgard commented Mar 26, 2026

Well to be clear, I'm not going to merge this. It's an addition of complexity that we really don't need.

As far as I know, PPSSPP isn't bottlenecked by the memory allocator anywhere, and like I said, if it is, that's what should be fixed. We should tolerate slow allocators.

@hrydgard hrydgard closed this Mar 26, 2026
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

Successfully merging this pull request may close these issues.

3 participants