Skip to content

Refactor bulk metadata visiting #1180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
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
160 changes: 160 additions & 0 deletions benches/bulk_meta/bzero.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
use criterion::Criterion;
use mmtk::util::{
constants::{BITS_IN_BYTE, BYTES_IN_WORD},
metadata::side_metadata::{grain::AddressToBitAddress, SideMetadataSpec},
Address,
};

pub fn bench(c: &mut Criterion) {
let data_bytes = 256usize; // Match an Immix line size.
let meta_bits = data_bytes / BYTES_IN_WORD;
let meta_bytes = meta_bits / BITS_IN_BYTE;

let allocate_u32 = || -> Address {
let ptr = unsafe {
std::alloc::alloc_zeroed(std::alloc::Layout::from_size_align(meta_bytes, 8).unwrap())
};
Address::from_mut_ptr(ptr)
};

let start = allocate_u32();
let end = start + meta_bytes;
let start_ba = start.with_bit_offset(0);
let end_ba = end.with_bit_offset(0);

c.bench_function("bzero_bset_modern_64", |b| {
b.iter(|| {
SideMetadataSpec::set_meta_bits_modern_inner::<u64, false, false, false>(
start_ba, end_ba,
);
SideMetadataSpec::zero_meta_bits_modern_inner::<u64, false, false, false>(
start_ba, end_ba,
);
})
});

c.bench_function("bzero_bset_modern_64_callback", |b| {
b.iter(|| {
SideMetadataSpec::set_meta_bits_modern_inner::<u64, true, false, false>(
start_ba, end_ba,
);
SideMetadataSpec::zero_meta_bits_modern_inner::<u64, true, false, false>(
start_ba, end_ba,
);
})
});

c.bench_function("bzero_bset_modern_64_callback_normalize", |b| {
b.iter(|| {
SideMetadataSpec::set_meta_bits_modern_inner::<u64, true, true, false>(
start_ba, end_ba,
);
SideMetadataSpec::zero_meta_bits_modern_inner::<u64, true, true, false>(
start_ba, end_ba,
);
})
});

c.bench_function("bzero_bset_modern_64_callback_normalize_fastpath", |b| {
b.iter(|| {
SideMetadataSpec::set_meta_bits_modern_inner::<u64, true, true, true>(start_ba, end_ba);
SideMetadataSpec::zero_meta_bits_modern_inner::<u64, true, true, true>(
start_ba, end_ba,
);
})
});

c.bench_function("bzero_bset_modern_32", |b| {
b.iter(|| {
SideMetadataSpec::set_meta_bits_modern_inner::<u32, false, false, false>(
start_ba, end_ba,
);
SideMetadataSpec::zero_meta_bits_modern_inner::<u32, false, false, false>(
start_ba, end_ba,
);
})
});

c.bench_function("bzero_bset_modern_32_callback", |b| {
b.iter(|| {
SideMetadataSpec::set_meta_bits_modern_inner::<u32, true, false, false>(
start_ba, end_ba,
);
SideMetadataSpec::zero_meta_bits_modern_inner::<u32, true, false, false>(
start_ba, end_ba,
);
})
});

c.bench_function("bzero_bset_modern_32_callback_normalize", |b| {
b.iter(|| {
SideMetadataSpec::set_meta_bits_modern_inner::<u32, true, true, false>(
start_ba, end_ba,
);
SideMetadataSpec::zero_meta_bits_modern_inner::<u32, true, true, false>(
start_ba, end_ba,
);
})
});

c.bench_function("bzero_bset_modern_32_callback_normalize_fastpath", |b| {
b.iter(|| {
SideMetadataSpec::set_meta_bits_modern_inner::<u32, true, true, true>(start_ba, end_ba);
SideMetadataSpec::zero_meta_bits_modern_inner::<u32, true, true, true>(
start_ba, end_ba,
);
})
});

c.bench_function("bzero_bset_modern_8", |b| {
b.iter(|| {
SideMetadataSpec::set_meta_bits_modern_inner::<u8, false, false, false>(
start_ba, end_ba,
);
SideMetadataSpec::zero_meta_bits_modern_inner::<u8, false, false, false>(
start_ba, end_ba,
);
})
});

c.bench_function("bzero_bset_modern_8_callback", |b| {
b.iter(|| {
SideMetadataSpec::set_meta_bits_modern_inner::<u8, true, false, false>(
start_ba, end_ba,
);
SideMetadataSpec::zero_meta_bits_modern_inner::<u8, true, false, false>(
start_ba, end_ba,
);
})
});

c.bench_function("bzero_bset_modern_8_callback_normalize", |b| {
b.iter(|| {
SideMetadataSpec::set_meta_bits_modern_inner::<u8, true, true, false>(start_ba, end_ba);
SideMetadataSpec::zero_meta_bits_modern_inner::<u8, true, true, false>(
start_ba, end_ba,
);
})
});

c.bench_function("bzero_bset_modern_8_callback_normalize_fastpath", |b| {
b.iter(|| {
SideMetadataSpec::set_meta_bits_modern_inner::<u8, true, true, true>(start_ba, end_ba);
SideMetadataSpec::zero_meta_bits_modern_inner::<u8, true, true, true>(start_ba, end_ba);
})
});

c.bench_function("bzero_bset_classic", |b| {
b.iter(|| {
SideMetadataSpec::set_meta_bits_classic::<false>(start, 0, end, 0);
SideMetadataSpec::zero_meta_bits_classic::<false>(start, 0, end, 0);
})
});

c.bench_function("bzero_bset_classic_fast", |b| {
b.iter(|| {
SideMetadataSpec::set_meta_bits_classic::<true>(start, 0, end, 0);
SideMetadataSpec::zero_meta_bits_classic::<true>(start, 0, end, 0);
})
});
}
1 change: 1 addition & 0 deletions benches/bulk_meta/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod bzero;
14 changes: 9 additions & 5 deletions benches/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ use criterion::Criterion;
// However, I will just keep these benchmarks here. If we find it not useful, and we do not plan to improve MockVM, we can delete
// them.

mod bulk_meta;

#[cfg(feature = "mock_test")]
mod mock_bench;

Expand All @@ -29,15 +31,17 @@ pub fn bench_main(_c: &mut Criterion) {
"alloc" => mock_bench::alloc::bench(_c),
"internal_pointer" => mock_bench::internal_pointer::bench(_c),
"sft" => mock_bench::sft::bench(_c),
_ => panic!("Unknown benchmark {:?}", bench),
_ => {} // Fall back to non-mock test.
},
Err(_) => panic!("Need to name a benchmark by the env var MMTK_BENCH"),
}

#[cfg(not(feature = "mock_test"))]
{
eprintln!("ERROR: Currently there are no benchmarks when the \"mock_test\" feature is not enabled.");
std::process::exit(1);
match std::env::var("MMTK_BENCH") {
Ok(bench) => match bench.as_str() {
"bzero" => bulk_meta::bzero::bench(_c),
_ => panic!("Unknown benchmark {:?}", bench),
},
Err(_) => panic!("Need to name a benchmark by the env var MMTK_BENCH"),
}
}

Expand Down
Loading
Loading