Skip to content

Commit

Permalink
Add reuse bench
Browse files Browse the repository at this point in the history
  • Loading branch information
EVaillant committed Feb 27, 2024
1 parent b774e6d commit 3e85eb7
Show file tree
Hide file tree
Showing 940 changed files with 59,502 additions and 159,370 deletions.
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"rust-analyzer.checkOnSave.command": "clippy",
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer",
"editor.formatOnSave": true
}
}
104 changes: 103 additions & 1 deletion benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,108 @@ fn bench_free(c: &mut Criterion) {
group.finish();
}

fn bench_reuse(c: &mut Criterion) {
const VEC_SIZE: usize = 16384;
const BATCH_SIZE: usize = 8192;

let mut group = c.benchmark_group("reuse");
group.bench_function("none object poll", |b| {
b.iter_batched(
|| {
(
lockfree_object_pool::NoneObjectPool::new(|| {
Vec::<u8>::with_capacity(16 * 1024)
}),
Vec::with_capacity(VEC_SIZE),
)
},
|(pool, mut vec)| {
for index in 0..BATCH_SIZE {
vec.insert(index, criterion::black_box(pool.pull()));
}
},
criterion::BatchSize::SmallInput,
);
});

group.bench_function("mutex object poll", |b| {
b.iter_batched(
|| {
let pool = lockfree_object_pool::MutexObjectPool::<Vec<u8>>::new(
|| Vec::with_capacity(16 * 1024),
|_v| {},
);
let v: Vec<_> = (0..VEC_SIZE).map(|_| pool.pull()).collect();
drop(v);
(pool, Vec::with_capacity(VEC_SIZE))
},
|(pool, mut vec)| {
for index in 0..BATCH_SIZE {
vec.insert(index, criterion::black_box(pool.pull()));
}
},
criterion::BatchSize::SmallInput,
);
});

group.bench_function("spin_lock object poll", |b| {
b.iter_batched(
|| {
let pool = lockfree_object_pool::SpinLockObjectPool::<Vec<u8>>::new(
|| Vec::with_capacity(16 * 1024),
|_v| {},
);
let v: Vec<_> = (0..VEC_SIZE).map(|_| pool.pull()).collect();
drop(v);
(pool, Vec::with_capacity(VEC_SIZE))
},
|(pool, mut vec)| {
for index in 0..BATCH_SIZE {
vec.insert(index, criterion::black_box(pool.pull()));
}
},
criterion::BatchSize::SmallInput,
);
});

group.bench_function("linear object poll", |b| {
b.iter_batched(
|| {
let pool = lockfree_object_pool::LinearObjectPool::new(
|| Vec::<u8>::with_capacity(16 * 1024),
|_v| {},
);
let v: Vec<_> = (0..VEC_SIZE).map(|_| pool.pull()).collect();
drop(v);
(pool, Vec::with_capacity(VEC_SIZE))
},
|(pool, mut vec)| {
for index in 0..BATCH_SIZE {
vec.insert(index, criterion::black_box(pool.pull()));
}
},
criterion::BatchSize::SmallInput,
);
});

group.bench_function("crate 'object-pool'", |b| {
b.iter_batched(
|| {
let pool = object_pool::Pool::new(VEC_SIZE, || Vec::<u8>::with_capacity(16 * 1024));
let v: Vec<_> = (0..VEC_SIZE).map(|_| pool.try_pull().unwrap()).collect();
drop(v);
(pool, Vec::with_capacity(VEC_SIZE))
},
|(pool, mut vec)| {
for index in 0..BATCH_SIZE {
vec.insert(index, criterion::black_box(pool.try_pull().unwrap()));
}
},
criterion::BatchSize::SmallInput,
);
});
}

