sled/pagecache/
constants.rs

1use super::*;
2
3// crc: u32 4
4// kind: u8 1
5// seg num: u64 9 (varint)
6// pid: u64 9 (varint)
7// len: u64 9 (varint)
8/// Log messages have a header that might eb up to this length.
9pub const MAX_MSG_HEADER_LEN: usize = 32;
10
11/// Log segments have a header of this length.
12pub const SEG_HEADER_LEN: usize = 20;
13
14/// The minimum number of items per segment.
15/// Items larger than this fraction of an `io_buf`
16/// will be stored as an off-log blob.
17pub const MINIMUM_ITEMS_PER_SEGMENT: usize = 4;
18
19/// During testing, this should never be exceeded.
20#[allow(unused)]
21pub const MAX_SPACE_AMPLIFICATION: f64 = 5.;
22
23pub(crate) const META_PID: PageId = 0;
24pub(crate) const COUNTER_PID: PageId = 1;
25pub(crate) const BATCH_MANIFEST_PID: PageId = PageId::max_value() - 666;
26
27pub(crate) const PAGE_CONSOLIDATION_THRESHOLD: usize = 10;
28pub(crate) const SEGMENT_CLEANUP_THRESHOLD: usize = 50;
29
30// Allows for around 1 trillion items to be stored
31// 2^37 * (assuming 50% node fill, 8 items per leaf)
32// and well below 1% of nodes being non-leaf nodes.
33#[cfg(target_pointer_width = "64")]
34pub(crate) const MAX_PID_BITS: usize = 37;
35
36// Allows for around 32 billion items to be stored
37// 2^32 * (assuming 50% node fill of 8 items per leaf)
38// and well below 1% of nodes being non-leaf nodes.
39// Assumed to be enough for a 32-bit system.
40#[cfg(target_pointer_width = "32")]
41pub(crate) const MAX_PID_BITS: usize = 32;