Skip to content
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

Refactor - Assign SBPF versions to SIMDs #602

Merged
merged 4 commits into from
Nov 26, 2024
Merged
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
4 changes: 2 additions & 2 deletions benches/elf_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ fn loader() -> Arc<BuiltinProgram<TestContextObject>> {
}

#[bench]
fn bench_load_sbpfv1(bencher: &mut Bencher) {
let mut file = File::open("tests/elfs/syscall_reloc_64_32_sbpfv1.so").unwrap();
fn bench_load_sbpfv0(bencher: &mut Bencher) {
let mut file = File::open("tests/elfs/syscall_reloc_64_32_sbpfv0.so").unwrap();
let mut elf = Vec::new();
file.read_to_end(&mut elf).unwrap();
let loader = loader();
Expand Down
4 changes: 2 additions & 2 deletions benches/jit_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use test_utils::create_vm;

#[bench]
fn bench_init_vm(bencher: &mut Bencher) {
let mut file = File::open("tests/elfs/relative_call_sbpfv1.so").unwrap();
let mut file = File::open("tests/elfs/relative_call_sbpfv0.so").unwrap();
let mut elf = Vec::new();
file.read_to_end(&mut elf).unwrap();
let executable =
Expand All @@ -42,7 +42,7 @@ fn bench_init_vm(bencher: &mut Bencher) {
#[cfg(all(feature = "jit", not(target_os = "windows"), target_arch = "x86_64"))]
#[bench]
fn bench_jit_compile(bencher: &mut Bencher) {
let mut file = File::open("tests/elfs/relative_call_sbpfv1.so").unwrap();
let mut file = File::open("tests/elfs/relative_call_sbpfv0.so").unwrap();
let mut elf = Vec::new();
file.read_to_end(&mut elf).unwrap();
let mut executable =
Expand Down
12 changes: 6 additions & 6 deletions benches/memory_mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ macro_rules! bench_gapped_randomized_access_with_1024_entries {
)];
let config = Config::default();
let memory_mapping =
$mem::new(memory_regions, &config, SBPFVersion::V2).unwrap();
$mem::new(memory_regions, &config, SBPFVersion::V3).unwrap();
let mut prng = new_prng!();
bencher.iter(|| {
assert!(memory_mapping
Expand Down Expand Up @@ -111,7 +111,7 @@ macro_rules! bench_randomized_access_with_0001_entry {
let content = vec![0; 1024 * 2];
let memory_regions = vec![MemoryRegion::new_readonly(&content[..], 0x100000000)];
let config = Config::default();
let memory_mapping = $mem::new(memory_regions, &config, SBPFVersion::V2).unwrap();
let memory_mapping = $mem::new(memory_regions, &config, SBPFVersion::V3).unwrap();
let mut prng = new_prng!();
bencher.iter(|| {
let _ = memory_mapping.map(
Expand Down Expand Up @@ -145,7 +145,7 @@ macro_rules! bench_randomized_access_with_n_entries {
let (memory_regions, end_address) =
generate_memory_regions($n, MemoryState::Readable, Some(&mut prng));
let config = Config::default();
let memory_mapping = $mem::new(memory_regions, &config, SBPFVersion::V2).unwrap();
let memory_mapping = $mem::new(memory_regions, &config, SBPFVersion::V3).unwrap();
bencher.iter(|| {
let _ = memory_mapping.map(
AccessType::Load,
Expand Down Expand Up @@ -194,7 +194,7 @@ macro_rules! bench_randomized_mapping_with_n_entries {
let (memory_regions, _end_address) =
generate_memory_regions($n, MemoryState::Readable, Some(&mut prng));
let config = Config::default();
let memory_mapping = $mem::new(memory_regions, &config, SBPFVersion::V2).unwrap();
let memory_mapping = $mem::new(memory_regions, &config, SBPFVersion::V3).unwrap();
bencher.iter(|| {
let _ = memory_mapping.map(AccessType::Load, 0x100000000, 1);
});
Expand Down Expand Up @@ -243,7 +243,7 @@ macro_rules! bench_mapping_with_n_entries {
let (memory_regions, _end_address) =
generate_memory_regions($n, MemoryState::Readable, None);
let config = Config::default();
let memory_mapping = $mem::new(memory_regions, &config, SBPFVersion::V2).unwrap();
let memory_mapping = $mem::new(memory_regions, &config, SBPFVersion::V3).unwrap();
bencher.iter(|| {
let _ = memory_mapping.map(AccessType::Load, 0x100000000, 1);
});
Expand Down Expand Up @@ -301,7 +301,7 @@ fn do_bench_mapping_operation(bencher: &mut Bencher, op: MemoryOperation, vm_add
MemoryRegion::new_writable(&mut mem2, 0x100000000 + 8),
],
&config,
SBPFVersion::V2,
SBPFVersion::V3,
)
.unwrap();

Expand Down
18 changes: 6 additions & 12 deletions benches/vm_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use test_utils::create_vm;

#[bench]
fn bench_init_interpreter_start(bencher: &mut Bencher) {
let mut file = File::open("tests/elfs/rodata_section_sbpfv1.so").unwrap();
let mut file = File::open("tests/elfs/rodata_section_sbpfv0.so").unwrap();
let mut elf = Vec::new();
file.read_to_end(&mut elf).unwrap();
let executable =
Expand All @@ -51,7 +51,7 @@ fn bench_init_interpreter_start(bencher: &mut Bencher) {
#[cfg(all(feature = "jit", not(target_os = "windows"), target_arch = "x86_64"))]
#[bench]
fn bench_init_jit_start(bencher: &mut Bencher) {
let mut file = File::open("tests/elfs/rodata_section_sbpfv1.so").unwrap();
let mut file = File::open("tests/elfs/rodata_section_sbpfv0.so").unwrap();
let mut elf = Vec::new();
file.read_to_end(&mut elf).unwrap();
let mut executable =
Expand Down Expand Up @@ -171,7 +171,7 @@ fn bench_jit_vs_interpreter_address_translation_stack_fixed(bencher: &mut Benche
bencher,
ADDRESS_TRANSLATION_STACK_CODE,
Config {
enabled_sbpf_versions: SBPFVersion::V1..=SBPFVersion::V1,
enabled_sbpf_versions: SBPFVersion::V0..=SBPFVersion::V0,
..Config::default()
},
524289,
Expand All @@ -185,10 +185,7 @@ fn bench_jit_vs_interpreter_address_translation_stack_dynamic(bencher: &mut Benc
bench_jit_vs_interpreter(
bencher,
ADDRESS_TRANSLATION_STACK_CODE,
Config {
enabled_sbpf_versions: SBPFVersion::V1..=SBPFVersion::V2,
..Config::default()
},
Config::default(),
524289,
&mut [],
);
Expand Down Expand Up @@ -233,7 +230,7 @@ fn bench_jit_vs_interpreter_call_depth_fixed(bencher: &mut Bencher) {
call function_foo
exit",
Config {
enabled_sbpf_versions: SBPFVersion::V1..=SBPFVersion::V1,
enabled_sbpf_versions: SBPFVersion::V0..=SBPFVersion::V0,
..Config::default()
},
137218,
Expand Down Expand Up @@ -263,10 +260,7 @@ fn bench_jit_vs_interpreter_call_depth_dynamic(bencher: &mut Bencher) {
call function_foo
add r11, 4
exit",
Config {
enabled_sbpf_versions: SBPFVersion::V1..=SBPFVersion::V2,
..Config::default()
},
Config::default(),
176130,
&mut [],
);
Expand Down
Loading