pub struct StorageProfile {
pub seek_latency_s: f64,
pub sequential_bandwidth_bps: f64,
pub block_bytes: u64,
}Expand description
Parameters of a storage medium, expressed in the units the cost model needs.
The two parameters that matter most on non-uniform storage are the seek latency (the fixed price of positioning at a read) and the sequential bandwidth (the marginal price per byte once positioned). On a 7200rpm HDD the former dominates the latter by orders of magnitude, which is precisely why minimizing seek count — not bytes, and not graph hops — is the lever.
Classical in-RAM ANN implicitly assumes StorageProfile::memory, where the
seek latency is ~0 and bandwidth is effectively unbounded; under that profile
the storage-access term vanishes and only graph hops remain. Slate-ANN takes
the profile as an input instead.
Fields§
§seek_latency_s: f64Latency to position at a fresh random read, in seconds.
For an HDD this is head-seek plus average rotational latency; for an SSD it is a small controller/queue constant; for RAM it is ~0.
sequential_bandwidth_bps: f64Sustained sequential transfer rate, in bytes per second.
block_bytes: u64Natural transfer granularity of the medium, in bytes.
Reads smaller than this still pay for at least this many bytes of transfer (HDD sector / SSD page / OS page). Used when pricing a read whose payload is smaller than one block.
Implementations§
Source§impl StorageProfile
impl StorageProfile
Sourcepub const fn hdd_7200rpm() -> Self
pub const fn hdd_7200rpm() -> Self
A representative 7200rpm consumer hard disk drive.
~9 ms seek (≈4.2 ms average rotational latency at 7200rpm plus head seek), ~160 MB/s sequential, 4 KiB minimum transfer. This is the headline target medium: the regime where the uniform-latency assumption is most catastrophically wrong.
Sourcepub const fn ssd_nvme() -> Self
pub const fn ssd_nvme() -> Self
A representative consumer NVMe solid-state drive.
~100 µs effective random-access latency, ~3.5 GB/s sequential, 4 KiB page. Random reads are cheap here, which is why SSD-tuned designs (e.g. DiskANN) can afford one small random read per hop.
Sourcepub const fn memory() -> Self
pub const fn memory() -> Self
Resident memory: the implicit medium of classical in-RAM ANN.
Negligible seek, very high bandwidth, cache-line granularity. Under this
profile QueryCost::storage_access_s is ~0 and query cost is dominated
by traversal and distance computation — the classical special case.
Sourcepub fn transfer_s(self, bytes: u64) -> f64
pub fn transfer_s(self, bytes: u64) -> f64
Seconds to transfer bytes at the medium’s sequential bandwidth.
This is the honest transfer time for an already-summed byte count: zero
bytes costs zero. Per-read block-granularity flooring lives in
read_s, since “a read smaller than a block still pays
for a block” is a property of an individual read, not of an aggregate.