Skip to content

Commit 7a24f22

Browse files
committed
refactor: remove Collector:Allocator supertrait
1 parent d4864e7 commit 7a24f22

File tree

14 files changed

+46
-835
lines changed

14 files changed

+46
-835
lines changed

Cargo.lock

Lines changed: 1 addition & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Conclusion
2+
3+
date: 2026-03-17
4+
author: shruti2522
5+
6+
We have decided not to go ahead with `Collector: Allocator`. One of the main
7+
reasons is that it requires the collector to be non-moving, but the whole point
8+
of this redesign is to move Boa towards a moving GC, so implementing a feature
9+
that fundamentally depends on objects never moving works against that goal. The
10+
rest of the reasoning is documented in `collector_allocator_supertrait.md`.

oscars/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ version = "0.1.0"
44
edition = "2024"
55

66
[dependencies]
7-
allocator-api2 = { version = "0.4.0", optional = true }
87
hashbrown = "0.16.1"
98
oscars_derive = { path = "../oscars_derive", version = "0.1.0" }
109
rustc-hash = "2.1.1"
@@ -18,7 +17,6 @@ boa_gc = { git = "https://github.com/boa-dev/boa", branch = "main" }
1817
[[bench]]
1918
name = "oscars_vs_boa_gc"
2019
harness = false
21-
required-features = ["gc_allocator"]
2220

2321
[[bench]]
2422
name = "arena2_vs_mempool3"
@@ -33,5 +31,4 @@ default = ["mark_sweep"]
3331
std = []
3432
mark_sweep = []
3533
mark_sweep2 = ["mark_sweep"]
36-
gc_allocator = ["dep:allocator-api2", "mark_sweep"]
3734
thin-vec = ["dep:thin-vec", "mark_sweep"]

oscars/benches/oscars_vs_boa_gc.rs

Lines changed: 1 addition & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use criterion::{BenchmarkId, Criterion, black_box, criterion_group, criterion_main};
22
use oscars::mark_sweep::{
3-
Gc as OscarsGc, GcAllocVec, MarkSweepGarbageCollector, cell::GcRefCell as OscarsGcRefCell,
3+
Gc as OscarsGc, MarkSweepGarbageCollector, cell::GcRefCell as OscarsGcRefCell,
44
};
55

66
use boa_gc::{Gc as BoaGc, GcRefCell as BoaGcRefCell, force_collect as boa_force_collect};
@@ -101,99 +101,6 @@ fn bench_collection(c: &mut Criterion) {
101101
group.finish();
102102
}
103103

104-
fn bench_vec_create(c: &mut Criterion) {
105-
let mut group = c.benchmark_group("vector_creation");
106-
107-
for size in [10, 100, 1000].iter() {
108-
group.bench_with_input(
109-
BenchmarkId::new("oscars_gc_allocator", size),
110-
size,
111-
|b, &size| {
112-
let collector = MarkSweepGarbageCollector::default()
113-
.with_page_size(65536)
114-
.with_heap_threshold(262144);
115-
116-
b.iter(|| {
117-
let vec = GcAllocVec::with_capacity(size, &collector);
118-
let gc_vec = OscarsGc::new_in(OscarsGcRefCell::new(vec), &collector);
119-
120-
for i in 0..size {
121-
gc_vec.borrow_mut().push(black_box(i));
122-
}
123-
124-
black_box(gc_vec.borrow().len())
125-
});
126-
},
127-
);
128-
129-
group.bench_with_input(
130-
BenchmarkId::new("boa_gc_std_vec", size),
131-
size,
132-
|b, &size| {
133-
b.iter(|| {
134-
let gc_vec = BoaGc::new(BoaGcRefCell::new(Vec::with_capacity(size)));
135-
for i in 0..size {
136-
gc_vec.borrow_mut().push(black_box(i));
137-
}
138-
black_box(gc_vec.borrow().len())
139-
});
140-
},
141-
);
142-
}
143-
144-
group.finish();
145-
}
146-
147-
fn bench_vec_ptrs(c: &mut Criterion) {
148-
let mut group = c.benchmark_group("vec_of_gc_pointers");
149-
150-
for num_elements in [10, 50, 100].iter() {
151-
group.bench_with_input(
152-
BenchmarkId::new("oscars", num_elements),
153-
num_elements,
154-
|b, &num_elements| {
155-
let collector = MarkSweepGarbageCollector::default()
156-
.with_page_size(65536)
157-
.with_heap_threshold(262144);
158-
159-
b.iter(|| {
160-
let vec = GcAllocVec::with_capacity(num_elements, &collector);
161-
let gc_vec = OscarsGc::new_in(OscarsGcRefCell::new(vec), &collector);
162-
163-
for i in 0..num_elements {
164-
let inner = OscarsGc::new_in(OscarsGcRefCell::new(i), &collector);
165-
gc_vec.borrow_mut().push(inner);
166-
}
167-
168-
let sum: usize = gc_vec.borrow().iter().map(|gc| *gc.borrow()).sum();
169-
black_box(sum)
170-
});
171-
},
172-
);
173-
174-
group.bench_with_input(
175-
BenchmarkId::new("boa_gc", num_elements),
176-
num_elements,
177-
|b, &num_elements| {
178-
b.iter(|| {
179-
let mut vec = Vec::with_capacity(num_elements);
180-
181-
for i in 0..num_elements {
182-
let gc = BoaGc::new(BoaGcRefCell::new(i));
183-
vec.push(gc);
184-
}
185-
186-
let gc_vec = BoaGc::new(BoaGcRefCell::new(vec));
187-
let sum: usize = gc_vec.borrow().iter().map(|gc| *gc.borrow()).sum();
188-
black_box(sum)
189-
});
190-
},
191-
);
192-
}
193-
194-
group.finish();
195-
}
196-
197104
fn bench_mixed(c: &mut Criterion) {
198105
let mut group = c.benchmark_group("mixed_workload");
199106

@@ -382,8 +289,6 @@ criterion_group!(
382289
benches,
383290
bench_alloc,
384291
bench_collection,
385-
bench_vec_create,
386-
bench_vec_ptrs,
387292
bench_mixed,
388293
bench_pressure,
389294
bench_deep,

oscars/src/collectors/collector.rs

Lines changed: 0 additions & 81 deletions
This file was deleted.

0 commit comments

Comments
 (0)