Skip to content

Commit d9aad66

Browse files
committed
Try to fix this spaghetti
1 parent 577c2a4 commit d9aad66

File tree

17 files changed

+759
-726
lines changed

17 files changed

+759
-726
lines changed

rust/benches/bench.rs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,20 @@
11
#![feature(allocator_api)]
2-
#![feature(box_syntax)]
2+
mod benchmarks;
33

4-
use criterion::criterion_group;
54
use {
6-
create::create_links,
7-
criterion::criterion_main,
8-
delete::delete_links,
9-
each::{each_all, each_concrete, each_identity, each_incoming, each_outgoing},
10-
update::update_links,
5+
benchmarks::create_links,
6+
criterion::{criterion_group, criterion_main},
117
};
12-
mod create;
13-
mod delete;
14-
mod each;
15-
mod update;
168

179
criterion_group!(
1810
benches,
1911
create_links,
20-
delete_links,
21-
each_identity,
22-
each_concrete,
23-
each_outgoing,
24-
each_incoming,
25-
each_all,
26-
update_links
12+
//delete_links,
13+
//each_identity,
14+
//each_concrete,
15+
//each_outgoing,
16+
//each_incoming,
17+
//each_all,
18+
//update_links
2719
);
2820
criterion_main!(benches);

rust/benches/benchmarks/create.rs

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
use {
2+
linkspsql::{connect, Sql},
3+
criterion::{measurement::WallTime, BenchmarkGroup, Criterion},
4+
doublets::{data::LinkType, mem::Alloc, split, unit, Doublets},
5+
linkspsql::{
6+
benchmark, elapsed, prepare_file, Benched, Client, Fork, Result, Transaction,
7+
BACKGROUND_LINKS,
8+
},
9+
std::{
10+
alloc::Global,
11+
time::{Duration, Instant},
12+
},
13+
tokio::runtime::{Builder, Runtime},
14+
};
15+
16+
fn bench<S: Benched + Doublets<T>, T: LinkType>(
17+
builder: S::Builder<'_>,
18+
id: &str,
19+
group: &mut BenchmarkGroup<WallTime>,
20+
) -> Result<()> {
21+
let mut storage = S::setup(builder)?;
22+
group.bench_function(id, |b| {
23+
benchmark! {
24+
b,
25+
let mut fork = storage.fork();
26+
for _ in 0..1_000 {
27+
let _ = fork.create_point();
28+
}
29+
}
30+
});
31+
Ok(())
32+
}
33+
34+
pub fn create_links(c: &mut Criterion) -> Result<()> {
35+
let mut group = c.benchmark_group("Create");
36+
//let united = prepare_file("united.links")?;
37+
//let split_data = prepare_file("split_data.links")?;
38+
//let split_index = prepare_file("split_index.links")?;
39+
//bench::<Client<usize>, _>(&runtime, "PSQL_NonTransaction", &mut group).unwrap();
40+
{
41+
let runtime = Runtime::new().unwrap();
42+
let mut client = runtime.block_on(connect()).unwrap();
43+
bench::<Transaction<'_, usize>, _>(&mut client, "PSQL_Transaction", &mut group).unwrap();
44+
}
45+
46+
/*bench::<unit::Store<usize, Alloc<LinkPart<_>, _>>, _>(
47+
Global,
48+
"Doublets_United_Volatile",
49+
&mut group,
50+
)
51+
.unwrap();
52+
53+
bench::<unit::Store<usize, FileMapped<_>>, _>(
54+
prepare_file("united.links")?,
55+
"Doublets_United_NonVolatile",
56+
&mut group,
57+
)
58+
.unwrap();
59+
60+
bench::<split::Store<usize, Alloc<DataPart<_>, _>, Alloc<IndexPart<_>, _>>, _>(
61+
Global,
62+
"Doublets_Split_Volatile",
63+
&mut group,
64+
)
65+
.unwrap();
66+
67+
bench::<split::Store<usize, FileMapped<_>, FileMapped<_>>, _>(
68+
(
69+
prepare_file("split_data.links")?,
70+
prepare_file("split_index.links")?,
71+
),
72+
"Doublets_Split_NonVolatile",
73+
&mut group,
74+
)
75+
.unwrap();*/
76+
group.finish();
77+
Ok(())
78+
}
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
#![feature(allocator_api)]
2-
31
use {
42
criterion::Criterion,
53
doublets::{
64
mem::{Alloc, FileMapped},
75
split, unit, Doublets,
86
},
9-
linkspsql::{benchmark, connect, elapsed, prepare_file, SetupTeardown, BACKGROUND_LINKS},
7+
linkspsql::{benchmark, connect, elapsed, prepare_file, Benched, BACKGROUND_LINKS},
108
std::{
9+
alloc::Global,
1110
error::Error,
1211
time::{Duration, Instant},
1312
},
@@ -17,7 +16,6 @@ use {
1716
pub fn delete_links(c: &mut Criterion) -> Result<(), Box<dyn Error>> {
1817
let runtime = Runtime::new()?;
1918
let mut group = c.benchmark_group("Delete");
20-
let allocator = std::alloc::Global;
2119
let united = prepare_file("united.links")?;
2220
let split_data = prepare_file("split_data.links")?;
2321
let split_index = prepare_file("split_index.links")?;
@@ -70,7 +68,7 @@ pub fn delete_links(c: &mut Criterion) -> Result<(), Box<dyn Error>> {
7068
let _ = client.transaction()?.teardown();
7169
}
7270
{
73-
let storage = Alloc::new(allocator);
71+
let storage = Alloc::new(Global);
7472
let mut links = unit::Store::<usize, _>::new(storage)?;
7573
let _ = links.setup();
7674
benchmark! {
@@ -110,8 +108,8 @@ pub fn delete_links(c: &mut Criterion) -> Result<(), Box<dyn Error>> {
110108
let _ = links.teardown();
111109
}
112110
{
113-
let data = Alloc::new(allocator);
114-
let index = Alloc::new(allocator);
111+
let data = Alloc::new(Global);
112+
let index = Alloc::new(Global);
115113
let mut links = split::Store::<usize, _, _>::new(data, index)?;
116114
let _ = links.setup();
117115
benchmark! {
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(allocator_api)]
21
mod all;
32
mod concrete;
43
mod identity;

rust/benches/benchmarks/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
mod create;
2+
//mod delete;
3+
///mod each;
4+
//mod update;
5+
pub use create::create_links;

0 commit comments

Comments
 (0)