Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ raw-cpuid = "11.0.1"
strum = { version = "0.27", features = ["derive"] }
to_method = "1.1.0"
zerocopy = { version = "0.7.32", features = ["derive"] }
mimalloc = { version = "0.1.46", optional = true }

[target.'cfg(not(target_env = "msvc"))'.dependencies]
tikv-jemallocator = { version = "0.6.0", optional = true }

[build-dependencies]
cc = "1.0.79"
Expand All @@ -42,6 +46,13 @@ asm_arm64_i8mm = ["asm"]
asm_arm64_sve2 = ["asm"]
bitdepth_8 = []
bitdepth_16 = []
# Use the mimalloc memory allocator
mimalloc = ["dep:mimalloc"]
# Use the mimalloc memory allocator in secure mode
# (This has a ~10% performance penalty!)
mimalloc_secure = ["mimalloc/secure"]
# Use the jemalloc memory allocator (used in Firefox)
jemalloc = ["dep:tikv-jemallocator"]

[profile.dev]
panic = "abort"
Expand Down
3 changes: 3 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,9 @@ cargo_command = [
if get_option('buildtype') == 'release'
cargo_command += ['--release']
endif
if get_option('malloc') != 'default'
cargo_command += ['--features', get_option('malloc')]
endif

librav1d = custom_target(
'librav1d',
Expand Down
8 changes: 7 additions & 1 deletion meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,10 @@ option('test_rust_path',
option('seek_stress_test_rust_path',
type: 'string',
value: '',
description: 'Use specified Rust binary instead of building it. Path must be relative to build directory.')
description: 'Use specified Rust binary instead of building it. Path must be relative to build directory.')

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.

value: 'default',
description: 'Select memory allocator to use')
11 changes: 11 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
#![deny(unsafe_op_in_unsafe_fn)]

#[cfg(all(feature = "mimalloc", feature = "jemalloc"))]
compile_error!("You may only use one allocator at a time.");

#[cfg(feature = "mimalloc")]
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;

#[cfg(all(not(target_env = "msvc"), feature = "jemalloc"))]
#[global_allocator]
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;

#[cfg(feature = "bitdepth_16")]
use crate::include::common::bitdepth::BitDepth16;
#[cfg(feature = "bitdepth_8")]
Expand Down
Loading