Skip to content

Commit d893603

Browse files
authored
rename arena to memorypool (#48295)
1 parent b473bac commit d893603

File tree

15 files changed

+525
-465
lines changed

15 files changed

+525
-465
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ time = { version = "0.3.36", features = ["formatting", "local-offset", "macros"]
6464
cbindgen = "0.27"
6565

6666
[[bench]]
67-
name = "arena"
67+
name = "memorypool"
6868
harness = false
6969

7070
[[bench]]
Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,24 @@
1515
*/
1616

1717
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
18-
use pushpin::core::arena;
18+
use pushpin::core::memorypool;
1919
use std::cell::RefCell;
2020
use std::mem;
2121
use std::rc::Rc;
2222

23-
fn bench_arena_rc_new<const N: usize>(c: &mut Criterion, op_count: usize) {
23+
fn bench_mp_rc_new<const N: usize>(c: &mut Criterion, op_count: usize) {
2424
let bytes = mem::size_of::<[u64; N]>();
25-
let memory = Rc::new(arena::RcMemory::new(op_count));
25+
let memory = Rc::new(memorypool::RcMemory::new(op_count));
2626
let instances = RefCell::new(Vec::with_capacity(op_count));
2727

28-
c.bench_function(&format!("arena rc new {bytes}b x{op_count}"), |b| {
28+
c.bench_function(&format!("mp rc new {bytes}b x{op_count}"), |b| {
2929
b.iter_batched_ref(
3030
|| instances.borrow_mut().clear(),
3131
|_| {
3232
let instances = &mut *instances.borrow_mut();
3333
let mut next_value: [u64; N] = [0; N];
3434
while next_value[0] < op_count as u64 {
35-
let n = arena::Rc::new(next_value, &memory).unwrap();
35+
let n = memorypool::Rc::new(next_value, &memory).unwrap();
3636
instances.push(n);
3737
next_value[0] += 1;
3838
}
@@ -63,18 +63,18 @@ fn bench_std_rc_new<const N: usize>(c: &mut Criterion, op_count: usize) {
6363
});
6464
}
6565

66-
fn bench_arena_rc_drop<const N: usize>(c: &mut Criterion, op_count: usize) {
66+
fn bench_mp_rc_drop<const N: usize>(c: &mut Criterion, op_count: usize) {
6767
let bytes = mem::size_of::<[u64; N]>();
68-
let memory = Rc::new(arena::RcMemory::new(op_count));
68+
let memory = Rc::new(memorypool::RcMemory::new(op_count));
6969
let instances = RefCell::new(Vec::with_capacity(op_count));
7070

71-
c.bench_function(&format!("arena rc drop {bytes}b x{op_count}"), |b| {
71+
c.bench_function(&format!("mp rc drop {bytes}b x{op_count}"), |b| {
7272
b.iter_batched_ref(
7373
|| {
7474
let instances = &mut *instances.borrow_mut();
7575
let mut next_value: [u64; N] = [0; N];
7676
while next_value[0] < op_count as u64 {
77-
let n = arena::Rc::new(next_value, &memory).unwrap();
77+
let n = memorypool::Rc::new(next_value, &memory).unwrap();
7878
instances.push(n);
7979
next_value[0] += 1;
8080
}
@@ -111,24 +111,24 @@ fn criterion_benchmark(c: &mut Criterion) {
111111

112112
{
113113
// Preallocate the instances
114-
let memory = Rc::new(arena::RcMemory::new(OP_COUNT));
114+
let memory = Rc::new(memorypool::RcMemory::new(OP_COUNT));
115115
let mut instances = Vec::new();
116116
let mut next_value: u64 = 0;
117117
while next_value < OP_COUNT as u64 {
118-
let n = arena::Rc::new(next_value, &memory).unwrap();
118+
let n = memorypool::Rc::new(next_value, &memory).unwrap();
119119
instances.push(n);
120120
next_value += 1;
121121
}
122122

123123
let clones = RefCell::new(Vec::with_capacity(instances.len()));
124124

125-
c.bench_function(&format!("arena rc clone x{OP_COUNT}"), |b| {
125+
c.bench_function(&format!("mp rc clone x{OP_COUNT}"), |b| {
126126
b.iter_batched_ref(
127127
|| clones.borrow_mut().clear(),
128128
|_| {
129129
let clones = &mut *clones.borrow_mut();
130130
for r in &instances {
131-
clones.push(arena::Rc::clone(&r));
131+
clones.push(memorypool::Rc::clone(&r));
132132
}
133133
},
134134
BatchSize::PerIteration,
@@ -164,23 +164,23 @@ fn criterion_benchmark(c: &mut Criterion) {
164164

165165
{
166166
// Preallocate the instances
167-
let memory = Rc::new(arena::RcMemory::new(OP_COUNT));
167+
let memory = Rc::new(memorypool::RcMemory::new(OP_COUNT));
168168
let mut instances = Vec::new();
169169
let mut next_value: u64 = 0;
170170
while next_value < OP_COUNT as u64 {
171-
let n = arena::Rc::new(next_value, &memory).unwrap();
171+
let n = memorypool::Rc::new(next_value, &memory).unwrap();
172172
instances.push(n);
173173
next_value += 1;
174174
}
175175

176176
let clones = RefCell::new(Vec::with_capacity(instances.len()));
177177

178-
c.bench_function(&format!("arena rc dec x{OP_COUNT}"), |b| {
178+
c.bench_function(&format!("mp rc dec x{OP_COUNT}"), |b| {
179179
b.iter_batched_ref(
180180
|| {
181181
let clones = &mut *clones.borrow_mut();
182182
for r in &instances {
183-
clones.push(arena::Rc::clone(r))
183+
clones.push(memorypool::Rc::clone(r))
184184
}
185185
},
186186
|_| clones.borrow_mut().clear(),
@@ -217,16 +217,16 @@ fn criterion_benchmark(c: &mut Criterion) {
217217

218218
{
219219
// Preallocate the instances
220-
let memory = Rc::new(arena::RcMemory::new(OP_COUNT));
220+
let memory = Rc::new(memorypool::RcMemory::new(OP_COUNT));
221221
let mut instances = Vec::new();
222222
let mut next_value: u64 = 0;
223223
while next_value < OP_COUNT as u64 {
224-
let n = arena::Rc::new(next_value, &memory).unwrap();
224+
let n = memorypool::Rc::new(next_value, &memory).unwrap();
225225
instances.push(n);
226226
next_value += 1;
227227
}
228228

229-
c.bench_function(&format!("arena rc deref x{OP_COUNT}"), |b| {
229+
c.bench_function(&format!("mp rc deref x{OP_COUNT}"), |b| {
230230
b.iter(|| {
231231
for (expected_value, r) in instances.iter().enumerate() {
232232
assert_eq!(*r.get(), expected_value as u64);
@@ -254,22 +254,22 @@ fn criterion_benchmark(c: &mut Criterion) {
254254
});
255255
}
256256

257-
bench_arena_rc_new::<1>(c, OP_COUNT);
257+
bench_mp_rc_new::<1>(c, OP_COUNT);
258258
bench_std_rc_new::<1>(c, OP_COUNT);
259259

260-
bench_arena_rc_drop::<1>(c, OP_COUNT);
260+
bench_mp_rc_drop::<1>(c, OP_COUNT);
261261
bench_std_rc_drop::<1>(c, OP_COUNT);
262262

263-
bench_arena_rc_new::<80>(c, OP_COUNT);
263+
bench_mp_rc_new::<80>(c, OP_COUNT);
264264
bench_std_rc_new::<80>(c, OP_COUNT);
265265

266-
bench_arena_rc_drop::<80>(c, OP_COUNT);
266+
bench_mp_rc_drop::<80>(c, OP_COUNT);
267267
bench_std_rc_drop::<80>(c, OP_COUNT);
268268

269-
bench_arena_rc_new::<160>(c, OP_COUNT);
269+
bench_mp_rc_new::<160>(c, OP_COUNT);
270270
bench_std_rc_new::<160>(c, OP_COUNT);
271271

272-
bench_arena_rc_drop::<160>(c, OP_COUNT);
272+
bench_mp_rc_drop::<160>(c, OP_COUNT);
273273
bench_std_rc_drop::<160>(c, OP_COUNT);
274274
}
275275

src/connmgr/batch.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
use crate::connmgr::zhttppacket;
1919
use crate::connmgr::zhttpsocket::FROM_MAX;
20-
use crate::core::arena;
2120
use crate::core::list;
21+
use crate::core::memorypool;
2222
use arrayvec::ArrayVec;
2323
use slab::Slab;
2424
use std::convert::TryFrom;
@@ -31,7 +31,7 @@ pub struct BatchKey {
3131
pub struct BatchGroup<'a, 'b> {
3232
addr: &'b [u8],
3333
use_router: bool,
34-
ids: arena::ReusableVecHandle<'b, zhttppacket::Id<'a>>,
34+
ids: memorypool::ReusableVecHandle<'b, zhttppacket::Id<'a>>,
3535
}
3636

3737
impl<'a> BatchGroup<'a, '_> {
@@ -58,7 +58,7 @@ pub struct Batch {
5858
nodes: Slab<list::Node<usize>>,
5959
addrs: Vec<AddrItem>,
6060
addr_index: usize,
61-
group_ids: arena::ReusableVec,
61+
group_ids: memorypool::ReusableVec,
6262
last_group_ckeys: Vec<usize>,
6363
}
6464

@@ -68,7 +68,7 @@ impl Batch {
6868
nodes: Slab::with_capacity(capacity),
6969
addrs: Vec::with_capacity(capacity),
7070
addr_index: 0,
71-
group_ids: arena::ReusableVec::new::<zhttppacket::Id>(capacity),
71+
group_ids: memorypool::ReusableVec::new::<zhttppacket::Id>(capacity),
7272
last_group_ckeys: Vec::with_capacity(capacity),
7373
}
7474
}

0 commit comments

Comments
 (0)