Skip to main content

yo_common/
lib.rs

1//! Shared vocabulary for the whole engine: addresses, ids, the error model,
2//! the two hash families, and the cache hint the batch walk is built on.
3//!
4//! Everything here is used on the hot path, so the rules are strict. No
5//! allocation outside the error path, no dependencies, and every constant that
6//! another crate assumes is asserted in a test here rather than assumed twice.
7
8#![deny(missing_docs)]
9
10pub mod addr;
11pub mod blake3;
12pub mod crc;
13pub mod dtoa;
14pub mod eq;
15pub mod error;
16pub mod glob;
17pub mod num;
18pub mod prefetch;
19pub mod re;
20pub mod rng;
21pub mod small;
22pub mod wyhash;
23pub mod xxh3;
24
25pub use addr::{ADDR_BITS, Addr, MAX_OFFSET, OFFSET_BITS, SPACE_BITS, ShardId, Space};
26pub use crc::{SLOT_COUNT, crc16, crc32c, hash_tag, slot_of};
27pub use eq::bytes_eq;
28pub use error::{Code, Error, Result};
29pub use glob::matches as glob_matches;
30pub use num::{
31    DIGITS_MAX, i64_digits, i64_len, parse_i64, push_double, push_i64, push_u64, u64_digits,
32};
33pub use prefetch::{prefetch, prefetch_read};
34pub use rng::Rng;
35pub use small::Small;
36pub use wyhash::{hash_key, tag_of, wyhash};
37pub use xxh3::hash64;
38
39/// The size of an index bucket, and the cache line the engine is built around.
40///
41/// Everything that claims to be one cache line asserts against this rather than
42/// writing 64 twice.
43pub const CACHE_LINE: usize = 64;
44
45/// The largest batch the shard loop drains in one pass (`04` section 3).
46///
47/// This is also the C ABI's `BATCH_MAX` and the size of every `_many` form, so
48/// it is here rather than in the shard crate.
49pub const BATCH_MAX: usize = 64;