Conversation
nekevss
left a comment
There was a problem hiding this comment.
Hmmmm, for the sake of quick iteration, we should split these into two modules, but can you attempt to minimize the duplication here, thinking specifically about the tracing and cell module.
This would mean splitting off the pointers, the internals, and the collector impl into versioned modules. But then we lessen the duplication.
We will also need to eventually think about a way to reuse some of this code maybe behind a trait. But let's leave that for later and focus on minimizing the duplication while having two implementations.
| // SAFETY: `ArenaHeapItem` is `repr(transparent)`, use addr_of_mut! to avoid | ||
| // creating a &mut reference during trace | ||
| let raw: *mut ArenaHeapItem<GcBox<NonTraceable>> = self.as_heap_ptr().as_ptr(); | ||
| unsafe { NonNull::new_unchecked(core::ptr::addr_of_mut!((*raw).0)) } |
There was a problem hiding this comment.
use &raw mut instead per the docs
| let raw: *mut ArenaHeapItem<GcBox<NonTraceable>> = self.as_heap_ptr().as_ptr(); | ||
| // SAFETY: `raw` is non-null because it comes from `as_heap_ptr()` | ||
| // `ArenaHeapItem` is `#[repr(transparent)]` so it shares the same address as field 0 | ||
| unsafe { NonNull::new_unchecked(core::ptr::addr_of_mut!((*raw).0)) } |
| pub(crate) type ErasedEphemeron = core::ptr::NonNull< | ||
| ArenaHeapItem< | ||
| Ephemeron< | ||
| crate::collectors::mark_sweep_arena2::internals::NonTraceable, |
There was a problem hiding this comment.
nit: weird formatting
Maybe just import NonTraceable directly and don't indent this.
There was a problem hiding this comment.
I don't think this needs to be copied again. Is there a reason the other cell intrinsics can't be shared between the two approaches here?
There was a problem hiding this comment.
Removed duplication in cell.rs, trace.rs and gc_header.rs now just re-export the mark_sweep ones directly since they share the exact same types. Also added a comment about the trace macros so it's clear in the future
2d884ef to
d0686d1
Compare
fix #29
mark_sweep_arena2arena2_vs_boa_gc, documented the results in notesmark_sweeptestsTODO once approved : plug this implementation into
boabench results:
arena2is much faster for simple allocations and collection sweeps, about 2x fast. In mixed tests and heavy memory tests, they perform about the same