History

Let commitgraph fuzzer use the latest API

This increases performance by 4x while reducing kernel load to not being present at all, down from 90%/nearly 1 CPU.

Sebastian Thiel committed 2 years ago

Commit 672294e1 parent 8613c412 files · +7 −7Browse files

Showing the changes to gix-commitgraph (2 of 2 files). Show all

Unified · Split

2 files
  1. gix-commitgraph/fuzz/Cargo.toml +1 −1
  2. gix-commitgraph/fuzz/fuzz_targets/fuzz_file.rs +6 −6
gix-commitgraph/fuzz/Cargo.toml+1−1
@@ -11,7 +11,7 @@ cargo-fuzz = true · 10 unmodified lines
11anyhow = "1.0.76"11anyhow = "1.0.76"
12arbitrary = { version = "1.3.2", features = ["derive"] }12arbitrary = { version = "1.3.2", features = ["derive"] }
13libfuzzer-sys = "0.4"13libfuzzer-sys = "0.4"
14tempfile = "3.8.1"14memmap2 = "0.9.0"
15 15
16[dependencies.gix-commitgraph]16[dependencies.gix-commitgraph]
17path = ".."17path = ".."
gix-commitgraph/fuzz/fuzz_targets/fuzz_file.rs+6−6
@@ -1,17 +1,17 @@
1#![no_main]1#![no_main]
2 2
3use anyhow::Result;3use anyhow::Result;
4use arbitrary::Arbitrary;
5use gix_commitgraph::File;4use gix_commitgraph::File;
6use libfuzzer_sys::fuzz_target;5use libfuzzer_sys::fuzz_target;
7use std::fs;
8use std::hint::black_box;6use std::hint::black_box;
9use tempfile::NamedTempFile;
10 7
11fn fuzz(data: &[u8]) -> Result<()> {8fn fuzz(data: &[u8]) -> Result<()> {
12 let named_temp_file = NamedTempFile::new()?;9 let data = {
13 fs::write(named_temp_file.path(), data).expect("Unable to write fuzzed file");10 let mut d = memmap2::MmapMut::map_anon(data.len())?;
14 let file = File::try_from(named_temp_file.path())?;11 d.copy_from_slice(data);
12 d.make_read_only()?
13 };
14 let file = File::new(data, "does not matter".into())?;
15 15
16 _ = black_box(file.iter_base_graph_ids().count());16 _ = black_box(file.iter_base_graph_ids().count());
17 _ = black_box(file.iter_commits().count());17 _ = black_box(file.iter_commits().count());