Swift · Residency

Residency

import USearch 3.0.0-rc.1 · 4c3e5023

Where the payload lives is the constructor’s name, as in the C lifecycle verbs, so a residency an index lacks has no constructor to call. initRam and initVram start empty, loadRam, loadVram and their Buffer forms copy a checkpoint in, and viewRam and viewNvme serve one in place. Each takes only the placement its own hardware has, one shard per named memory domain, device, or path, and an empty list derives the placement from the machine:

let inRam = try DenseIndex.initRam(options, memoryDomains: [0, 1])          // one graph per socket
let inVram = try DenseIndex.initVram(options, devices: [0, 1])              // sharded, never replicated
let onNvme = try DenseIndex.viewNvme("index.safegraphs.json", config: DenseViewNvmeConfig(paths: ["/mnt/nvme0"]))

An NVMe index serves a checkpoint in place, so it is only ever viewed, and until NVMe checkpoints carry keys, viewNvme reports unsupported. Placement never comes back out of a checkpoint, which records where it was written, never where a reader must keep it, so metadataRead answers a DenseMetadata naming dimensions, metric, quantization and connectivity alone. valuesPerKey is absent from it too, bounding a live handle’s mutable state rather than the serialized form.

API

StructResidencyWhere an executor computes, and with it where the arenas it makes keep their memory.5
Types.swift:880 ↗
struct Residency

Conforms to

Hashable, Sendable, CustomStringConvertible, Equatable
ramHost memory, walked by host threads.
Types.swift:885 ↗
static let ram: Residency
vramDevice memory, walked by device streams; no host read reaches it.
Types.swift:887 ↗
static let vram: Residency
nvmeNVMe drives, read through host submission rings into host memory.
Types.swift:889 ↗
static let nvme: Residency
descriptionThe residency rendered as the library spells it.
Types.swift:892 ↗
var description: String { get }
initReads a spelling back, and nil for one no residency carries.
Types.swift:895 ↗
init?(name: String)