pub struct Shared;Expand description
A size-classed free list shared by every thread, for a library.
Pooled keeps its lists per thread, which is right for a program that
owns its threads. A library loaded into Python or Node does not: the host
starts and ends threads, and every thread that ends would leave its lists
behind, up to [CLASSES] times the per class cap. These lists belong to the
process, so nothing is left behind when a thread ends.
Why a lock per class is still cheaper than the system heap (task-2191). The C library spent about 15% of a single row insert into an indexed table in the Windows heap. A free list here takes one uncontended compare and swap to lock and one store to unlock, and a host calls the library from one thread at a time far more often than from several.
Trait Implementations§
Source§unsafe fn alloc(&self, layout: Layout) -> *mut u8
unsafe fn alloc(&self, layout: Layout) -> *mut u8
layout. Read more