-- pg_turbovec v1.27.1 -- Phase Q-4a: parallelize the IVF k-means build. -- Build-SPEED change only. NO shippable behaviour change to a built -- index: the persisted IVF centroids + assignment are BYTE-IDENTICAL -- to v1.27.0 for a fixed (corpus, seed, lists, dim). -- -- This file is a *reference mirror*. The authoritative install script -- is generated by `cargo pgrx schema`. -- -- NO wire-format change (stays VERSION 7), NO SQL-surface change, NO -- REINDEX. Existing indexes are unaffected; this only makes NEW -- IVF (WITH (lists = N)) builds faster. -- -- What changed: two remaining serial hot loops in the k-means build -- were parallelized bit-identically (the rest was already parallel -- from v1.20.0/v1.22.1): -- * gemm_lloyd_assign's per-row nearest-centroid argmin + top-2 -- tie-break -- run every Lloyd iteration over the whole sample -- -- is now a data-parallel par_iter_mut().enumerate() writing each -- assign[i] to a fixed index (byte-identical regardless of thread -- count). -- * rotate_corpus_into's GEMM -- Parallelism::None -> Rayon(0), on -- the same gemm-tiling-never-reduces-across-threads guarantee -- v1.22.1 established for the Lloyd cross-term GEMM. -- Left serial (deliberately): the k-means++ next-seed CDF pick -- (sequential by construction) and the empty-cell reseed scan. -- -- Measured ~1.91x build speedup (lists=4096, n=131072, dim=256, -- 8-core, release) with bit-identical output. Sub-linear because -- Lloyd iterations are sequentially dependent (only within-iteration -- work parallelizes). Bit-identity across pool sizes {1,2,auto} is -- asserted by ivf_coarse_model_bit_identical_across_pool_sizes + -- rotate_corpus_bit_identical_across_pool_sizes. -- -- Migration: `ALTER EXTENSION pg_turbovec UPDATE TO '1.27.1';`. No -- REINDEX -- a no-op upgrade for existing indexes; new IVF builds are -- just faster.