Skip to main content

Crate yo_common

Crate yo_common 

Source
Expand description

Shared vocabulary for the whole engine: addresses, ids, the error model, the two hash families, and the cache hint the batch walk is built on.

Everything here is used on the hot path, so the rules are strict. No allocation outside the error path, no dependencies, and every constant that another crate assumes is asserted in a test here rather than assumed twice.

Re-exports§

pub use addr::ADDR_BITS;
pub use addr::Addr;
pub use addr::MAX_OFFSET;
pub use addr::OFFSET_BITS;
pub use addr::SPACE_BITS;
pub use addr::ShardId;
pub use addr::Space;
pub use crc::SLOT_COUNT;
pub use crc::crc16;
pub use crc::crc32c;
pub use crc::hash_tag;
pub use crc::slot_of;
pub use eq::bytes_eq;
pub use error::Code;
pub use error::Error;
pub use error::Result;
pub use glob::matches as glob_matches;
pub use num::DIGITS_MAX;
pub use num::i64_digits;
pub use num::i64_len;
pub use num::parse_i64;
pub use num::push_double;
pub use num::push_i64;
pub use num::push_u64;
pub use num::u64_digits;
pub use prefetch::prefetch;
pub use prefetch::prefetch_read;
pub use rng::Rng;
pub use small::Small;
pub use wyhash::hash_key;
pub use wyhash::tag_of;
pub use wyhash::wyhash;
pub use xxh3::hash64;

Modules§

addr
The 56 bit address: a 4 bit space and a 52 bit offset.
blake3
BLAKE3, the hash the shape tag is made of (15 section 3.1).
crc
CRC16 for slot placement, CRC32C for integrity, CRC64 for the file format.
dtoa
Redis’s double printer, which is Grisu2 by way of fpconv.
eq
Comparing two byte strings without leaving the function.
error
The error model. P5: errors are values with structure, never a string a caller has to parse.
glob
Redis’s glob matching, which is what KEYS, SCAN MATCH, CONFIG GET and COMMAND LIST FILTERBY PATTERN all mean by a pattern.
num
Numbers to text and back, written by hand.
prefetch
Telling the cache what the next walk is going to want.
re
A POSIX extended regular expression matcher over bytes.
rng
A random number generator you can write down.
small
A list that stays on the stack until it does not fit.
wyhash
wyhash, the shard’s key hash.
xxh3
XXH3, the 64 bit form, with the default secret and no seed.

Constants§

BATCH_MAX
The largest batch the shard loop drains in one pass (04 section 3).
CACHE_LINE
The size of an index bucket, and the cache line the engine is built around.