Skip to content

Conversation

frc4533-lincoln
Copy link

This PR adds features for switching the global allocator to mimalloc, mimalloc secure mode, or jemalloc.

As for why these two:

  • mimalloc is a highly performant allocator.
  • jemalloc is used in Firefox and Servo.

PartitionAlloc (used in Chrome) doesn't have Rust bindings, but I could write some if that'd be useful.


option('malloc',
type: 'combo',
choices: ['default', 'mimalloc', 'mimalloc_secure', 'jemalloc'],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you able to integrate this into dav1d's meson build system, too, so we can more accurately compare them? How difficult is that?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using Rust crates for mimalloc and jemalloc so I'd need to figure out how to link them.
I guess I can try

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's difficult, we can merge this in as is—it's still useful—but it'd be even nicer to be able to compare to dav1d with the same allocator.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@frc4533-lincoln, is it difficult? Should we just merge this in as is and add it to dav1d later?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@frc4533-lincoln, I can merge this, but I don't have permission to git push --force after rebasing.

@djc
Copy link
Collaborator

djc commented May 26, 2025

Given that the global allocator is usually decided by the application, and not a library, not sure if this should be eligible for the performance bounty -- this doesn't directly contribute to rav1d performance relative to dav1d. Though it will still be interesting to see what the performance difference will be like!

@frc4533-lincoln
Copy link
Author

@djc Yeah, that's fine.
Working on using an arena for the memory pool, but might be a little while figuring out how to integrate it.
Hoping to get some work done on that tomorrow.

@kkysen
Copy link
Collaborator

kkysen commented May 27, 2025

Given that the global allocator is usually decided by the application, and not a library, not sure if this should be eligible for the performance bounty -- this doesn't directly contribute to rav1d performance relative to dav1d. Though it will still be interesting to see what the performance difference will be like!

Just to let you know, we did discuss this separately beforehand and I clarified that changing the allocator wouldn't be eligible for the performance bounty, but that it could still be useful as a way to potentially uncover memory-related performance bottlenecks.

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

Successfully merging this pull request may close these issues.

3 participants