pub(crate) struct Extent {
alloc_size: usize,
comp_len: usize,
resident: bool,
incomplete_passes: u8,
crc: u32,
read_since_demotion: bool,
home: Home,
}pool only.Expand description
One chunk’s compressed backing copy.
Fields§
§alloc_size: usizeByte size of the backing allocation (the extent’s class size, or the heap layout on the fallback path): the granule the resident accounting and the pageout operate on.
comp_len: usize§resident: boolWhether the extent’s pages are (engine-)resident: set at write and by
Extent::read_into, cleared by a Extent::pageout whose
residency observation found the whole range gone. Meaningful only in
the Arena and Heap homes, see Extent::is_resident. Mutated
only under the owning chunk’s state mutex.
incomplete_passes: u8Consecutive pageout passes whose observation found pages still
resident. Reset by Extent::read_into. At
PAGEOUT_RETRY_CAP the extent stops being advised out.
crc: u32Checksum of the first comp_len stored bytes, set when a demotion
commits and verified by every file read.
read_since_demotion: boolWhether the extent was read from its file since its demotion.
home: HomeImplementations§
Source§impl Extent
impl Extent
Sourcepub(crate) fn write(
arena: &Arc<ExtentArena>,
data: &[u64],
codec: &dyn ExtentCodec,
scratch: Scratch,
) -> Extent
pub(crate) fn write( arena: &Arc<ExtentArena>, data: &[u64], codec: &dyn ExtentCodec, scratch: Scratch, ) -> Extent
Encodes data through codec into a fresh extent, preferring an
arena slot and degrading to the heap when the payload’s class is
exhausted. The pages stay resident; the pool’s RSS-target
enforcement decides when Extent::pageout pushes them to the
device.
Encoding goes through a reused thread-local scratch buffer so the
extent slot can be chosen by the actual stored payload rather
than the codec’s worst case. Worst-case sizing costs ~5.6× on
compressible data, in swap capacity and in swap write bandwidth per
eviction (the whole allocation is paged out), which at hydration
eviction rates backs up device writeback and bloats the working set
with swap-cache pages. scratch says whether the caller’s thread
keeps the grown scratch for its next job.
Sourcefn ptr(&self) -> *mut u8
fn ptr(&self) -> *mut u8
The in-memory copy of the stored bytes. Panics for a File extent,
which has none.
Sourcepub(crate) fn alloc_size(&self) -> usize
pub(crate) fn alloc_size(&self) -> usize
The byte size of the extent’s allocation: the granule the resident accounting and the pageout operate on.
Sourcepub(crate) fn is_resident(&self) -> bool
pub(crate) fn is_resident(&self) -> bool
Whether the extent’s pages are engine-resident (not pushed to the
device since the last write or read). A Demoting extent is
resident until its demotion commits, and a File extent never is.
Sourcepub(crate) fn is_reclaimable_arena(&self) -> bool
pub(crate) fn is_reclaimable_arena(&self) -> bool
Whether the extent sits in an arena slot, resident and not retry-capped: the state RSS-target enforcement acts on, and the one in which freeing the extent avoids a device write.
Sourcepub(crate) fn is_demoting(&self) -> bool
pub(crate) fn is_demoting(&self) -> bool
Whether a demoter currently owns the extent.
Sourcepub(crate) fn file_bytes(&self) -> Option<usize>
pub(crate) fn file_bytes(&self) -> Option<usize>
The file slot’s size for a File extent, None otherwise.
Sourcepub(crate) fn file_location(&self) -> Option<FileLocation>
pub(crate) fn file_location(&self) -> Option<FileLocation>
The file location of a File extent, None otherwise.
Sourcepub(crate) fn note_file_read(&mut self) -> bool
pub(crate) fn note_file_read(&mut self) -> bool
Records a read of the extent’s file, returning whether it was already read since its demotion.
Sourcepub(crate) fn begin_demotion(&mut self, file_slot: FileSlot) -> DemotionSource
pub(crate) fn begin_demotion(&mut self, file_slot: FileSlot) -> DemotionSource
Moves an Arena extent to Demoting toward file_slot and returns
what the demoter’s unlocked write needs. Panics for any other home.
Sourcepub(crate) fn commit_demotion(&mut self, store: Arc<FileStore>, crc: u32)
pub(crate) fn commit_demotion(&mut self, store: Arc<FileStore>, crc: u32)
Commits a demotion whose write succeeded: the extent moves to its
File home with checksum crc, and its arena slot is freed with its
pages discarded. Panics unless the extent is Demoting. The caller
holds the chunk’s state lock, so no reader borrows the arena slot.
Sourcepub(crate) fn abort_demotion(&mut self) -> FileSlot
pub(crate) fn abort_demotion(&mut self) -> FileSlot
Returns a Demoting extent to its Arena home and hands back the
file slot the demotion reserved, for the caller to return to the
store. Panics unless the extent is Demoting.
Sourcepub(crate) fn pageout_capped(&self) -> bool
pub(crate) fn pageout_capped(&self) -> bool
Whether the extent’s pageout retry budget is exhausted: consecutive
incomplete passes reached PAGEOUT_RETRY_CAP, so callers stop
calling Extent::pageout until a read resets the budget.
Heap-fallback extents are permanently capped: they are never advised
out and stay counted resident until freed.
Sourcepub(crate) fn pageout(&mut self) -> bool
pub(crate) fn pageout(&mut self) -> bool
Hints the kernel to push the extent’s pages to the swap device and
observes the result: returns true, marking the extent non-resident,
only when the observation finds the whole range unmapped (a page
whose clean copy lingers in the swap cache counts as reclaimed). An
incomplete pass leaves the extent fully resident for accounting and
spends one unit of the retry budget: a single pinned page keeps the
whole extent counted, which is the safe direction, and the retry
budget exists exactly for such transient pins.
Callers must not invoke this on a Extent::pageout_capped
extent.
Sourcepub(crate) fn prefetch(&self)
pub(crate) fn prefetch(&self)
Hints the kernel to swap the extent’s pages back in ahead of a read.
A no-op for Demoting and File extents: the first is resident, and
the second would need an asynchronous read into a buffer a later read
can claim.
Sourcepub(crate) fn read_into(&mut self, codec: &dyn ExtentCodec, dst: &mut [u8])
pub(crate) fn read_into(&mut self, codec: &dyn ExtentCodec, dst: &mut [u8])
Decodes the extent through codec into dst, which must be exactly
the chunk’s body length. Reading an in-memory extent faults its pages
back in, so it is resident again afterwards. The caller owns the
accounting for that transition (the pool re-counts and re-enqueues it
for the RSS target). A File extent is read per
FileLocation::read_range_into and stays on file.
Sourcepub(crate) fn read_range_into(
&mut self,
codec: &dyn ExtentCodec,
body_len: usize,
offset: usize,
dst: &mut [u8],
)
pub(crate) fn read_range_into( &mut self, codec: &dyn ExtentCodec, body_len: usize, offset: usize, dst: &mut [u8], )
Decodes the byte range [offset, offset + dst.len()) of the
extent’s body_len-byte body into dst. The range must lie within
the body, and body_len must be the body’s exact length (the codec
validates it against the stored form). Residency effects are those
of Extent::read_into regardless of the range: the stored
form is one whole codec block, so any read faults (or reads from
file) and decodes the entire extent, and a sub-range only narrows
the final copy.
Trait Implementations§
Auto Trait Implementations§
impl !Sync for Extent
impl Freeze for Extent
impl RefUnwindSafe for Extent
impl Unpin for Extent
impl UnsafeUnpin for Extent
impl UnwindSafe for Extent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
Source§fn plus_equals(&mut self, rhs: &&'a S)
fn plus_equals(&mut self, rhs: &&'a S)
std::ops::AddAssign, for types that do not implement AddAssign.