pub(crate) struct SwapExtent {
ptr: *mut u8,
alloc_size: usize,
comp_len: usize,
resident: bool,
incomplete_passes: u8,
backing: Backing,
}pool only.Expand description
One chunk’s compressed backing copy.
Fields§
§ptr: *mut u8§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
SwapExtent::read_into, cleared by a SwapExtent::pageout whose
residency observation found the whole range gone. Drives the pool’s
extent_resident_bytes accounting; mutated only under the owning
chunk’s state mutex.
incomplete_passes: u8Consecutive pageout passes whose observation found pages still
resident. Reset by SwapExtent::read_into. At
PAGEOUT_RETRY_CAP the extent stops being advised out.
backing: BackingImplementations§
Source§impl SwapExtent
impl SwapExtent
Sourcepub(crate) fn write(
arena: &Arc<ExtentArena>,
data: &[u64],
codec: &dyn ExtentCodec,
scratch: Scratch,
) -> SwapExtent
pub(crate) fn write( arena: &Arc<ExtentArena>, data: &[u64], codec: &dyn ExtentCodec, scratch: Scratch, ) -> SwapExtent
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 SwapExtent::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.
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).
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 SwapExtent::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. Cheap: the
compression is already paid, the madvise and page-table read are
microseconds, and the device write happens on the kernel’s
asynchronous writeback path.
Callers must not invoke this on a SwapExtent::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.
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 faults the pages back in, so the
extent is resident again afterwards; the caller owns the accounting
for that transition (the pool re-counts and re-enqueues it for the
RSS target).
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 SwapExtent::read_into regardless of the range: the stored
form is one whole codec block, so any read faults and decodes the
entire extent, and a sub-range only narrows the final copy. A
backend whose stored form is rangeable (file extents reading with
pread, a sub-block-framed codec) can serve the range with
proportional I/O behind this same signature.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SwapExtent
impl RefUnwindSafe for SwapExtent
impl !Sync for SwapExtent
impl Unpin for SwapExtent
impl UnsafeUnpin for SwapExtent
impl UnwindSafe for SwapExtent
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
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,
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.Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
map-response-body only.Source§fn decompression(self) -> Decompression<Self>where
Self: Sized,
fn decompression(self) -> Decompression<Self>where
Self: Sized,
decompression-br or decompression-deflate or decompression-gzip or decompression-zstd only.Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
trace only.Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
trace only.Source§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
follow-redirect only.