fn bench_alloc_mt(c: &mut Criterion) {
let mut group = c.benchmark_group("multi thread allocation");
bench_alloc_mt_impl_!(
Expand Down Expand Up @@ -305,5 +407,5 @@ criterion_group!(
bench_forward_multi_thread11
);
criterion_group!(multi_thread, bench_alloc_mt, bench_free_mt);
criterion_group!(mono_thread, bench_alloc, bench_free);
criterion_group!(mono_thread, bench_alloc, bench_free, bench_reuse);
criterion_main!(mono_thread, multi_thread, forward_multi_thread);
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"mean":{"confidence_interval":{"confidence_level":0.95,"lower_bound":692.3373410038585,"upper_bound":854.9035414178314},"point_estimate":775.3326748371961,"standard_error":41.54300906479159},"median":{"confidence_interval":{"confidence_level":0.95,"lower_bound":924.0113663133097,"upper_bound":1038.2073735637205},"point_estimate":998.0270538869258,"standard_error":30.922850874423546},"median_abs_dev":{"confidence_interval":{"confidence_level":0.95,"lower_bound":115.38833741476797,"upper_bound":269.3120755942236},"point_estimate":174.14122488282922,"standard_error":41.12497073058249},"slope":{"confidence_interval":{"confidence_level":0.95,"lower_bound":1034.6949154067327,"upper_bound":1072.5352631227072},"point_estimate":1056.3635247858945,"standard_error":9.665908874615987},"std_dev":{"confidence_interval":{"confidence_level":0.95,"lower_bound":368.07609550423166,"upper_bound":449.8780643339072},"point_estimate":417.0844221593338,"standard_error":20.981885319481645}}
{"mean":{"confidence_interval":{"confidence_level":0.95,"lower_bound":40.25971762693777,"upper_bound":41.63588746031105},"point_estimate":40.88144999777207,"standard_error":0.3540448191593488},"median":{"confidence_interval":{"confidence_level":0.95,"lower_bound":40.17273395844824,"upper_bound":40.75245742637047},"point_estimate":40.46929668961862,"standard_error":0.14343907424406363},"median_abs_dev":{"confidence_interval":{"confidence_level":0.95,"lower_bound":1.0086008314370745,"upper_bound":2.8610553424118184},"point_estimate":2.145206741241782,"standard_error":0.5175814216784274},"slope":{"confidence_interval":{"confidence_level":0.95,"lower_bound":41.18262952854391,"upper_bound":41.833196313253836},"point_estimate":41.52563954758871,"standard_error":0.16654893211587216},"std_dev":{"confidence_interval":{"confidence_level":0.95,"lower_bound":1.9216492632511177,"upper_bound":5.115461025371509},"point_estimate":3.5612974992500113,"standard_error":0.8510374523148664}}
101 changes: 0 additions & 101 deletions benches/criterion/allocation/crate 'object-pool'/base/raw.csv

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"sampling_mode":"Linear","iters":[849.0,1698.0,2547.0,3396.0,4245.0,5094.0,5943.0,6792.0,7641.0,8490.0,9339.0,10188.0,11037.0,11886.0,12735.0,13584.0,14433.0,15282.0,16131.0,16980.0,17829.0,18678.0,19527.0,20376.0,21225.0,22074.0,22923.0,23772.0,24621.0,25470.0,26319.0,27168.0,28017.0,28866.0,29715.0,30564.0,31413.0,32262.0,33111.0,33960.0,34809.0,35658.0,36507.0,37356.0,38205.0,39054.0,39903.0,40752.0,41601.0,42450.0,43299.0,44148.0,44997.0,45846.0,46695.0,47544.0,48393.0,49242.0,50091.0,50940.0,51789.0,52638.0,53487.0,54336.0,55185.0,56034.0,56883.0,57732.0,58581.0,59430.0,60279.0,61128.0,61977.0,62826.0,63675.0,64524.0,65373.0,66222.0,67071.0,67920.0,68769.0,69618.0,70467.0,71316.0,72165.0,73014.0,73863.0,74712.0,75561.0,76410.0,77259.0,78108.0,78957.0,79806.0,80655.0,81504.0,82353.0,83202.0,84051.0,84900.0],"times":[89972.0,139640.0,207113.0,274360.0,348218.0,409189.0,473151.0,538822.0,604953.0,688404.0,745785.0,810486.0,1614290.0,1980184.0,1934314.0,1938040.0,1983022.0,2030923.0,2222036.0,2248844.0,2172710.0,2276754.0,2280963.0,2413596.0,2363229.0,2376689.0,2438919.0,17718800.0,18791883.0,19844471.0,20966300.0,22089088.0,23155606.0,24244697.0,25331688.0,26426786.0,27527811.0,28687376.0,30046383.0,31379426.0,32108218.0,33105317.0,34248917.0,35356253.0,36461893.0,37486581.0,39381168.0,40747149.0,41091590.0,41954704.0,43133301.0,44294855.0,45795969.0,46514942.0,47368324.0,48554928.0,49665422.0,50828642.0,51817645.0,52865134.0,53961268.0,55407031.0,56679540.0,57683954.0,58588759.0,59644568.0,60697584.0,61806181.0,62910886.0,64075335.0,65061635.0,65996832.0,67092375.0,68014130.0,69307661.0,70195862.0,71524376.0,73508515.0,73974835.0,74693045.0,75842592.0,76776765.0,77884329.0,78971607.0,80480851.0,81030769.0,82140865.0,83753434.0,84305943.0,85507446.0,86760415.0,87334246.0,88511777.0,89523942.0,90691512.0,91691951.0,92969757.0,93868065.0,94819340.0,96121534.0]}
{"sampling_mode":"Linear","iters":[1554.0,3108.0,4662.0,6216.0,7770.0,9324.0,10878.0,12432.0,13986.0,15540.0,17094.0,18648.0,20202.0,21756.0,23310.0,24864.0,26418.0,27972.0,29526.0,31080.0,32634.0,34188.0,35742.0,37296.0,38850.0,40404.0,41958.0,43512.0,45066.0,46620.0,48174.0,49728.0,51282.0,52836.0,54390.0,55944.0,57498.0,59052.0,60606.0,62160.0,63714.0,65268.0,66822.0,68376.0,69930.0,71484.0,73038.0,74592.0,76146.0,77700.0,79254.0,80808.0,82362.0,83916.0,85470.0,87024.0,88578.0,90132.0,91686.0,93240.0,94794.0,96348.0,97902.0,99456.0,101010.0,102564.0,104118.0,105672.0,107226.0,108780.0,110334.0,111888.0,113442.0,114996.0,116550.0,118104.0,119658.0,121212.0,122766.0,124320.0,125874.0,127428.0,128982.0,130536.0,132090.0,133644.0,135198.0,136752.0,138306.0,139860.0,141414.0,142968.0,144522.0,146076.0,147630.0,149184.0,150738.0,152292.0,153846.0,155400.0],"times":[78626.0,127464.0,186479.0,237065.0,291009.0,369881.0,413725.0,468532.0,526076.0,581457.0,700951.0,716215.0,767436.0,828777.0,970076.0,966128.0,1000292.0,1049289.0,1105731.0,1156541.0,1216885.0,1338874.0,1507679.0,1886558.0,2113018.0,2617952.0,1883909.0,1740712.0,1747701.0,1778257.0,1847946.0,1906393.0,1974808.0,2035706.0,2099652.0,2169630.0,2219956.0,2275455.0,2359073.0,2416766.0,2488318.0,2544816.0,2738146.0,2783680.0,2821235.0,2866492.0,2919930.0,3012930.0,3058993.0,3152463.0,3163480.0,3265861.0,3320530.0,3362903.0,3441662.0,3533713.0,3566617.0,3571666.0,3720983.0,3767288.0,3817249.0,3934073.0,3962832.0,4035425.0,4118719.0,4163798.0,4225895.0,4219916.0,4369723.0,4436737.0,4464230.0,4566883.0,4659787.0,4592241.0,4797673.0,4839716.0,4865431.0,5001927.0,5088551.0,5102827.0,5218624.0,5234993.0,5292178.0,5392574.0,5712226.0,5740964.0,5838830.0,5851470.0,5895448.0,5944712.0,6060078.0,6111214.0,6198698.0,6227587.0,6308832.0,6363119.0,6442302.0,6526749.0,6585609.0,6668964.0]}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[-2662.1962582557235,-1255.8568226134105,2494.381672432758,3900.7211080750712]
[31.459121679804326,35.1665339737503,45.05296675760622,48.76037905155219]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"mean":{"confidence_interval":{"confidence_level":0.95,"lower_bound":692.3373410038585,"upper_bound":854.9035414178314},"point_estimate":775.3326748371961,"standard_error":41.54300906479159},"median":{"confidence_interval":{"confidence_level":0.95,"lower_bound":924.0113663133097,"upper_bound":1038.2073735637205},"point_estimate":998.0270538869258,"standard_error":30.922850874423546},"median_abs_dev":{"confidence_interval":{"confidence_level":0.95,"lower_bound":115.38833741476797,"upper_bound":269.3120755942236},"point_estimate":174.14122488282922,"standard_error":41.12497073058249},"slope":{"confidence_interval":{"confidence_level":0.95,"lower_bound":1034.6949154067327,"upper_bound":1072.5352631227072},"point_estimate":1056.3635247858945,"standard_error":9.665908874615987},"std_dev":{"confidence_interval":{"confidence_level":0.95,"lower_bound":368.07609550423166,"upper_bound":449.8780643339072},"point_estimate":417.0844221593338,"standard_error":20.981885319481645}}
{"mean":{"confidence_interval":{"confidence_level":0.95,"lower_bound":40.25971762693777,"upper_bound":41.63588746031105},"point_estimate":40.88144999777207,"standard_error":0.3540448191593488},"median":{"confidence_interval":{"confidence_level":0.95,"lower_bound":40.17273395844824,"upper_bound":40.75245742637047},"point_estimate":40.46929668961862,"standard_error":0.14343907424406363},"median_abs_dev":{"confidence_interval":{"confidence_level":0.95,"lower_bound":1.0086008314370745,"upper_bound":2.8610553424118184},"point_estimate":2.145206741241782,"standard_error":0.5175814216784274},"slope":{"confidence_interval":{"confidence_level":0.95,"lower_bound":41.18262952854391,"upper_bound":41.833196313253836},"point_estimate":41.52563954758871,"standard_error":0.16654893211587216},"std_dev":{"confidence_interval":{"confidence_level":0.95,"lower_bound":1.9216492632511177,"upper_bound":5.115461025371509},"point_estimate":3.5612974992500113,"standard_error":0.8510374523148664}}

0 comments on commit 3e85eb7

Please sign in to comment.