Skip to main content

RegistryIndex

Struct RegistryIndex 

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

A flattened lookup index built from one registry subtree. 由一棵注册子树构建的扁平查找索引。

Implementations§

Source§

impl RegistryIndex

Source

pub fn len(&self) -> usize

Number of identities in the flattened index, including every descendant. 扁平索引中的身份总数,包含全部后代。

Examples found in repository?
examples/scale_audit.rs (line 132)
93fn main() {
94    let sizes = std::env::args()
95        .skip(1)
96        .map(|value| value.parse::<usize>().expect("size must be an integer"))
97        .collect::<Vec<_>>();
98    let sizes = if sizes.is_empty() {
99        vec![10_000, 100_000]
100    } else {
101        sizes
102    };
103    println!(
104        "nodes\tregister_ms\tregister_budget_ms\tindex_ms\tindex_budget_ms\tentries\tpages\tstatic_face_bytes"
105    );
106    // 40 µs and 20 µs per node: roughly eight times the 5.2 µs and 2.6 µs measured
107    // for 100 000 nodes when this budget was added.
108    // 每节点 40 µs 与 20 µs:约等于加入本预算时 100 000 个节点实测 5.2 µs 与 2.6 µs 的八倍。
109    let register_ceiling = ceiling("NICHLINK_SCALE_REGISTER_US", 40);
110    let index_ceiling = ceiling("NICHLINK_SCALE_INDEX_US", 20);
111    for size in sizes {
112        let namespace = format!("scale-{size}");
113        let root = Registry::root_for_namespace(FrameworkId::new("nichlink.scale"), &namespace);
114        let parent = root_node_id(&namespace);
115        let submissions = (0..size)
116            .map(|index| snapshot(&namespace, index, parent))
117            .collect::<Vec<_>>();
118        let mut registry = root;
119        let register_start = Instant::now();
120        registry
121            .register_snapshot_batch(submissions)
122            .expect("generated scale batch must register");
123        let register_ms = register_start.elapsed().as_millis();
124        let index_start = Instant::now();
125        let index = registry.index();
126        let index_ms = index_start.elapsed().as_millis();
127        let stats = registry.storage_stats();
128        let register_budget_ms = register_ceiling * size as u128 / 1000;
129        let index_budget_ms = index_ceiling * size as u128 / 1000;
130        println!(
131            "{size}\t{register_ms}\t{register_budget_ms}\t{index_ms}\t{index_budget_ms}\t{}\t{}\t{}",
132            index.len(),
133            stats.pages,
134            size * std::mem::size_of::<nichlink::StaticFace>()
135        );
136        assert!(
137            register_ms <= register_budget_ms,
138            "registering {size} nodes took {register_ms} ms, over the {register_budget_ms} ms              budget ({register_ceiling} µs per node); raise NICHLINK_SCALE_REGISTER_US if this              machine is simply slower, and update docs/performance-baseline.md if the baseline moved"
139        );
140        assert!(
141            index_ms <= index_budget_ms,
142            "indexing {size} nodes took {index_ms} ms, over the {index_budget_ms} ms budget              ({index_ceiling} µs per node); raise NICHLINK_SCALE_INDEX_US if this machine is              simply slower, and update docs/performance-baseline.md if the baseline moved"
143        );
144        let extra = snapshot(&namespace, size, parent);
145        registry
146            .register_snapshot_batch([extra])
147            .expect("incremental transaction must register");
148        assert_eq!(registry.index().len(), size + 2);
149    }
150}

Trait Implementations§

Source§

impl Clone for RegistryIndex

Source§

fn clone(&self) -> RegistryIndex

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RegistryIndex

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for RegistryIndex

Source§

fn default() -> RegistryIndex

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.