Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions notes/coll_alloc_supertrait/CONCLUSION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Conclusion

date: 2026-03-17
author: shruti2522

We have decided not to go ahead with `Collector: Allocator`. One of the main
reasons is that it requires the collector to be non-moving, but the whole point
of this redesign is to move Boa towards a moving GC, so implementing a feature
that fundamentally depends on objects never moving works against that goal. The
rest of the reasoning is documented in `collector_allocator_supertrait.md`.
4 changes: 1 addition & 3 deletions oscars/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ version = "0.1.0"
edition = "2024"

[dependencies]
allocator-api2 = { version = "0.4.0", optional = true }
hashbrown = "0.16.1"
oscars_derive = { path = "../oscars_derive", version = "0.1.0" }
rustc-hash = "2.1.1"
Expand All @@ -18,7 +17,7 @@ boa_gc = { git = "https://github.com/boa-dev/boa", branch = "main" }
[[bench]]
name = "oscars_vs_boa_gc"
harness = false
required-features = ["gc_allocator"]
required-features = ["mark_sweep"]

[[bench]]
name = "arena2_vs_mempool3"
Expand All @@ -33,5 +32,4 @@ default = ["mark_sweep"]
std = []
mark_sweep = []
mark_sweep2 = ["mark_sweep"]
gc_allocator = ["dep:allocator-api2", "mark_sweep"]
thin-vec = ["dep:thin-vec", "mark_sweep"]
97 changes: 1 addition & 96 deletions oscars/benches/oscars_vs_boa_gc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use criterion::{BenchmarkId, Criterion, black_box, criterion_group, criterion_main};
use oscars::mark_sweep::{
Gc as OscarsGc, GcAllocVec, MarkSweepGarbageCollector, cell::GcRefCell as OscarsGcRefCell,
Gc as OscarsGc, MarkSweepGarbageCollector, cell::GcRefCell as OscarsGcRefCell,
};

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

fn bench_vec_create(c: &mut Criterion) {
let mut group = c.benchmark_group("vector_creation");

for size in [10, 100, 1000].iter() {
group.bench_with_input(
BenchmarkId::new("oscars_gc_allocator", size),
size,
|b, &size| {
let collector = MarkSweepGarbageCollector::default()
.with_page_size(65536)
.with_heap_threshold(262144);

b.iter(|| {
let vec = GcAllocVec::with_capacity(size, &collector);
let gc_vec = OscarsGc::new_in(OscarsGcRefCell::new(vec), &collector);

for i in 0..size {
gc_vec.borrow_mut().push(black_box(i));
}

black_box(gc_vec.borrow().len())
});
},
);

group.bench_with_input(
BenchmarkId::new("boa_gc_std_vec", size),
size,
|b, &size| {
b.iter(|| {
let gc_vec = BoaGc::new(BoaGcRefCell::new(Vec::with_capacity(size)));
for i in 0..size {
gc_vec.borrow_mut().push(black_box(i));
}
black_box(gc_vec.borrow().len())
});
},
);
}

group.finish();
}

fn bench_vec_ptrs(c: &mut Criterion) {
let mut group = c.benchmark_group("vec_of_gc_pointers");

for num_elements in [10, 50, 100].iter() {
group.bench_with_input(
BenchmarkId::new("oscars", num_elements),
num_elements,
|b, &num_elements| {
let collector = MarkSweepGarbageCollector::default()
.with_page_size(65536)
.with_heap_threshold(262144);

b.iter(|| {
let vec = GcAllocVec::with_capacity(num_elements, &collector);
let gc_vec = OscarsGc::new_in(OscarsGcRefCell::new(vec), &collector);

for i in 0..num_elements {
let inner = OscarsGc::new_in(OscarsGcRefCell::new(i), &collector);
gc_vec.borrow_mut().push(inner);
}

let sum: usize = gc_vec.borrow().iter().map(|gc| *gc.borrow()).sum();
black_box(sum)
});
},
);

group.bench_with_input(
BenchmarkId::new("boa_gc", num_elements),
num_elements,
|b, &num_elements| {
b.iter(|| {
let mut vec = Vec::with_capacity(num_elements);

for i in 0..num_elements {
let gc = BoaGc::new(BoaGcRefCell::new(i));
vec.push(gc);
}

let gc_vec = BoaGc::new(BoaGcRefCell::new(vec));
let sum: usize = gc_vec.borrow().iter().map(|gc| *gc.borrow()).sum();
black_box(sum)
});
},
);
}

group.finish();
}

fn bench_mixed(c: &mut Criterion) {
let mut group = c.benchmark_group("mixed_workload");

Expand Down Expand Up @@ -382,8 +289,6 @@ criterion_group!(
benches,
bench_alloc,
bench_collection,
bench_vec_create,
bench_vec_ptrs,
bench_mixed,
bench_pressure,
bench_deep,
Expand Down
2 changes: 1 addition & 1 deletion oscars/src/alloc/arena2/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ impl<'arena> Arena<'arena> {

pub fn get_allocation_data<T>(
&self,
value_ref: &T,
_value_ref: &T,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove parameter

if this is truly unused, then we should not pass in a value

) -> Result<ArenaAllocationData, ArenaAllocError> {
let size = core::mem::size_of::<ArenaHeapItem<T>>();
let alignment = core::mem::align_of::<ArenaHeapItem<T>>();
Expand Down
81 changes: 0 additions & 81 deletions oscars/src/collectors/collector.rs

This file was deleted.

Loading