Small release with one significant change: Gc now points to T directly,
eliminating the extra soundness requirement documented in v0.6.1 for
Gc::cast and Gc::from_ptr.
This change also should enable very slightly improved performance by pointing
directly to a T rather than pointing to a structure with T as a field.
This comes with a very slight reduction in performance for tracing because the
opposite is true there, the pointer must be negatively offset to the header.
Since dereferencing is vastly more common than tracing, this is a win.
There is also one behavior only API incompatible change, but it changes the
behavior enough to warrant an incompatible semver change: GC pacing is now based
on Gc pointer count and no longer on the (shallow) size of allocations in
bytes.
This change was made because it is has been too difficult in Rust to try and integrate with Rust's other ways of allocating and freeing memory and determining the cost of allocations, drops, and frees. With this change, there is no longer an association whatsoever with the shallow size in bytes for allocations and pacing. This was already very misleading, as it did not (automatically) count any allocations held by GC objects, and integrating external byte allocation proved far too complex and brittle and did not account for drops that are expensive in other ways.
The replacement is either live with the inaccuracy of Gc-count pacing (which
is practically no different than before), or to keep track of memory manually
(which is equivalently difficult as using the previous "external bytes"
features) and create debt artificially at an appropriate pace.
Practically speaking, the only change for users will be to adjust pacing factors if you set them manually.
- Use raw
Gccount for collection metrics and ignore allocation size. - New
ZstCachetype to share a single allocation amongGcpointers to ZSTs. GcandGcWeaknow store pointers directly toTand are more or less identical to*const Tin behavior and performance.
(Doc-only) soundess fix for v0.6.0!
- Document that
Gc::castandGc::from_ptrrequire that the source and target types share the same alignment.
Big release with a huge number of changes.
Much faster DynamicRootSet that does not require individual allocations per
root!
Non-object-safe Collect trait enables more optimization for automatic impls.
Explicit forward and backwards GC write barriers to enable more kinds of safe container abstractions.
More precise control over GC phase.
Entirely new, much more tunable, much more correct GC pacing system.
Removes the idea of "external allocation" from collection entirely, as it was simply too complex to reason about. Instead, users can use custom allocators and directly adjust collection debt up and down based on recorded external allocation. This direct adjustment of collection debt can also be use to directly drive incremental collection independent of GC allocation.
- Implement
Ord/PartialOrdforCollectionPhase. - Let
Gc::cast,Gc::from_ptrGcWeak::castandGcWeak::from_ptrwork with unsized types. - Redesign
DynamicRootSetto not require individual allocations per root. - Remove
Collect,Sized, and'staticbounds onRootable::Root. - Add convenience
Gc::new_static,Gc::eraseandGcWeak::eraseconvenience methods. - Make
StaticCollect<T>work with unsizedT. - Add (unsafe) forward write barriers and explicit (unsafe) backwards write
barriers to
Mutation. - Rename
CollectionPhase::Collecting->CollectionPhase::SweepingandStaticCollect->Static. - Get rid of
unsafe_empty_collect!macro. - Slightly re-org crate exports and drop some special case re-exports from the crate root.
- Rename
MarkedArena::start_collectingtoMarkedArena::start_sweepingto matchCollectionPhase::Sweeping - Implement
Borrow<T>forGc<'gc, T>. - Rework the
Collecttrait. Adds a'gclifetime for correctness.Collect::NEEDS_TRACEassociated constant allows for more optimization of tracing. No longer object safe! Adds aTracetrait for the trace implementation passed toCollect::trace. - Use unsafe interior mutability to reduce internal
RefCelllocking in the collector. - Update
hashbrownto0.17. - New, much more correct GC pacing system with many more tunable parameters.
- Add
Arena::cycle_debt(equivalent ofArena::collect_debtwhich stops at the end of the GC cycle. and some method renames to aid phase tracking. - Add the ability to add / subtract artificial debt from the GC pacing.
- Improvements to correctness around inheriting GC debt across cycles.
- Implement
CollectforBinaryHeap. - Add
OnceLock(a GC-awareOnceCell). - Add
{Deref, Index}Writetraits, for deref. and indexing behind write barriers. - Migrate to Edition 2024 to fix
field!macro unsoundness. - Add a
DynCollecttrait and a way to safely GC custom dyn traits via a macro (replacement for lostCollectobject safety). - Add
Collectimpl forenum_map::EnumMapbehind feature gate. - Add
Collectimpl forslotmap::SlotMapbehind feature gate. - Add
Collectimpl forsmallvec::SmallVecbehind feature gate. Collectimpl forindexmap::IndexMapandindexmap::IndexSetbehind feature gate.- Remove all notions of externally allocated bytes,
MetricsAlloc, andallocator-api2dependency.
- Adds a
Collectimpl forhashbrown::HashTable.
- Add the ability to transition from a fully marked arena immediately into
CollectionPhase::Collecting.
- Correct the behavior of
Arena::mark_debtandArena::mark_allto do what their documentation suggest and do nothing duringCollectionPhase::Collecting - Implement
Collectforstd::collections::LinkedList - Make
StaticCollect<T>#[repr(transparent)], to support sound casting fromGc<StaticCollect<T>>toGc<T>.
This release adds the concept of "finalization" to arenas. At the end of the "mark" phase, at the moment that an arena is considered "fully marked" and is ready to transition to the "sweep" phase, the "fully marked" arena can be examined with some special powers...
MarkedArena::finalize can be called to check which pointers are considered
"dead" for this collection cycle. A "dead" pointer is one that is destined
(without further changes) to be freed during the next "sweep" phase. You can
"resurrect" these pointers either through normal root mutation before entering
the "sweep" phase, or more simply by calling explicit resurrect methods
on those pointers. Any resurrection, whether through mutation or resurrect
methods, immediately makes the arena no longer fully marked, but the arena can
then be re-marked and re-examined.
This simple, safe API (examining a "fully marked" arena for potentially dead pointers, performing mutation, then potentially re-marking and re-examining) is enough to implement quite complex garbage collector behavior. It can be used to implement "finalizer" methods on objects, "ephemeron tables", Java-style "reference queues" and more.
- New
FinalizationAPI. - New API to query the current phase of the collector.
- Fixup the pacing algorithm for correctness and simplicity. Makes
Pacing::with_timing_factor(0.0)actually work correctly for stop-the-world collection. GcWeak::is_droppednow works only during collection, not mutation.- Add more trait impls to
StaticCollect. Gc::ptr_eqandGcWeak::ptr_eqnow ignore metadata ofdynpointers, matching the behavior ofRc::ptr_eqandArc::ptr_eq.
This release adds the ability to track external allocations (allocations
which are not stored in a Gc<T>) which also participate in pacing the garbage
collector. There is now a new (feature-gated) type allocator_api::MetricsAlloc
which implements the allocator-api2::Allocator trait which can be used to
automatically track the external allocation of collection types.
This release also adds (feature-gated) tracing support, which emits a span
per GC phase (propagate, sweep, drop), and events when collection resumes and
yields.
- Tracked external allocations API which participates in GC pacing.
- Feature-gated support for a
allocator_api2::Allocatorimplementation that automatically tracks allocation. - Feature-gated support for
hashbrowntypes, to automatically implementCollecton them. - Feature-gated
tracingsupport. - Implement
CollectforBox<T: ?Sized>. - Add methods to project
Write<Option<T>>andWrite<Result<T, E>>. - Don't fail to build by trying to implement
CollectonArc<T>for platforms withoutArc.
- Actually pause for the configured amount of time in the gc, rather than the minimum.
- Implement
Eq,PartialEq,Ord,PartialOrd, andHashtraits onGc<T>similar to the traits on std smart pointers likeRc<T>. - Relax unnecessary bounds on
Collectimpls of std collections. - Make
Arena::remembered_size()return reasonable values.
- Fallible
DynamicRootSetAPI.
An enormous number of breaking API changes, too many to list, almost the entire API has been rethought.
The credit goes mostly to others for the release, @Bale001, @Aaron1011, @dragazo, and especially @moulins.
- New
ArenaAPI that does not require macros and instead uses aRootabletrait and HRTBs for lifetime projection. - Methods on
Arenato directly mutate the root type and map the root from one type to another. - A new API for 'static roots that are held in smart pointers
(
DynamicRootSet). Gcpointers can now point to DSTs, and there is anunsize!macro for unsizing coercions to replace the unstableUnsizetrait.- Weak pointers!
GcCellhas been replaced by explicit public lock types held withinGcpointers with safe ways of mutating them.- Field projection on held lock types to allow for separate locks held within a
single
Gcpointer to be safely mutated. - Unsafe
Gcpointer coercions to compatible pointee types. - Soundly get references to
Gctypes with&'gclifetime. - More ergonomic
MutationandCollectioncontext types. - Tons of correctness and soundness fixes.
This release also completely drops the gc-sequence combinator crate.
Because of other API changes, anything you could do with gc-sequence before
can almost certainly be expressed better either using the new 'static root API
or with the new map API. See this comment for a bit more info.
- No changes, fixing a release snafu with cargo-release
- Allow using
#[collect(require_static)]on fields - Add no_std compatibility for gc-arena and gc-sequence
- Add
Collectimpl for VecDeque,PhantomData`. - Add
#[track_caller]for better panic error messages - Improve error messages for proc-macro derived
Collectimplementations substantially. - Improve generated code for
Context::allocatein release builds.
- API incompatible change: depend on proc-macro2, quote, and syn 1.0
- API incompatible change: update synstructure to 0.12
- API incompatible change: use the trick from the
pin-projectcrate to prevent types from implementing Drop by making it cause a conflicting impl of aMustNotImplDroptrait. - API incompatible change: Add
#[collect(no_drop)]and remove theempty_dropandrequire_copyversions since they are now less useful thanno_drop.