/// Test the second execution of the sigsegv handler for a memory address.
///
/// This is when a page previously mapped readonly is remapped as writeable.
Test the second execution of the sigsegv handler for a memory address.
This is when a page previously mapped readonly is remapped as writeable.
Test the second execution of the sigsegv handler for a memory address . This is when a page previously mapped readonly is remapped as writeable .
fn criterion_fault_handler_sim_write(criterion: &mut Criterion) {
    let mut group = criterion.benchmark_group("fault_handler");
    let ptr: *mut c_void = unsafe {
        mmap(
            ptr::null_mut(),
            PAGE_SIZE,
            ProtFlags::PROT_NONE,
            MapFlags::MAP_ANON | MapFlags::MAP_PRIVATE,
            0,
            0,
        )
        .unwrap()
    };
    group.bench_function("fault handler sim write", |bench| {
        bench.iter_with_setup(
            // Setup input data for measurement
            || {
                let page_map = PageMap::new();
                let data = BenchData {
                    ptr,
                    tracker: SigsegvMemoryTracker::new(
                        PersistenceType::Sigsegv,
                        ptr,
                        PAGE_SIZE,
                        no_op_logger(),
                        DirtyPageTracking::Track,
                        Some(page_map.clone()),
                    )
                    .unwrap(),
                    page_map: Some(page_map),
                };
                sigsegv_fault_handler_old(&data.tracker, &data.page_map, data.ptr);
                data
            },
            // Do the actual measurement
            |data| {
                sigsegv_fault_handler_old(
                    black_box(&data.tracker),
                    &data.page_map,
                    black_box(data.ptr),
                )
            },
        )
    });
}
fn criterion_fault_handler_sim_write ( criterion : & mut Criterion ) { let mut group = criterion . benchmark_group ( " " ) ; let ptr : * mut c_void = unsafe { mmap ( ptr :: null_mut ( ) , PAGE_SIZE , ProtFlags :: PROT_NONE , MapFlags :: MAP_ANON | MapFlags :: MAP_PRIVATE , 0 , 0 , ) . unwrap ( ) } ; group . bench_function ( " " , | bench | { bench . iter_with_setup ( // Setup input data for measurement | | { let page_map = PageMap :: new ( ) ; let data = BenchData { ptr , tracker : SigsegvMemoryTracker :: new ( PersistenceType :: Sigsegv , ptr , PAGE_SIZE , no_op_logger ( ) , DirtyPageTracking :: Track , Some ( page_map . clone ( ) ) , ) . unwrap ( ) , page_map : Some ( page_map ) , } ; sigsegv_fault_handler_old ( & data . tracker , & data . page_map , data . ptr ) ; data } , // Do the actual measurement | data | { sigsegv_fault_handler_old ( black_box ( & data . tracker ) , & data . page_map , black_box ( data . ptr ) , ) } , ) } ) ; }
Test the second execution of the sigsegv handler for a memory address.
Test the second execution of the sigsegv handler for a memory address .
criterion
&mut Criterion