#[non_exhaustive]pub struct LifecycleStorage {
pub engine_vertices: usize,
pub retired_vertices: usize,
pub catalog_nodes: usize,
pub catalog_node_capacity: usize,
pub incident_entries: usize,
pub incident_capacity: usize,
}Expand description
Storage diagnostics of a LifecycleGraph, from
LifecycleGraph::storage_stats.
Logical sizes and retained capacities are reported separately: vectors and hash maps keep capacity after removals, so capacity can exceed the logical size. Capacities count elements, not bytes, and exclude allocator overhead and the inner engine’s own capacities.
The type, its six fields and its trait implementations are stable. It is
#[non_exhaustive]: a minor release may add fields, but none of these is
removed or changes meaning or unit in 1.x.
§Guaranteed
For a value s returned by g.storage_stats():
- Every field is a count of elements (entries, vertices or slots), never bytes.
- The values are computed at the call;
sis a copy that does not follow later mutations ofg. s.catalog_nodes == g.node_count(),s.engine_vertices == g.engine_vertex_count(),s.engine_vertices == s.catalog_nodes + s.retired_verticesands.incident_entries == 2 * g.edge_count()(registered edges, enabled or not, counted at both endpoints).s.catalog_node_capacity >= s.catalog_nodesands.incident_capacity >= s.incident_entries.s.engine_vertices <= 2 * s.catalog_nodes + 1024, the bound ofLifecycleGraph::engine_vertex_count.- On a graph with no registered node and no removal (for example a new
one),
engine_vertices,retired_vertices,catalog_nodesandincident_entriesare0.
§Implementation-dependent
The capacities (initial values, growth, what is retained after removals and catalog rebuilds), and how many retired slots exist below the bound above, that is when retired slots are compacted, depend on the implementation, the operation history and the standard library’s growth policy, and may change in any release. None of the values measures heap usage or RSS.
§Examples
use knotrel_core::{EngineConfig, LifecycleGraph};
let mut graph = LifecycleGraph::new(EngineConfig::CompactBfs)?;
graph.link(1, 2)?;
graph.link(2, 3)?;
assert!(graph.remove_node(3));
let storage = graph.storage_stats();
assert_eq!(storage.catalog_nodes, graph.node_count());
assert_eq!(storage.incident_entries, 2 * graph.edge_count());
assert_eq!(
storage.engine_vertices,
storage.catalog_nodes + storage.retired_vertices
);
assert!(storage.incident_capacity >= storage.incident_entries);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.engine_vertices: usizeVertices held by the inner engine, including retired slots.
retired_vertices: usizeRetired engine slots of removed nodes not yet compacted.
catalog_nodes: usizeRegistered nodes in the catalog.
catalog_node_capacity: usizeCapacity of the catalog’s node map (elements).
incident_entries: usizeIncidence entries in the catalog: two per registered edge.
incident_capacity: usizeSum of the incident vectors’ capacities (elements).