Go · Introspection

Introspection

import "github.com/unum-cloud/USearch/golang" 3.0.0-rc.1 · 4c3e5023

description, _ := index.Describe()
fmt.Println(description.Metadata.Dimensions, description.Size, description.Capacity,
	description.MemoryUsage, description.Capabilities) // the codename dispatch picked on this machine

found, _ := index.Contains(usearch.KeyFromUint64(42))
count, _ := index.Count(usearch.KeyFromUint64(42)) // entries sharing one key

reachability, _ := index.Health()
fmt.Println(reachability.Reachable, "of", reachability.Audited, "entries reachable")

fmt.Println(usearch.Version(), usearch.CapabilitiesCompiled(), usearch.CapabilitiesAvailable())

Health audits how much of the graph a search reaches from its landmarks; entries it misses stay unfound until a Refine re-links them.

API

Types

DenseIndexDescriptionDenseIndexDescription is a live index's frozen metadata and current counters, each read once, so under concurrent insertions they may come from slightly different moments.
types.go:155 ↗
type DenseIndexDescription struct {
    Metadata DenseMetadata
    Size uint
    Capacity uint
    MemoryUsage uint
    CPUClass string
    GPUClass string
    ShardsCount uint
}

Fields

MetadataDenseMetadataMetadata is the frozen metric, quantization, dimensions and connectivity, as a checkpoint reports them.
SizeuintSize is the number of stored entries.
CapacityuintCapacity is the number of entries hosted without growing again.
MemoryUsageuintMemoryUsage is the bytes the handle holds; traversal scratch is the executor's.
CPUClassstringCPUClass is the CPU class dispatch picked on this machine, as CPUClass.String spells it.
GPUClassstringGPUClass is the GPU class dispatch picked on the index's devices; "unknown" for a host index.
ShardsCountuintShardsCount is the number of live shards.
DenseReachabilityDenseReachability is one reachability audit: the population it judged, and how much of it a search reaches.
types.go:203 ↗
type DenseReachability struct {
    Audited uint
    Reachable uint
    Sweeps uint
    BackSweeps uint
}

Fields

AuditeduintAudited counts the entries published when the audit started; compare Reachable against this, never a later size.
ReachableuintReachable counts those a search reaches; the rest no search finds until a refinement re-links them.
SweepsuintSweeps counts the levels the sweep took to converge.
BackSweepsuintBackSweeps counts the levels the sweep back toward the entry point took, where an audit sweeps both ways.
EnumCPUClassCPUClass is a CPU family USearch ships tuned variants for; a RAM or NVMe placement or executor may pin one, and the zero value pins none.1
types.go:630 ↗
type CPUClass int32

Values

CPUClassUnknownCPUClassUnknown pins nothing, so dispatch derives the CPU's own class.
CPUClassSerialCPUClassSerial is the portable floor, with no SIMD assumptions.
CPUClassIntelHaswellCPUClassIntelHaswell is Haswell-class x86: AVX2 and FMA.
CPUClassIntelSierraCPUClassIntelSierra is Sierra Forest-class x86: AVX-VNNI without AVX-512.
CPUClassIntelSkylakeCPUClassIntelSkylake is Skylake-class x86: the AVX-512 foundation.
CPUClassIntelIcelakeCPUClassIntelIcelake is Icelake-class x86: AVX-512 VNNI and VPOPCNT.
CPUClassAmdGenoaCPUClassAmdGenoa is Genoa-class x86: native bf16 dot products over AVX-512.
CPUClassIntelSapphireCPUClassIntelSapphire is Sapphire Rapids-class x86: AVX-512 FP16 and the AMX tiles.
CPUClassIntelGraniteCPUClassIntelGranite is Granite Rapids-class x86: the AMX-FP16 tiles.
CPUClassIntelDiamondCPUClassIntelDiamond is Diamond Rapids-class x86: AVX10.2's FP8 conversions.
CPUClassAwsG2CPUClassAwsG2 is Graviton2-class Arm: the bare NEON floor.
CPUClassAppleM2CPUClassAppleM2 is Armv8.6 NEON with dot products and bf16.
CPUClassAppleM4CPUClassAppleM4 is Apple M4-class Arm: the SME outer-product tiles.
CPUClassAwsG5CPUClassAwsG5 is Graviton5-class Arm: Armv9.2.
CPUClassNvidiaVeraCPUClassNvidiaVera is Vera-class Arm: FP8 dot products.
CPUClassAlibabaC930CPUClassAlibabaC930 is Alibaba C930-class RISC-V: RVA23 vectors.
CPUClassWasm32V128CPUClassWasm32V128 is WebAssembly with fixed-width simd128.
CPUClassWasm64ExtendedCPUClassWasm64Extended is WebAssembly with relaxed SIMD, threads and 64-bit addressing.
CPUClassMonoversionedCPUClassMonoversioned is the one class of a monoversioned build.
*String× 2String renders the class as the library spells it.
types.go:674 ↗
func (class CPUClass) String() string
EnumGPUClassGPUClass is a GPU family USearch ships tuned variants for; a VRAM placement or executor may pin one, and the zero value pins none.
types.go:680 ↗
type GPUClass int32

Values

GPUClassUnknownGPUClassUnknown pins nothing, so dispatch derives the devices' own class.
GPUClassNvidiaAmpereGPUClassNvidiaAmpere is Ampere-class NVIDIA, and every NVIDIA GPU without a class of its own.
GPUClassNvidiaAdaGPUClassNvidiaAda is Ada-class NVIDIA: the fp8 conversions.
GPUClassNvidiaHopperGPUClassNvidiaHopper is Hopper-class NVIDIA.
GPUClassNvidiaBlackwellGPUClassNvidiaBlackwell is Blackwell-class NVIDIA.
GPUClassNvidiaBlackwellRTXGPUClassNvidiaBlackwellRTX is Consumer Blackwell NVIDIA.
GPUClassNvidiaRubinGPUClassNvidiaRubin is Rubin-class NVIDIA.
GPUClassAmdCDNA3GPUClassAmdCDNA3 is CDNA3 AMD: gfx942.
GPUClassAmdCDNA4GPUClassAmdCDNA4 is CDNA4 AMD: gfx950.
GPUClassAmdCDNA5GPUClassAmdCDNA5 is CDNA5 AMD: gfx1250.
GPUClassAppleMetal7GPUClassAppleMetal7 is Apple7-family GPUs, and every Apple GPU without a class of its own.
GPUClassAppleMetal9GPUClassAppleMetal9 is Apple9-family GPUs.
GPUClassAppleMetal10GPUClassAppleMetal10 is Apple10-family GPUs.

Functions

CapabilitiesAvailableCapabilitiesAvailable lists the hardware capabilities the current machine offers at runtime, comma separated.
usearch.go:1099 ↗
func CapabilitiesAvailable() string
CapabilitiesCompiledCapabilitiesCompiled lists the hardware capabilities the linked binary was compiled with, comma separated.
usearch.go:1095 ↗
func CapabilitiesCompiled() string
VersionVersion reports the version of the linked library.
usearch.go:1091 ↗
func Version() string