v0.7.1
The native protocol silently created the wrong index type
From the changelog · release notes and binaries
x86 support for the SIMD kernels, validated on real hardware for the first time, and a cleanup pass over the engine that turned up a data-loss bug.
Fixed
-
The native protocol silently created the wrong index type. Its wire contract documents three kinds (0 f32, 1 int8, 2 binary), but the server passes that byte to the shared six-value table, where 3 is TQ1. Byte 3 was historically PQ, so a native client asking for PQ got a TurboQuant 1-bit index instead: no error, a different index. Native v1 now refuses kind 3 and says where to go, and the TurboQuant tiers are reachable through native v2, which states its kind map explicitly. Nothing about a v1 byte changed meaning.
-
Consolidate dropped vectors staged by an in-flight flush.
flush_beginmoves the delta into a staging map and releases the write lock while the new segment builds off-thread; aSKEG.VINDEX.CONSOLIDATEarriving in that window foldeddelta > runs > base, skipping the staging map, then truncated the WAL and reopened from disk. The staged vectors were left in neither the rebuilt graph, the log, nor memory. Silent: no error, no crash, the ids simply stopped being found. The fold now follows the documented precedence,delta > flushing > runs > base. -
A wrong vector dimension aborted a shard thread.
DiskVamanaIndex::insertand the search path asserted on a dimension mismatch, so one client’s bad request could take down a thread serving every other vindex on that shard. Both already returnedio::Result; they now returnInvalidInput. The flat backend is guarded at the seam, where its signature cannot change. -
NaN was bucketed to the top instead of the bottom on AVX-512 builds.
bucketize_x8_avx512used an unordered compare as if it were an ordered>, which is true for NaN, so any vector containing one was silently mis-encoded. Only on AVX-512 builds, only on x86. It had passed clippy, an assembly read-through and an instruction-selection guard in CI; executing it on x86 found it in one run. -
Public SIMD kernels did not enforce the preconditions their dispatchers checked.
skeg-simdexports the individual kernels, not only the dispatchers, and eleven of them index withget_uncheckedor raw pointer loads. They took a loop bound from one slice and read from another, assumed a bit-packed layout, or relied on adebug_assertthat a release build compiles away:tq1_masked_sum_neongiven a short slice aborted the process instead of panicking, and a non-power-of-two length walked the FWHT butterfly stages off the end of its slice. The ADC entry points had a related gap, accepting a dimension with no packed representation at all, becausedim * BITS / 8truncates to zero fordim = 1. Every caller inside the workspace goes through a dispatcher or a quantizer that validates, so the engine was not exposed; a directskeg-simduser was. Each public kernel now validates for itself through the same helper its dispatcher uses, and the FWHT and bit-plane preconditions are runtime asserts rather than debug-only ones. Verified by walking every public path to an unchecked access: 47 reach one, none through an unguarded route. -
The AVX-512 ADC declared fewer target features than it uses. The kernel is compiled with AVX-512F, BW, VL and SSSE3, but the tq4 wrapper declared two of those and the tq2 wrapper three, and the tq4 dispatcher did not check SSSE3. Zen 4 and Zen 5 have all four so nothing surfaced there, but a CPU with a partial combination, or a caller following the documented contract of the unsafe entry point, could execute an instruction it does not have. All five sites now read one shared predicate,
avx512_adc_supported. -
VSEARCH had two separately written paths, one for the worker pool and one inline. They agreed, but nothing kept them agreeing, and a fix applied to one and not the other would surface only where
workers > 0. Now one path, with the equivalence test extended to cover filters and payloads. -
The io_uring batch reader rebuilt its ring on every call, an
io_uring_setupplus two mmaps and two munmaps per batch, which erased the overlap it exists for. With the ring reused, a cold batch of 800 reads costs 3.5 us per read againstpread’s 100 us; the backend had measured slower thanpreadbefore the fix.
Added
-
Native protocol v2, negotiated rather than assumed. The 24-byte frame header already carried a version byte; the parser now accepts 1 and 2, and every response goes back at the request’s version.
NativeHelloreports what the server supports. The default encoder still emits v1, so existing clients are untouched. -
AVX2 and AVX-512 kernels for x86, dispatched at runtime, with the
avx512feature off by default. AVX-512 is selected only where the wider instruction set offers something AVX2 lacks: VNNI for the int8 dot, VPOPCNTDQ for Hamming, mask registers for tq1 and sign flips, and a register-resident 16-entry table for the ADC. Where it is only the same trick at twice the width it loses on cores that split 512-bit operations, so those kernels ship built and tested but not dispatched. -
NEON kernels for the rotation path (
fwht_f32,flip_signs,bucketize_x8), which ran scalar on aarch64. At dim 1536 on an M1 Pro:flip_signs950 ns to 157 ns,bucketize_x86.22 us to 1.59 us,fwht_f321.94 us to 1.39 us. -
A batch-read seam in the platform layer with a blocking implementation and an optional
io_uringone, pluspreallocate_sync,write_vectored_at_sync,advise_hugeandopen_populated. The vLog preallocates and fsyncs segments through it. -
An x86_64 release. The tarball matrix gains
x86_64-unknown-linux-gnu, and the container image now publisheslinux/amd64alongsidelinux/arm64under one manifest, sodocker pullresolves the architecture by itself. Both carry the AVX-512 kernels: kernel selection is a runtime CPU check, so a machine without AVX-512 simply never picks them. The x86 CI job runs that build on an AVX2-only runner, which is what turns “carries the kernels” into something other than a claim. The Cargo feature stays opt-in, because compiling those kernels needs Rust 1.89 and the MSRV promised to people building from source is 1.88. -
A kernel coverage test: which kernel exists for which instruction set and which one the dispatcher picks. A gap has to carry a reason, and a kernel that exists but loses to its neighbour is recorded as present-but-not-chosen rather than as coverage.
Changed
-
Only one workflow publishes the container image.
release.ymlanddocker-publish.ymlboth fired on av*tag and both pushedghcr.io/skegdb/skeg:<version>and:latest; the one that finished last won. The images were identical, so it never showed. It would have started showing now that one of them publishes a multi-architecture manifest and the other an arm64-only image.release.ymlstill builds the Dockerfile, to fail the release run if it is broken, but no longer pushes. -
The ADC kernels keep their centroid table in a register and permute it instead of gathering it from memory and unpacking codes in a scalar loop. At dim 1536 on a Zen 4 EPYC the AVX-512 kernel went from 464 ns to 63.7 ns and AVX2 from 431 ns to 147 ns, so machines without AVX-512 gain too. End to end on 99k vectors, an AVX-512 build serves tq2 and tq4 36% to 61% more queries per second than an AVX2 one, at identical recall and RSS.
-
Flat 4-bit TurboQuant search uses the block-32 kernel, which scores 32 rows against one pre-computed table: 939 ns against 11.9 us for the scalar reference at dim 1536. Same candidate width and same exact-f32 rerank, so the answer is unchanged.
-
One ADC kernel per instruction set over a code-width parameter, instead of one per tier, so a technique fix lands once per instruction set. Kernels are grouped by operation, each module holding every instruction set for it.
-
One source of truth for the quantization wire encoding (
QuantKind::from_wire/to_wire/wire_kinds), replacing four hand-written byte tables. The byte values are unchanged and now pinned by a test, because on-disk registries written by earlier versions depend on them. -
The idle maintenance decision is a named function, not a 110-line closure nested inside the shard loop. It chooses flush against consolidate against runs-merge against delete-patch, so it is what gets read during a memory or latency incident, and it used to appear in traces as an anonymous closure.
Removed
crossbeam-channelandlz4_flexfrom the workspace manifest. Neither was referenced by any crate or any source file.
Versions bumped
skeg-proto0.2.0. A breaking bump for a 0.x crate:Op,ParseError,ErrCodeandNativeVectorKindV2gained variants, which breaks an exhaustivematchin another crate. All four are now#[non_exhaustive], so the next op, error code or kind is an additive change instead of another breaking one. It costs nothing here: the server’s dispatch already ends in a catch-all, because a wire protocol has to answer an op it does not know.skeg-simd0.1.6,skeg-platform0.1.5,skeg-core0.3.4,skeg-telemetry0.2.2,skeg-vector0.1.8,skeg-server0.7.1,skeg-server-tenant0.2.4