heapdump_vmo::resources_table_v1

Struct ResourcesTableWriter

Source
pub struct ResourcesTableWriter { /* private fields */ }
Expand description

Mediates write access to a VMO containing compressed stack traces and thread info structs.

Compressed stack traces are stored as a hash table for efficient deduplication. Thread information structures are not deduplicated (it is expected that deduplication happens at a higher level in the stack). Apart from the hash table’s bucket heads, all data is immutable: neither stack traces nor thread info structs can be modified or deleted after having been inserted.

Hash collisions are handled by maintaining per-bucket linked lists. Specifically, an array of list heads, one for each bucket, is stored at the beginning of the VMO. The remaining part of the VMO contains the linked list nodes. Since nodes are immutable, insertion always happen at the head of the list.

Thanks to the fact that inserted data is immutable, other readers are allowed to read data from this VMO while ResourcesTableWriter is still alive. In particular, all insertion functions return a ResourceKey, which is simply the offset of the just-inserted now-immutable data, and that can be used by ResourcesTableReader to read data back without even having to know about the hash table.

Implementations§

Source§

impl ResourcesTableWriter

Source

pub fn new(vmo: &Vmo) -> Result<ResourcesTableWriter, Error>

Initializes a VMO as an empty table and creates an AllocationsTableWriter to write into it.

The caller must guarantee that the vmo is not accessed by others (unless they use ResourcesTableReader instances) while the returned instance is alive.

Source

pub fn intern_compressed_stack_trace( &mut self, compressed_stack_trace: &[u8], ) -> Result<(ResourceKey, bool), Error>

Appends a compressed stack trace and returns its offset into the VMO.

This function also applies deduplication: if a copy of the given stack trace is already present, the offset of the existing copy is returned without modifying the VMO contents.

Source

pub fn insert_thread_info( &mut self, koid: zx_koid_t, name: &Name, ) -> Result<ResourceKey, Error>

Appends a thread information entry and returns its offset into the VMO.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.