GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — GigaMap/jvector: compression formats, in-memory PQ scoring, and jvector 4.0.0-rc.9 by fh-ms · Pull Request #834 · eclipse-store/store Conversation
|
| Vectors | Switch duration |
|---|---|
| 5,000 | ~2 s |
| 10,000 | ~4 s |
| 20,000 | ~6-9 s |
| 25,000 | ~10 s |
| 50,000 | ~14-19 s |
| 1,000,000 | several minutes |
It happens at most once per index generation. What makes it worth planning for is that it is triggered by the background optimization, so on a large index it arrives at a moment nobody chose. Treat it as a full stop on that GigaMap for the duration rather than as a write pause: call optimize() explicitly at a quiet point, and size optimizationIntervalMs and minChangesBetweenOptimizations with the table in mind. This is a cost, not a defect - but it belongs in the release note rather than in a surprise.
Two independent dimensions of the on-disk format replace the single enablePqCompression boolean, which could say whether PQ codes were fused into the graph but nothing about how the vectors beside them were stored:
vectorStorage - INLINE (default) or NVQ, how each vector is storedapproximateScoring - NONE (default), FUSED_PQ or PQ_IN_MEMORY, how traversal scores candidatesEvery combination is legal. enablePqCompression remains as a deprecated literal delegate for approximateScoring(b ? FUSED_PQ : NONE), writing the same field, so the two spellings cannot disagree - the last call wins.
NVQ is the first setting that makes an index smaller. FUSED_PQ enlarges the .graph: it duplicates each node's code maxDegree times on top of full-precision inline vectors, buying traversal speed at the cost of space. NVQ stores 8-bit quantized vectors instead. At dimension 768 and maxDegree 32, per node:
| configuration | bytes/node on disk | note |
|---|---|---|
INLINE + FUSED_PQ |
9,352 | fastest traversal, largest file |
INLINE + NONE |
3,208 | today's default |
NVQ + FUSED_PQ |
7,080 | |
NVQ + PQ_IN_MEMORY |
936 | approximate traversal intact, codes in heap |
Measured 18.8 MB against 64.2 MB over 20,000 vectors, a 3.4x reduction.
Scores stay exact under every combination. Reranking compares against the full-precision vectors held in the GigaMap, so the top-k a search returns carries exact similarities and exact ordering. What quantization changes is which candidates traversal finds on the way there.
NVQ costs time at write, since quantizing fits each vector's nonlinearity by a grid search on the persist path - about 3x sequentially, about 1.2x under the parallel writer, because the encode then runs per node on the writer's worker threads. Pair NVQ with parallelOnDiskWrite(true).
PQ_IN_MEMORY trades disk for heap. The same codes kept once instead of maxDegree times: for an on-disk index in a {indexName}.pqv sidecar read into heap at load, for an in-memory index built at optimization with no file at all. The heap term is linear and has no ceiling - pqSubspaces bytes for every ordinal up to the highest in use, deletion holes included, resident while the index is open. Roughly 192 MB per million vectors at dimension 768, roughly 19 GB at a hundred million. Size it before choosing it over FUSED_PQ, which pays in disk and page cache instead.
In-memory indices can use compressed scoring too. PQ_IN_MEMORY is the one PQ-based mode an in-memory index can use, and it is worth having: profiling shows about 2,000 vector lookups per insertion during construction and well over a thousand distinct lookups per query during search, all of which scoring from in-heap codes removes. An index cannot start compressed, so the switch is a rebuild and happens at optimization - which is why the mode requires optimizationIntervalMs > 0, rejected at build time otherwise. isPqCompressionActive() reports which side of the switch an index is on.
New preset: forCompactLargeDataset. forLargeDataset is unchanged and produces exactly the graph it produced before.
INLINE graph with no fused codes keeps its feature-less fast path and writes byte-identical files.null and keeps its setting from the retained legacy boolean, so an existing PQ-enabled index does not silently lose PQ on upgrade. A test forces that shape by reflection and fails without the guard.INLINE + NONE.NaN or an infinity is now refused with an IllegalStateException instead of being indexed. Previously one such component could make a quantized index return nothing at all, permanently - the quantizer fits its parameters to the data, so the value propagated into every vector the graph stored, and removing the entity did not heal it because the quantizer is adopted from the loaded graph rather than retrained. Measured on NVQ + NONE: ten hits before the persist that trains the quantizer, zero after and zero thereafter. An application whose embedding function can divide by a zero norm will now see the failure at the point that causes it.268 tests on the default profile and 175 with -P slow-tests, no failures, run with surefire.rerunFailingTestsCount=0 so nothing is masked by a retry. Full reactor build green; gigamap/codegen-test and demos/product-recommendations build and test green against the merged tip.
Recorded during review, none of them regressions introduced here:
searchDiskIndex has no reachable caller - an on-disk index is always in incremental mode - so the non-incremental disk search and its searcher-pool setup are dead code. Documented as unreached rather than removed, because whether it is a latent bug or a deliberately dormant path is a design question the code does not answer.ARCHITECTURE.md describes inconsistently.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
* GigaMap/jvector: update jvector to 4.0.0-rc.9 jvector 4.0.0-rc.8 initialises GraphSearcher.pruneSearch to true, enabling a TopK and filtered-search pruning heuristic that upstream classified as recall-destructive and permanently disabled in 4.0.0-rc.8-hf1 (datastax/jvector#682), carried forward into rc.9 (datastax/jvector#686). Both of this module's search invocations run the affected paths: the TopK path searches with threshold 0, and the on-disk path with deletions searches under restrictive accept bits, which is the case upstream's defect report names explicitly. rc.9 supersedes the hf1 hotfix rather than merely matching it, so the intermediate bump is skipped. In rc.9 the pruneSearch field is initialised to false, usePruning(boolean) ignores its argument and is deprecated, and the field is never read on the search path. The bump is a one-line change with no source change and no on-disk migration. OnDiskGraphIndex.CURRENT_VERSION is 6 and MAGIC is -62111 in both versions, and the class diff is purely additive, so an index written by either version loads and searches correctly under the other and a rollback stays readable. Adopting rc.9 was previously blocked by a deterministic failure of VectorIndexDiskTest#testShutdownDoesNotRebuildGraphInIncrementalMode. That was not an rc.9 regression. Under rc.8 the shutdown path was about to write a zero-vector graph over a valid one, and jvector's header writer threw a NullPointerException on the null entry node of an empty graph, which the shutdown path swallowed into an ERROR log; the bad write never reached the file and the test passed for the wrong reason. rc.9 supports empty graphs, so the write succeeded and the test correctly failed. The underlying defect is fixed by 958e060, so the test now passes on rc.9 for the right reason. Verified on this change: 245 tests green on the default profile and 133 with -P slow-tests, no failures, and gigamap/codegen-test, demos/product-recommendations and examples/gigamap all still build. A recall probe across both versions (4000 vectors, dim 256, degree 16, clustered data, 100 queries, recall@10 against brute force) measured no difference beyond noise, so this is prevention rather than the repair of a regression observable at these scales. Upstream observed the damage at larger scales and other score distributions, which is the regime GigaMap targets. * GigaMap/jvector: align the architecture notes with the bumped jvector version The module documentation pinned 4.0.0-rc.8 in two places, so the bump left it contradicting the version the build actually resolves.
…nsions (#827) * GigaMap/jvector: express the on-disk format as two configuration dimensions The on-disk format is about to grow a second dimension. Today enablePqCompression is a single boolean, which can say whether Product Quantization codes are fused into the graph but nothing about how the vectors beside them are stored. A boolean cannot carry that, so the setting becomes two enums: vectorStorage for how each vector is stored, and approximateScoring for how traversal scores candidates. They are independent and every combination is legal. enablePqCompression becomes a deprecated literal delegate for approximateScoring(b ? FUSED_PQ : NONE), writing the very same field. That is what makes mixing the two spellings a non-question rather than a precedence rule to document: the last call wins, whichever it was. The accessor reports FUSED_PQ specifically, not merely "some compression", because that is what it has always meant. Each constant carries an explicit int code that is deliberately not its ordinal. These codes are written into the index metadata file in a later change, so an existing constant's code must never move and a new one is appended; using ordinals would silently remap every file already on disk the moment a constant were inserted anywhere but at the end. An unrecognised code resolves to null rather than throwing, which is what a file written by a newer version looks like, so it can be rejected and rebuilt rather than misread. The part with teeth is schema evolution. A VectorIndexConfiguration round-trips through EclipseStore as part of the index, and EclipseStore fills a field added by schema evolution with the zero value - null, for a reference. A configuration persisted before these enums existed therefore loads with both of them null, carrying its setting only in the legacy boolean, which is why that field is retained rather than replaced. The accessors derive from it instead of reporting the enum defaults; without that, every existing PQ-enabled index would silently lose PQ on upgrade. A test forces exactly that shape by reflection, since the builder cannot produce it, and it fails without the guard. No behaviour changes here. The engine still reads the deprecated accessor, so an index built with either spelling writes the same graph it did before. NVQ appears in the enum and its javadoc but is not yet implemented; the following change adds it. This is the first of two parts, split out because the API surface and its persistence compatibility are worth reviewing on their own. * GigaMap/jvector: make the compact preset actually the smallest, and correct two contracts forCompactLargeDataset set FUSED_PQ alongside NVQ, which made it larger than the plain uncompressed configuration it claims to improve on: fused codes are duplicated maxDegree times per node, so at dimension 768 and maxDegree 32 they cost 6144 bytes against the 800 the quantized vector occupies - about 7080 bytes per node against 3208. It now sets NONE, which is 936. What it gives up is traversal speed rather than accuracy: without fused codes each hop reads its candidates' own stored vectors, which are 800 bytes rather than 3072, and reranking becomes exact because the search path compares against the vectors in the GigaMap rather than the graph's quantized copy. The test pins the result against the node layout instead of restating the setting. nvqSubvectors() documented a return of 0 for auto while the accessor resolves 0 to 1, so callers never saw the value the contract promised. It now documents the effective value and points at pqSubspaces(), which deliberately returns its raw sentinel instead. The deprecated enablePqCompression() still promised full-precision inline vectors and exact reranking whenever true. With storage now a separate dimension that holds only for INLINE; under NVQ the graph carries quantized vectors and reranking compares against those. Both claims are qualified by storage mode. * GigaMap/jvector: correct why the legacy compression boolean is kept The comment claimed the field is retained so a build predating the enums can still read a configuration written by this one. It cannot. Once this build has persisted a configuration, VectorStorage and ApproximateScoring are in the type dictionary, and the older build fails to open the storage at all with a missing runtime type for the required type handler - reproduced by restarting a storage across the two module versions. The field is still right to keep, for the reason the accessors actually use it: a configuration written before the enums existed carries its setting in this boolean, and approximateScoring() derives the enum from it when the enum fields come back null. No downgrade path is promised, and the comment should not imply one. * GigaMap/jvector: fix two prose-vs-code mismatches in the compression javadoc The 'NVQ saves nothing' warning computed its size from the effective subvector count but logged the raw field, so a configuration left at the auto sentinel reported '0 subvectors' for a figure derived from one. The memory discussion under enablePqCompression() described reranking reading inline vectors and the resident cost of full-precision storage. That held while the flag implied INLINE; now that NVQ and FUSED_PQ compose it is wrong for a combination the API permits. The paragraph is scoped to INLINE and the NVQ case stated separately. * GigaMap/jvector: tie the NVQ accuracy note to the scoring mode The NVQ trade-off was stated as a flat "reranking compares against dequantized rather than full-precision vectors", which is only true in one of the two scoring modes. The reranker reads from the graph's quantized copy when the graph also carries fused codes; with ApproximateScoring.NONE it still reranks exactly, and in incremental mode it is exact by rule so the disk and in-memory halves merge on one score scale. Say all three cases instead of the one. The indexDirectory() file layout had the same shape of problem: it promised full-precision inline vectors in the .graph unconditionally, and named the deprecated boolean as what decides whether fused codes are present. It now refers to vectorStorage() and approximateScoring(), and records that the .meta carries both settings. * GigaMap/jvector: keep VectorIndexConfiguration implementable across the release The three new format accessors and their three builder mutators were abstract, so an application carrying its own implementation of either interface would stop compiling on upgrade. That is an avoidable break: the module already treats this as a concern, VectorIndex.isPqCompressionActive() being a default returning false for exactly this reason, and VectorIndexConfiguration itself already has backgroundPersistence() and backgroundOptimization() as defaults. The accessors get defaults. vectorStorage() returns INLINE and nvqSubvectors() returns 1, since an implementation predating those methods describes an inline graph with the recommended subvector count. approximateScoring() derives from the deprecated flag rather than returning a constant, because such an implementation expresses the same setting through enablePqCompression(); returning NONE would misreport a PQ-enabled configuration as having no approximate scoring. The builder mutators get defaults too, but they throw. A builder that cannot carry the setting must not accept the call and then hand back a configuration that says something else, so failing loudly is the only honest option - the default exists to preserve linkage, not to make the setting optional. Two tests hold this in place. They are written against stub implementations that declare none of the six new methods, so the file stops compiling if any of them becomes abstract again, and they pin the derivation: a legacy configuration with PQ enabled reports FUSED_PQ.
* GigaMap/jvector: store quantized vectors in the on-disk graph PR #825 established that FusedPQ makes the .graph file larger, not smaller: it duplicates each node's PQ code maxDegree times on top of the full-precision inline vectors, buying traversal speed and page locality at the cost of space. Nothing on offer made the index smaller, which is the constraint that actually binds once an index outgrows memory. JVector's NVQ feature does. It stores 8-bit non-uniformly quantized vectors inline in place of full precision, costing 4 + dimension + 28 * nvqSubvectors bytes per node against dimension * 4. At dimension 768 and maxDegree 32 that is 936 bytes per node against 3208, so roughly a million vectors occupy 0.89 GB rather than 3.0 GB. What that costs in accuracy depends on the other dimension, because that is what decides where the reranking pass reads from. Paired with NONE the graph carries no fused codes, the rerank reads the vectors held in the GigaMap, and quantization affects only which candidates traversal visits rather than how the final top-k is ordered. Paired with FUSED_PQ the rerank reads the graph's own quantized copy and the ordering is computed from dequantized vectors; measured recall@10 was 0.921 there against an exact baseline of 0.923. Either way it is safe with respect to the data itself, because the .graph is a derived artifact rebuilt from the vectors held in the GigaMap whenever its metadata is rejected. Quantizing the graph's copy costs recall, never durability. The .meta file moves to version 5, replacing the v4 PQ boolean with the two format codes the previous change introduced. A boolean could record whether fused codes were written but not whether the vectors beside them were full-precision or quantized. A code this build does not know resolves to null and is treated as a mismatch, so a file written by a newer version is rejected and rebuilt rather than misread, which is why a future storage or scoring mode will need no further version bump. Both compression managers are now fed by one training sample. Collecting per manager would walk the whole GigaMap twice, and in embedded mode call the user's Vectorizer once per entity twice, on the first persist of any index with both dimensions configured. The two-phase choreography is unchanged: collect under the GigaMap monitor, train with no locks held. No new locks and no new lock order. NVQ training differs from PQ in three ways that each remove machinery rather than adding it. It cannot decline on data shape, since a mean is defined for any non-empty sample, so its witness guards only against an outright exception. It is cheap enough to need no collect/train split of its own. And retraining is harmless, because every persist rewrites the whole graph together with the quantizer in its header, where a new PQ codebook would not match codes already fused into an existing graph. The quantizer is computed from the collected sample via NVQuantization.create rather than NVQuantization.compute. compute walks every ordinal of a RandomAccessVectorValues, which would mean handing it the null-safe view used for the disk write: it probes ordinal 0 for the dimension, which is a placeholder whenever ordinal 0 is a deletion hole, and it walks the whole corpus instead of the capped sample. The disk search path becomes a dispatch over both dimensions. An NVQ graph without fused codes traverses on its quantized vectors and reranks exactly from the GigaMap, which was previously unreachable: the old gate returned the exact provider whenever the graph lacked fused codes, so an NVQ graph would have scored every visited node through a GigaMap lookup. One rule is new and subtle: in incremental mode the disk-side reranker must be the exact one, because searchIncremental merges the disk and in-memory halves by raw score and the in-memory half is always exact, so an NVQ-dequantized disk half would sit on a different scale and bias every merge. Existing behaviour is deliberately untouched where it would otherwise drift. The plain INLINE graph with no fused codes keeps its feature-less fast path and writes byte-identical files. forLargeDataset keeps producing exactly the graph it produced before; a new forCompactLargeDataset preset opts into the compact format instead. An on-disk INLINE graph with no fused codes also still scores from the GigaMap rather than from the vectors in its own mapping, which the new dispatch could change for free but which belongs in its own change with its own staleness argument. Verified: 266 tests on the default profile and 142 with -P slow-tests, no failures. The size claim is asserted against the closed-form node layout rather than a recorded number, and recall is measured across five seeds against brute-force ground truth at the same floor as the PQ path. The configuration surface this builds on landed in #827. * GigaMap/jvector: state what NVQ actually costs, and prove it The documentation said NVQ makes reranking approximate whenever the graph also carries fused codes. Measuring it says otherwise, and the measurement is the interesting part: a test asserting that an NVQ index returns exact scores passed in both scoring modes, which it should not have if the fused branch reranked from the graph's quantized copy. The branch that does so is real but unreached. It sits behind incremental == false, and an on-disk index does not currently enter that state: tryLoad enters incremental mode on load, and every persist ends in reenterIncrementalMode. Instrumenting the non-incremental disk search and running the whole slow suite confirms it - 142 tests, not one of them reaches it. So in every path a live index takes, the disk-side rerank is the exact GigaMap one, and NVQ costs traversal quality rather than the scores: a candidate traversal never reaches cannot be recovered by reranking, but a candidate it does reach is ordered exactly. The branch is kept rather than removed, because it is the correct behaviour if that state ever becomes reachable, and its javadoc now says that it is unreached rather than implying it runs. The dispatch is restructured so each path computes only the reranker it uses. It previously built the graph reranker up front and then discarded it on the NVQ-without-fused-codes path, which called view.rerankerFor a second time - a wasted allocation per query on the very configuration the feature exists for, and the structure that made the code read as though NVQ reranked from the graph. The test measures score deviation rather than recall, because recall cannot distinguish the two rerankers at a scale the suite can afford, and it searches a reopened index so the query runs against the graph on disk rather than one the writing builder still holds. Both matter: an earlier draft did neither and would have passed against either implementation. * GigaMap/jvector: make a changed quantization count take effect The metadata recorded which storage and scoring modes a graph was written with, but not the two counts that shape the blocks within those modes. Changing either over an existing index directory was therefore accepted as a clean load, and the consequence is worse than a stale file: the quantizer is adopted from the loaded graph rather than retrained, so the old one stayed in place and every later persist kept writing the old shape. The new setting was not merely deferred, it was silently ignored. Both counts are now recorded and verified, on the same reasoning the mode codes already carried: nothing else in the file reveals them, and removeIndex() leaves files behind, so a setting changed over an existing directory has to invalidate the graph. They are recorded in effective form rather than as configured. The automatic sentinel and the value it resolves to are the same setting, and a count means nothing in a mode that does not encode with it, so both are normalized before being written - a count the format does not use is stored as zero. Without that, spelling out dimension / 4 instead of leaving pqSubspaces automatic would have forced a rebuild that changes nothing in the file. No version bump. Version 5 has not shipped; it exists only on this integration branch, so the layout is still free to grow. The test asserts both directions, because only the negative half is obvious: two configurations that describe the same graph must still load, or the fix trades a silent miss for a pointless cold start. It fails without the validation, on the NVQ subvector case. * GigaMap/jvector: finish correcting the NVQ accuracy claim The previous commit rewrote the prose explaining what NVQ costs but left three statements of the old claim standing: the summary bullet on the constant itself, the README's limitations list, and the compact preset's javadoc, which gave the absence of fused codes as the reason reranking stays exact when the real reason is that no reachable path reranks from the graph at all. The dispatch javadoc now says the same thing where it is easiest to check, next to the branch it describes: incremental is never false for an on-disk index, so the graph-backed reranker below it is unreached, and it is kept for correctness rather than because it runs. Also fixes a sentence that parsed only on a second reading.
* GigaMap/jvector: cover and document the NVQ storage mode Completes the NVQ work with the tests and documentation it was missing, and corrects two claims made for it that do not survive measurement. The incremental merge rule now has a test. A query in incremental mode searches the disk graph and the in-memory builder separately and merges the two by raw score, so the disk half must be reranked exactly or the two sides sit on different scales. Asserting this through recall proved useless: the quantization error rarely reorders a top-k, so the test passed whether or not the rule was in place. It asserts the invariant directly instead, comparing each returned score against the similarity JVector itself would compute. With the rule removed the deviation measures 7.9e-4 against a 1e-4 threshold, which is float-arithmetic noise on one side and quantization on the other. Note the configuration this needs: with NVQ storage and no fused codes the reranker is exact by construction, so only NVQ together with FUSED_PQ exercises the choice at all. That combination is also the only place the choice is made, since the non-incremental disk search the other branch belongs to is unreachable - so this rule is the whole reason an NVQ graph returns exact scores. The mean-pollution argument for training from the dense sample rather than the ordinal-spaced view was overstated, and the comment and test claiming it have been corrected. Deliberately halving the global mean left search results unchanged, because NVQ recentres and then scales each subvector by its own min and max, and that range absorbs a shifted mean almost entirely. The reasons to avoid NVQuantization.compute are the other two: it probes ordinal 0 for the dimension, which is a placeholder whenever ordinal 0 is a deletion hole, and it walks the whole corpus rather than the capped sample. Mean pollution is defence in depth rather than the motivation. The encode cost is now measured rather than estimated, and it changes a recommendation. At 20,000 vectors of dimension 768 with maxDegree 32, persisting takes 3.6 s with full-precision vectors and 11.1 s with quantized ones, about 3x. Under the parallel writer the same pair is 4.0 s and 4.8 s, about 1.2x, because the per-node encode runs on the writer's worker threads instead of in one pass. Pairing NVQ with parallelOnDiskWrite is therefore the documented advice rather than an aside. The same run confirms the size claim end to end: 64.2 MB against 18.8 MB, a ratio of 3.41 against the 3.43 the node layout predicts. New tests cover the production-dimension size ratio, NVQ under the parallel writer with concurrent searches, sparse ordinals with null embeddings, and rejection of both an unknown format code and a previous format version. The unknown-code case is what allows a future storage or scoring mode to be added without another version bump, so it is pinned directly. The documentation gains an NVQ section carrying these measurements, a storage column in the use-case matrix, and a compact large-dataset recipe. Four statements that were already stale before this work are corrected: the metadata does record configuration, it is no longer five fields, the format version is no longer 4, and a configuration change does now trigger a rebuild. Examples move off the deprecated setter. Verified: 267 tests on the default profile and 147 with -P slow-tests, no failures. * GigaMap/jvector: make two NVQ tests exercise what they claim Both tests passed, and both would have passed against an implementation without the behaviour they were written for. The parallel-write test submitted every search only after persistToDisk() returned, so it measured concurrent reads of a finished graph rather than searches overlapping the write. The point of the test is that NVQ encodes per node from a supplier the writer calls on its own worker threads, which makes NVQuantization.encode - and the encodeTo it delegates to - concurrently invoked, with nothing upstream exercising it that way. The searchers now loop until the persist returns, a latch holds the writer until all of them are running, and the number of searches that completed during the write is asserted, so the test fails rather than quietly degrading if the overlap ever stops happening. The sparse-ordinal test never left ordinal 0 empty: it added a vector before every null, so the first entity always carried an embedding. Ordinal 0 is the one ordinal NVQuantization.compute probes for the dimension, which is the edge case the test exists for, so the implementation it guards against would have passed it. A null entity now goes in first, and the fixture asserts that ordinal 0 both exists and carries no vector rather than assuming it. Also corrects the javadoc that named encodeTo as the method the supplier calls. It calls encode, which creates an empty QuantizedVector and delegates - verified in the rc.9 bytecode. * GigaMap/jvector: align the NVQ docs with the two-dimension format Three inconsistencies, all pointing the same way. The metadata description was written before the two quantization counts were added to it, so it listed five content witnesses and the two mode settings but neither count. It now lists both, and the loading section says why a changed count rebuilds where a reader might expect it merely to be deferred: the quantizer is adopted from the loaded graph rather than retrained, so without the check the new setting would be silently ignored rather than applied late. The effective-form comparison is stated there too, since that is what keeps an automatic sentinel from rebuilding against the value it stands for. The per-node inventory and the large-scale recipe still described NVQ as making reranking approximate. It does not on any path a live index takes; that was established by measurement in the preceding change. Both now say that the storage block affects how traversal scores candidates rather than how the final top-k is ordered. The summary matrix recommended NVQ for the RAG and image-search recipes, neither of which sets it - both leave vectorStorage at INLINE. A summary that disagrees with the configuration above it is worse than no summary, so the cells now match the recipes. Recommending NVQ there would be a change to what those recipes advise, which wants its own reasoning rather than arriving through a table. * GigaMap/jvector: test the NVQ encode concurrency where it can actually be observed The parallel-write test still could not see what it claimed, even after the previous attempt to fix it. doPersistToDisk holds builderLock.writeLock() across the whole of phase 2 including writeIndex, and search needs the read lock, so no query can run while NVQ.encode does - the code says as much where it releases the parentMap monitor but keeps the write lock. The searches counted as concurrent were running in the windows before and after it. Comparing a parallel-written graph against a sequential one byte for byte does not work either, which took a control to establish rather than an argument: two sequential writes of the same vectors with the same seed already differ. Graph construction is not deterministic, so that comparison cannot separate an unsafe encoder from an ordinary run-to-run difference. An earlier probe at 500 vectors came out identical and was simply luck. What is left is to assert the property against the quantizer directly. Eight threads encode the same 200 vectors repeatedly against one shared NVQuantization and compare every result with the single-threaded one, which is the access pattern the parallel writer produces, concentrated. It pins the property rather than reproducing a known failure - but it is the only one of the three formulations that runs the code concurrently at all. The integration-level claim keeps its own test, narrowed to what it can carry: the parallel writer completes, and its output loads and answers queries. Two size claims were also asserted nowhere. The production-dimension test documented the eight-subvector case at about 2.8x but measured only the default single-subvector setting, so the measure helper takes an explicit count and the lower end is measured too. And the suite ran five-seed recall for three of the four storage/scoring combinations while the documentation claimed all four; the missing uncompressed baseline is the one that decides whether the other three are near it or merely near each other, so it is now run rather than assumed. * GigaMap/jvector: quote the footprint the large-scale recipe actually gets The recipe enables NVQ alongside FUSED_PQ and annotated the result as a 3.4x smaller graph. That figure is the whole-node ratio without fused codes. Fused codes are unaffected by the storage mode and, at this recipe's dimension 768, maxDegree 32 and 48 subspaces, they are 1,536 bytes of the node on their own. The node goes from 4,744 bytes to 2,472, which is 1.9x - the vector block does shrink 3.8x, but it is no longer most of the node. Both numbers are now given, along with what dropping FUSED_PQ as well would cost, since 936 bytes against 3,208 is where the 3.4x in the rest of the documentation comes from and a reader comparing the two pages should not have to work out why they disagree. * GigaMap/jvector: repair three tests that stopped proving their point The unknown-format-code test had been silently disarmed by the two counts added to the metadata in the preceding change. Its helper addressed the storage and scoring codes as the last two ints in the file, which they no longer are, so both mutations landed on pqSubspaces and nvqSubvectors instead. The load was then rejected on a count mismatch before fromCode ever saw the unknown value, and the test went on passing while covering nothing. The helper now anchors its offsets at the start of the record and asserts the total length, so the next field added breaks it loudly rather than retargeting it. Confirmed the repaired test fails when fromCode is made to map unknown codes onto a known constant, which it did not before. The concurrent-encode test submitted its workers without a start barrier, so the pool was free to run one to completion before starting the next and a stateful encoder could have slipped through. The threads now meet at a latch before any of them encodes. The incremental merge test asserted only that some disk-resident entity came back. If a query set ever returned nothing from the in-memory half, the two score scales would never meet and the test would quietly narrow to a check on the disk reranker. It now requires results from both halves. * GigaMap/jvector: name the right source for each reranking path Reranking is exact under every format, but it does not always read the same vectors, and saying it reads the GigaMap either way describes the implementation wrongly. With INLINE storage and fused codes the reranker reads the full-precision vectors from the memory-mapped graph, which is the point of keeping them there - it costs no parentMap lookup, and in embedded mode no vectorize() call, per reranked candidate. Only when the graph holds quantized vectors, and so has no full-precision copy, does the rerank fall back to the GigaMap. Both the per-node inventory and the two-phase search description now say which source applies to which storage mode. The second mattered more than it looks: the NVQ section states that every combination of the two dimensions is valid, which brings NVQ + FUSED_PQ under a paragraph that claimed reranking always uses the graph's inline vectors. Also fixes a sentence that lost a verb. * GigaMap/jvector: give the compact preset the write mode it needs forCompactLargeDataset chose the quantized format and then inherited parallelOnDiskWrite=false from builderForLargeDataset, so it handed out the NVQ encode cost without the mitigation documented two paragraphs away: about 3x the persist wall time sequentially against about 1.2x under the parallel writer, because the per-node encode then runs on the writer's worker threads. A preset exists to make a coherent choice, and that one was not. Also corrects the deprecated flag's javadoc, which still said an NVQ graph reranks against its quantized vectors. It reranks against the full-precision vectors in the GigaMap - exact, but one lookup per reranked candidate, where an inline graph reads them from its own mapping for free. That difference is the reason worth documenting, and it is the opposite of what was written. * GigaMap/jvector: correct what VectorIndices.add says about reusing an index directory The contract told callers that the metadata records none of the tuning settings and that they must delete the .graph and .meta files by hand between removeIndex and add. Neither has been true since the format settings went into the metadata: a changed storage mode, scoring mode or quantization count is detected on load, and the graph is rebuilt from the parent map rather than served under the new configuration. Left as it was, the advice costs a rebuild nobody needed - and, worse, teaches that the check does not exist. The distinction the contract should draw is a different one, so it now draws that instead: settings that change what a reader must know to interpret the file are recorded and verified, while those that only shape how the graph was built - maxDegree, beamWidth, alpha, neighborOverflow, the similarity function - are not. A graph built under a previous value of one of those still loads, because nothing in the file contradicts the new configuration. Deleting the two files is the way to force those to take effect, which is the case the old advice was reaching for. * GigaMap/jvector: stop the sparse-ordinal test depending on an unstable ranking It compared the ordered top five from two independently built graphs and required them to be identical. Graph construction is not deterministic - established while reworking the parallel-write test, where two sequential writes of the same vectors already differed - and NVQ traversal is approximate on top of that, so a legitimate variation could have failed this for a reason unrelated to null embeddings. What the holes must not do is change which vectors are candidates, so that is what is asserted: the exact match ranks first in both, no null-embedding entity appears, and the two result sets agree on all but at most one entry. Ordering within the set is left alone, because it was never the claim. * GigaMap/jvector: give the search phases a table instead of a sentence The prose kept getting one of the four format combinations wrong, in both directions: first that reranking always reads the graph's inline vectors, then that it always reads the GigaMap. Neither holds, and a sentence that has to carry four cases with two exceptions was the wrong shape for it. The four combinations are now a table with the traversal source and the reranking source for each. Two entries are worth knowing and neither was stated before: FUSED_PQ traversal reads its codes whatever the storage block holds, so switching storage does not change how candidates are found in that mode; and the default INLINE + NONE reranks from the GigaMap even though full-precision vectors are sitting in its own mapping, because scoring them from the mapping would change the behaviour of the default on-disk configuration and that is deliberately left alone. The per-node inventory drops its reranking claim entirely and says only when the storage block is read during traversal, which is the thing a reader is looking at that list to find out. * GigaMap/jvector: tighten three test claims to what the tests establish The merge test counted disk-half and memory-half results across the whole query set, which does not establish that any single merge compared the two score scales: one query could contribute every disk hit and another every memory hit. It now requires at least one result set holding both. The compact preset's new parallelOnDiskWrite default was asserted nowhere, so a later refactor could drop the mitigation for NVQ's encode cost while every factory test still passed. Pinned, with the measurement as the reason. The sparse-ordinal fixture claimed more than it can show. Putting a hole at ordinal 0 does cover the ordinal that gets special treatment in the training path, but a test that asserts on search results cannot distinguish training from the collected sample from training over the ordinal space: NullSafeVectorValues hands out a placeholder of the right dimension, so NVQuantization.compute would not fail on it, and the placeholders only shift the mean - which the mean-pollution experiment already showed the per-subvector scaling absorbs. The comment now states the end-to-end claim it does establish. * GigaMap/jvector: finish the reranking and metadata corrections in the public javadoc Three places still contradicted what the search path does, all of them reachable from a user's IDE rather than from the documentation site. enablePqCompression carried a second NVQ paragraph, further down than the one corrected earlier, still saying reranking compares against quantized vectors. It reads the full-precision vectors in the GigaMap - the accuracy is unchanged and the cost is a lookup per reranked candidate, which is the part worth knowing. indexDirectory inventoried the .meta without the two quantization counts, so the javadoc listed fewer rebuild triggers than the file has. VectorIndices.add overstated the correction it received in the previous commit twice. A change to a recorded setting is a mismatch, but the counts are compared in effective form, so changing pqSubspaces while scoring is NONE - or nvqSubvectors while storage is INLINE - changes nothing in the file and triggers nothing. And the older sentence promising that removeIndex followed by add re-indexes every entity is no longer true for an on-disk index whose files survive validation, which is precisely what the new paragraph describes. The per-node inventory in advanced.adoc stops restating the search rules for a third time and points at the table that already holds all four cases. * GigaMap/jvector: measure the sparse-ordinal case against ground truth The previous attempt traded an exact-ordering comparison between two independently built graphs for an overlap bound between them, which is the same dependency with a looser constant. Nothing bounds how far two valid approximate graphs may diverge from one another, so the threshold was arbitrary and a legitimate variation could still fail it for a reason unrelated to null embeddings. Brute force does not move. Both indices are now measured against the true nearest neighbours instead of against each other, which is what the test meant all along: interleaving holes into the ordinal space must not cost the sparse index recall the dense one has. * GigaMap/jvector: qualify what NVQ costs by the scoring mode Correcting the claim that NVQ makes reranking approximate left a different over-generalisation in its place: that it costs traversal quality. That holds only when traversal reads the stored block, which is the NONE case. Under FUSED_PQ the fused codes drive traversal and the quantized vectors are not consulted, so candidate selection is exactly what it would be with INLINE storage - the cost there is the footprint saving and a GigaMap lookup per reranked candidate, nothing to do with recall. It read worst where it was attached to a recipe that enables FUSED_PQ, telling a reader to raise the search beam against an effect that configuration does not have. Stated per mode now in VectorStorage, which is where the explanation belongs, and the seven other places that carried some form of it either say the same thing or point at the table rather than restating it - the README twice, index.adoc, configuration.adoc, use-cases.adoc, the vectorStorage accessor and a test javadoc. Two of those were not flagged in review; they carried the same sentence and would have surfaced one round at a time. Also fixes two descriptions that predate the storage dimension: the .graph inventory still listed inline vectors and fused codes as the only contents, and the two-phase walkthrough described the FUSED_PQ path as though it were the only one, directly below a section stating that all four combinations are valid. * GigaMap/jvector: make the summaries agree with the search path, and flag the similarity-function hazard The last of the contradictions between the short descriptions and the detailed ones, in both directions: the overviews in advanced.adoc and index.adoc, the README feature list and the VectorStorage decision table all still said NVQ trades recall unconditionally, while vectorStorage() and the enum-level table said storage decides how exact reranking is. Neither survives the search path. Reranking is exact under all four combinations, and candidate recall moves only in the modes that traverse on the stored block. The VectorIndices contract also listed the similarity function beside maxDegree and beamWidth as a setting that is not recorded and whose graph can simply be reused. The first half is true and the second is not safe. Edges are built by searching with that function, so a graph built under one metric and reopened under another keeps neighbour lists chosen for the old one: queries still return, and their scores are computed with the new metric and are correct in themselves, but traversal follows edges optimised for the wrong distance and recall degrades with nothing reporting it. The contract now says to delete the files when changing it. Recording it in the metadata is the real fix and is filed separately - it needs a format field and its own review, not an edit at the end of a documentation change. Also: the README still claimed format version 4 and said null vectors are never accepted, which the Vectorizer.allowsNullVectors() opt-in has made untrue and which this branch adds tests for; and three runnable examples still used the deprecated enablePqCompression(true), two of them in javadoc where an IDE offers them for copying. * GigaMap/jvector: correct what removeIndex followed by add does to the on-disk files The contract said the new index loads the files the old one left behind if they still describe the data and the configuration, and told callers to delete them by hand when changing the similarity function. Review checked it against a running index: that reuse never happens. The index that add() creates is a new instance, so its structural modification counter starts at zero, while any .meta that was ever written carries at least one. The load is refused on that witness before the recorded settings are reached, and the graph is rebuilt every time. So the manual-deletion advice was work nobody needed, and the paragraph describing which settings are recorded was attached to the wrong path. Those settings do matter, just on the other one: an index that comes back through storage keeps its counter, its content witnesses agree, and the configuration is then what decides. The similarity-function hazard is rewritten rather than removed. Nothing in the file would contradict a changed metric, so a graph built under a previous one would be served under it if the two were ever brought together - it is the counter witness that keeps that from arising, since presenting a graph under a different configuration means building a new index and a new index adopts nothing. Recording the function in the metadata is still worth doing, so that the protection is by design rather than by consequence, and that is filed separately. * GigaMap/jvector: give the format witnesses the reason they actually have The justification carried everywhere was that removeIndex() leaves the files behind, so without the format codes a graph built under the previous setting would be reused. The measurement behind the preceding commit disproves it: that path is refused on the structural modification counter, since a new index starts at zero and any written .meta carries at least one, so the codes are never consulted there. They are not redundant, they were explained by the wrong case. The one that reaches them is a downgrade. A new storage or scoring mode ships without a format version bump - that is the stated point of the stable codes - so an index persisted by a newer build and opened by an older one presents a matching version and matching content witnesses, being the same index in the same store. An unrecognised code is then the only thing separating that file from one this build wrote, and fromCode returning null is what turns it into a rebuild rather than a misread. Corrected in advanced.adoc, which review flagged, and in the four other places carrying the same sentence: the metadata section of ARCHITECTURE.md, both halves of DiskIndexManager, and the dispatch javadoc in VectorIndex. Comments and documentation only.
…es (#830) * GigaMap/jvector: score from an in-memory PQ blob instead of fused codes FUSED_PQ buys fast approximate traversal by writing each node's code into every neighbour that references it, so the cost is pqSubspaces * maxDegree bytes per node on disk - 6144 at dimension 768, maxDegree 32 and the automatic subspace count, which is what makes a compressed graph nearly three times the size of an uncompressed one. The codes themselves are far smaller than that; the duplication is the price of having them inline. PQ_IN_MEMORY buys the same traversal by keeping one flat array instead. The codes go into a .pqv sidecar beside the graph and are read into heap on load, costing pqSubspaces bytes per ordinal once. The graph is left byte-for-byte what ApproximateScoring.NONE produces, which a test asserts directly. Combined with NVQ storage this is the smallest on-disk configuration available: measured at dimension 256, it is under half the uncompressed baseline and under a quarter of today's compressed one. The heap cost is linear and has no ceiling, so it is stated rather than implied. It is pqSubspaces bytes for every ordinal up to the highest in use - deletion holes included, because the codes are indexed by entity id - resident for as long as the index is open. Roughly 192 MB per million vectors at dimension 768, and roughly 19 GB at a hundred million. The configuration logs the per-ordinal rate when the mode is selected, the documentation carries the worked figures, and a test pins the accounting against the ordinal space rather than the vector count. No metadata version bump was needed. PQ_IN_MEMORY is simply a new scoring code, and a build that does not know it rejects the file rather than misreading it, which is the property the explicit non-ordinal codes exist for. The Stage 1 test that pinned code 3 as unknown now pins it as PQ_IN_MEMORY and moves the unknown-code assertion to 4 - the mechanism working as designed. The commit order is sidecar, then graph, then meta last, so the metadata only becomes visible once everything it describes is in place. A missing sidecar is a rejection rather than a degrade: the metadata asserts that this index traverses on PQ codes, so serving it exactly instead would leave the configuration describing something the index is not doing. Rejecting rebuilds from the store, which restores both files. The codebook lives in the sidecar too, since this mode writes no fused feature and the graph header therefore carries none. One test earns its place by construction. Every other test here passes whether or not the search path consults the codes, because the codes only choose which candidates traversal visits and reranking is exact either way - with enough beam width the same top-k comes back regardless. So testPqInMemoryCodesActuallyDriveTraversal swaps in a sidecar encoded from unrelated vectors, which the metadata does not describe and therefore does not reject, and asserts that retrieval degrades. With the scoring branch disabled the honest and aliased runs both measure 0.97 and the test fails; with it in place the aliased run drops far enough to prove the codes are what traversal follows. Two notes for anyone extending this. PQVectors.writeSidecarHeader is not the writer for a sidecar despite the name - it emits the codebook and counts only, for a caller that streams the chunks itself - so the symmetric write/load pair is used instead. And an index registered against an empty GigaMap never loads its disk files at all, because the metadata witnesses reject on the count; tests that mean to exercise the disk path have to round-trip through EmbeddedStorage. Verified: 267 tests on the default profile and 156 with -P slow-tests, no failures. * GigaMap/jvector: stop a too-small PQ_IN_MEMORY index rebuilding on every restart PQ training needs 256 embeddings. Below that the persist writes no codebook and therefore no sidecar, but the metadata still records the configured scoring mode - as it must, since recording what the write achieved would have the loader reject its own output and rebuild forever. The load then found no sidecar, treated it as loss, and rejected. The forever-rebuild arrived by the other route: an index under the threshold paid a cold start on every restart for as long as it stayed small, silently. The count witness separates the two cases, and it is already read and verified a few lines above. Below the threshold there are no codes to be missing, so the graph loads and traversal scores exactly - the same fallback a FusedPQ graph whose training declined already gets. At or above it, a missing sidecar is still loss and still rebuilds. Failing the persist instead would turn an ordinary small index into an error, which is worse than the behaviour it replaces. The test asserts through tryLoad rather than end to end. Written the obvious way first, it passed with the fix disabled: a rejected load rebuilds from the store and the index answers queries either way, so nothing observable at that level distinguishes them. Only the manager's own return value does. Also corrects a test javadoc claiming the graph is byte-for-byte what NONE produces. It asserts size and feature set, which is what the claim is actually about, and byte equality would be the wrong assertion anyway since graph construction is not deterministic. * GigaMap/jvector: check a loaded sidecar describes the graph beside it The metadata witnesses cover what a torn write can produce, since the metadata commits last and pqSubspaces is itself a witness. They do not cover a sidecar that arrived from somewhere else - copied in, restored from another backup generation, truncated outside this code - and reaching the score function with one of those is worse than rebuilding: a code array shorter than the graph's ordinal space fails on a lookup during a search rather than at load, when there is still something sensible to do about it. The two checkable mismatches are now rejected at load: a code length other than the configured subspace count, and fewer ordinals than the highest entity id in use. Content is not checkable and the javadoc says so - a correctly shaped sidecar full of the wrong codes passes, which is exactly what testPqInMemoryCodesActuallyDriveTraversal relies on to prove the codes are consulted at all. Detecting that would need a checksum the format does not carry. Writing the check found a second defect. effectivePqSubspaces gated on usesFusedPq, so a PQ_IN_MEMORY index recorded a subspace count of zero in its metadata: the witness added to make a changed pqSubspaces take effect was inert for the mode this change introduces, and the first assertion of the new test - that an index loads its own sidecar - failed against a count that was never written. It now gates on usesPq, which covers both modes. * GigaMap/jvector: decide the sidecar question from what was indexed, not what was counted The discriminator that separates a legitimately absent sidecar from a lost one used expectedVectorCount, which counts entities rather than embeddings. In embedded mode an entity without an embedding is counted but not indexed, so a map of 300 entities holding 100 vectors reads as over the training threshold while PQ training saw 100 and declined. The load then read the absent sidecar as loss and rejected, the rebuild declined again, and the next restart repeated it - the rebuild-every-restart loop the previous commit removed, restored for exactly the corpus shape that made training decline in the first place. The graph is already open at that point and its node count is what was actually written, nulls excluded. That is now what decides. The regression test needs an embedded vectorizer to reach the corner at all: with a computed one the count follows the stored vectors and the two agree, which is why the first version of this test failed on its own precondition rather than on the behaviour. * GigaMap/jvector: say per ordinal where the cost is per ordinal, and cover the second rejection The heap cost was described as bytes per vector in the places a reader meets first - the constant's cost line and summary, and the opening of the advanced section - while the paragraph that puts numbers on it correctly says per ordinal. The codes are indexed by entity id, so a deletion hole costs its bytes like any other ordinal, and per vector understates exactly the term the documentation is warning about. The sidecar rejection test claimed to cover both checkable mismatches and exercised one. It copied a smaller sidecar in, which is the too-few-ordinals case; the wrong-code-length branch had no test at all. It does now, from an index built with half the subspace count, and I checked both cases fail with their own branch disabled. * GigaMap/jvector: stop a sidecar outliving the graph it was written for Review reproduced the hole: an index persists with a codebook, a later persist declines training and writes none, and the old .pqv stays on disk beside the new graph. Every check it had passed - present, right code length, enough ordinals - so the next start loaded it and reported PQ active while traversing on codes describing vectors the graph no longer held. Silent, and worst precisely when the vectors changed in between, which is the situation that put the index there. Both halves of the fix are needed and each is verified to fail on its own. A persist that writes no sidecar now deletes any existing one, in the same step and before the graph becomes visible, so the pair on disk stays consistent at every point a crash can stop at. And the sidecar carries the structuralModCount of the persist that wrote it, in a trailer after JVector's payload so its format is untouched. A file that survives by a route the delete does not cover - a crash between the sidecar and graph renames, a file restored by hand - is then recognisable rather than merely plausible, and that closes the rename window as a side effect. The witness alone would have been worse than nothing: it would reject the stale file, the rebuild would decline training again, leave the same file in place again, and the index would rebuild on every restart - the loop the previous two commits removed twice already.
) * GigaMap/jvector: allow PQ-compressed scoring for in-memory indices An in-memory index performs about 2,000 vector lookups per insertion while building the graph, and well over a thousand distinct lookups per query while searching it. The per-query cache dedupes repeat visits to the same node but not the distinct ones, and both counts grow with the data set. Scoring from in-heap PQ codes removes them: measured, an insertion after the switch costs under 20 vectorizer calls against 1818 before it. An index cannot start compressed. GraphIndexBuilder takes its BuildScoreProvider at construction and a codebook needs 256 vectors, so the switch is a rebuild - train, encode every ordinal, build a fresh builder against the codes, replay the nodes, swap. That is O(n), so it happens at optimization, which already pays an O(n) cost, and nowhere else. build() therefore requires optimizationIntervalMs > 0 for this mode; triggering it from a mutation would put a full retrain and rebuild inside whichever add crossed the threshold. The switch runs in three phases, each holding exactly one lock and never two. Phase one reads the GigaMap under the parentMap monitor: whether training is pending, the training sample, the vectors to replay, the ordinal-space warning, the change counter. Phase two holds no lock at all and is where the cost is - k-means and the replay both work only from what phase one captured, so neither needs one. Phase three takes builderLock.writeLock() and swaps pointers. The split is not an optimisation, it is what ARCHITECTURE.md section 11 requires: acquire parentMap before builderLock, never the reverse, because a thread holding the write lock and then waiting for the monitor deadlocks against internalRemoveAll, which holds the monitor and waits for that lock. Nothing reachable from phase three may touch the monitor, which rules out collectStoredVectors (it iterates the GigaMap) and anything reading getVectorCount or getHighestEntityId. Both were called from there during development and both reopened the cycle. Releasing the monitor before the replacement is built means the index can move on while it is being built, and a replacement from the older picture would undo whatever moved. Rather than reconcile, phase three checks structuralModCount again and discards a replacement that no longer describes the index. The switch is deferred to the next optimization, never applied to a stale picture: the data wins, the switch waits. The heap cost is the sidecar mode's, with the same shape: pqSubspaces bytes for every ordinal up to the highest in use, deletion holes included, because the codes are indexed by entity id and removals never compact the array. A map whose id space has churned past its live count pays for the gap, so the switch warns when the ordinal space exceeds the live count fourfold - counting graph nodes rather than entities, since in embedded mode the entity count includes those with no embedding and would keep the warning quiet on exactly the shape it is about. Construction under compressed scoring does no reranking, so graph quality can drop. Measured recall@10 stays above 0.90 on clustered data at the default beam width; the documentation says to raise beamWidth for this mode if a given data set comes in lower. Verified: 268 tests on the default profile and 168 with -P slow-tests, no failures. * GigaMap/jvector: cover the in-memory PQ switch where it can actually be observed Most of what this mode does is invisible from the outside. A correct graph comes back whether the builder scored from codes or from vectors, and the search path uses the codes either way, so a test that only checks results passes against an implementation that never switched at all. Each test here is therefore aimed at something that changes when the behaviour changes, and each was checked to fail without the code it covers. insertsAfterTheSwitchScoreFromTheCodes counts vectorizer calls for insertions made after the switch: under 20 per node with the codes, 1818 without. It measures insertions rather than the switch itself because optimize() runs cleanup() on the old exact-provider builder first, and that alone costs a couple of hundred reads per node, swamping the signal. An earlier version measured across optimize() and reported that cleanup as a failure. aMutationWhilePreparingDiscardsTheSwitchRatherThanTheMutation drives a mutation into the window between the plan and the swap, through the same kind of seam the persist-window regression test uses, and asserts the switch is discarded, the mutation survives, and the next optimization switches. It runs with eventual indexing, because that is what routes the mutation through a background callback holding only the read lock - the path that can overtake the plan - and it drains the queue before asserting, since map.set only enqueues there. An earlier version did neither and passed for a reason unrelated to what it claimed. removeAllLetsTheIndexSwitchAgain covers the state reset: the codes describe a graph that removeAll destroys, and because the switch returns early when they are present, an index emptied and refilled would otherwise have reported compressed scoring against a codebook for data it no longer held, permanently. compressedScoringCollapsesVectorLookupsPerQuery and recallStaysHighAfterTheSwitch cover the two halves of the bargain - that traversal really does use the codes, and that graph quality survives construction without reranking. mutationsAfterTheSwitchStayConsistent and its exact-index control cover add, remove and update once the switch has happened. * GigaMap/jvector: describe PQ_IN_MEMORY as heap codes, not as a sidecar file The mode was documented from the on-disk side throughout, because that is where it started: codes in a .pqv sidecar, read into heap on load. For an in-memory index none of that is true. There is no persist to write a sidecar at, so there is no sidecar; the codes are built in heap during the optimization that switches the index over, and rebuilt the same way after a restart. A reader following the enum documentation, the configuration reference or the README would look for a file that is never written. All four now say where the codes come from in each case rather than describing one and implying it covers both. The advanced-guide example also left minChangesBetweenOptimizations at its default of 1000 while showing an index that switches at optimization. An index of a few hundred vectors never reaches that threshold, so the example configured exactly the case build() warns about and demonstrated a switch that would not happen. * GigaMap/jvector: correct a search-path comment left describing the removed design The gate on the in-memory search path explained itself by contrast with a build-path gate that no longer works that way: the codes used to be published empty and filled by a replay, so the two sites needed different conditions and the comment said why. The switch now encodes everything before anything is swapped in, so a published store is always a populated one. The count check stays - an empty store would mean there is nothing to score from, and falling back to exact is then right rather than a missed optimisation - but it is now a defensive check rather than the load-bearing distinction the comment described. * GigaMap/jvector: let the switch own its compression manager, and report from what is published Phases two and three run outside the monitor, and both reached this.pqManager. That field is not stable across them: closeInternalResources nulls it and initializeIndex installs a new one, so internalRemoveAll running alongside a switch could leave phase two training a manager the index had already discarded, or a null one. The discard path was worse - it reset whichever manager happened to be installed when it ran, which for a teardown followed by a successful second switch means clearing a codebook that was in use. The plan now carries the manager it was made for. Phase two trains that one, phase three refuses to publish unless it is still the index's, and the discard resets it only when it is. Ownership rather than re-reading, which is the same discipline the deferred builder ops already follow for the builder field. isPqCompressionActive() reported from the codebook, which is set at the start of a transition that then encodes every ordinal and rebuilds the graph with no lock held. For as long as that took, the index answered that compressed scoring was in effect while search was still selecting the exact provider - and that method's whole contract is to report what the index is doing rather than what it was asked to do. For an in-memory index it now reports the published codes, which appear at the same instant as the graph that scores from them. The test for that needed a seam of its own. The existing one fires before training, where a codebook does not exist yet and the old implementation would have read false too - so the first version of this test passed against the very bug it was written for. The new seam fires once the replacement is built and before the swap, which is the only stretch where the two witnesses disagree. Also scopes the on-disk requirement on the builder's approximateScoring setter to FUSED_PQ, matching the accessor and the validation it documents. * GigaMap/jvector: close five races around the in-memory PQ switch structuralModCount is the witness phase three revalidates against before adopting a replacement, and it was a plain field. Mutations bump it holding only the parentMap monitor while that check runs under builderLock with the monitor released, so the write lock supplies no happens-before edge between them and the switch could read a stale count and adopt a graph built before a mutation it never saw. Volatile now. Phase two read the manager's isTrained() and getPQ() as two separate calls. A teardown between them leaves the second returning null, and MutablePQVectors fails on it before the identity guard in phase three could decline the switch. The codebook is captured once and the switch abandoned if it is gone. The discard path reset the manager whenever it was still the index's. That is not enough: nothing serialises two optimizations, so both can prepare from the same manager, the loser discards on builder identity, and its reset would strip the codebook out from under the winner's freshly published graph. It now also requires that nothing has been published from that manager. The embedded vec-vec branch refreshed the PQ code only when codes already existed. During a switch there are none - they are published last - so an update landing while the replacement was being built was skipped, and after the swap nothing revisited it: the switch does not run again once codes are present, so that entity would have been scored by its old embedding for the rest of the index's life. The refresh is queued unconditionally now; trackPqCode is a no-op while there are no codes, and the queued op re-evaluates when it runs. The background add callbacks called addGraphNode directly. A mutation queued before the plan's snapshot is taken is included in that snapshot and still pending afterwards, so the replay adds the ordinal and the callback then adds it again - which throws. The change counter does not reject the plan, because the snapshot was taken after the mutation. Both callbacks go through internalAddGraphNodeIdempotent, which exists for exactly this and also reads the builder once. And an in-memory PQ index could never switch after a restart. The transition happens at optimization, but a restarted index has its entities already in the store, so nothing bumps the change count and every scheduled optimization is skipped for the life of the session. The first one is now armed when such an index initialises without codes. * GigaMap/jvector: make every exit from the PQ switch leave a usable state Two of these could wedge the index for the rest of its session. If anything in the locked block threw after the replacement had been built - cleanup() most obviously - control left through the outer finally and the replacement was never discarded. Its manager stays trained, so every later plan returns at that check, while no codes were ever published: the index sits on exact scoring permanently, with a builder and graph leaked beside it. The discard now runs in a finally of its own, so no exit can skip it. And a discarded switch asked for no retry. The background manager clears the optimization counter after every callback that returns normally, so the very mutation that invalidated the plan is erased with it. An index that lost the race once would wait for another minChangesBetweenOptimizations writes before trying again, which for a settled index means never - the opposite of the "deferred, not abandoned" contract the discard is supposed to honour. A discard now re-arms the next scheduled optimization. The rest are narrower. Phase three published the codes before the builder and the graph. isPqCompressionActive reads them with no lock, so for that instant it announced a switch while the old graph was closed and the new one not yet installed. The codes go last now, after everything they imply is in place. Phase one read pqManager twice - a null check and then isTrained. close() does not take the parentMap monitor, so a teardown between the two turns the guard into an NPE. Read once, and the captured reference is what the plan carries. The resurrect path cleared a node's deleted bit before writing its PQ code, and it holds no builderLock, so a concurrent search could reach the node in the instant it was scored by the code it used to have. Every add path already writes the code before the node becomes reachable; this one does now too. An explicit optimize() left the bootstrap counter armed, because it does not go through runOptimizationIfDirty, so the next scheduled tick ran a second full pass for nothing. It is consumed when the switch it was asking for has happened. Finally, the deprecated trainCompressionIfNeeded silently does nothing for this mode. That is the right behaviour - a codebook without the encode and the rebuild is not a usable state - but it was not what the contract said, so the contract says it now. * GigaMap/jvector: do the PQ switch under the monitor, in one step Four review rounds on this switch produced fourteen findings, and the last round's four included two that were incomplete versions of the round before's fixes. The lock ordering was never the problem; the state machine around it was. The switch planned under the monitor, built with no lock, then adopted under the write lock, and every one of those transitions needed its own answer to what happens if the index moved, if the manager was replaced, if something threw, if the adoption was declined. This replaces the whole arrangement with a single step. performPqSwitch now runs entirely inside the monitor block that doOptimize already holds, and takes no builderLock at all. That is ensureGraphRebuilt's posture, documented there as unable to sit in a monitor/builderLock cycle: a thread holding only the monitor waits for no lock a write-lock holder needs. Nothing can move under it, so there is nothing to revalidate - no structuralModCount witness, no captured-builder identity check, no manager-identity check, no prepared-but-unadopted state, no discard, no retry arming. The four findings of the last round are gone with the code they were about, and so are several from the rounds before. Two things make it work. The replaced builder and graph are not closed. Searches hold the read lock and never the monitor, so one can be traversing the old graph at the instant it is replaced; closing it would pull the graph out from under that search. They are heap objects and the collector takes them, once per index generation. And the background indexing worker is not excluded, because it does not need to be. Its callbacks take the read lock only, so one can run throughout - but every callback was enqueued by a mutation that had already applied to the GigaMap under this monitor, so the snapshot taken here already reflects it. A callback still holding the old builder writes a change the replacement already has, into a graph that is not closed. One that finds the replacement goes through the idempotent add. On the scheduled path the question does not arise at all: the manager drains pending indexing ops inline on its single executor thread before calling doOptimize. Exception safety is now one try/finally rather than a matrix. If anything after training throws, the monitor is held and nothing has been published, so rolling the codebook back is unambiguous - it is this manager, and no other switch can have won a race for it. Two behaviours change beyond the restructuring. cleanup() now runs on the builder the switch published rather than the one it abandoned, because the captured reference is taken after the switch instead of before; a freshly built graph was previously left uncleaned. And the bootstrap that arms the first scheduled optimization is scoped to an index that already holds vectors, which is the case that cannot earn one. It was firing on the construction path too, letting an index of a few hundred vectors switch on the first tick without ever reaching minChangesBetweenOptimizations - contradicting both the build() warning and the documentation. Each behavioural test was checked to fail without the thing it pins: the concurrency test with the switch moved outside the monitor, the publication-order test with the codes published early, the threshold test with the bootstrap unscoped, and the code-refresh test with the vec-to-vec refresh removed. One pre-existing test was asserting more than the module promises. An embedded vec-to-vec update leaves graph connections alone by contract, so the updated entity is reachable from its new vector only once they are rebuilt; asserting it immediately passed or failed on how the graph happened to be wired, and it flaked. It now asserts after the rebuild, which pins the code refresh more tightly than the bare search did - a node whose code was never refreshed is re-linked at its old position and stays unreachable. * GigaMap/jvector: keep the optimization bootstrap out of the change counter requestInitialOptimization armed the next scheduled optimization by writing the threshold into optimizationChangeCount, and clearOptimizationRequest cleared it by writing zero. That counter is markDirty's, not the bootstrap's, so both ends of the request trampled on it: arming added changes nothing had made, and clearing erased changes something had. An explicit optimize() therefore dropped every mutation that had accrued but not yet reached minChangesBetweenOptimizations, and those mutations lost their claim on a later optimization - for a synchronous mutation the deferred graph op is drained after cleanup, so its node would not be cleaned again until another threshold-sized batch arrived. The request is now a flag of its own. runOptimizationIfDirty runs when either the flag is set or the count has reached the threshold, and clears the flag alongside the count afterwards; clearOptimizationRequest clears only the flag. The two pieces of state answer different questions - "this index was armed for an optimization it cannot earn" against "this much has changed" - and neither consumes the other now. The new test is set up so the erasure is the only thing that can decide its outcome: 300 changes before the explicit optimize() and 250 after, against a threshold of 500. Together they clear it, so a scheduled optimization must follow; each alone does not, so if the first 300 are erased none ever runs. Verified to fail on all three attempts with the old write restored. * GigaMap/jvector: scope the .pqv sidecar documentation to on-disk indices The PQ_IN_MEMORY section of advanced.adoc was written when the mode was on-disk only, and describes the sidecar unconditionally - "a {indexName}.pqv file that is read into heap when the index loads", and a whole subsection on the third file. The in-memory half of the mode, added further down the same page, says there is no sidecar at all. Both are right about their own case and the page did not say which was which. The sidecar text now says on-disk where it means on-disk, points at the in-memory section for the other case, and that section says in turn that none of the file discussion above applies to it. README.md already drew the distinction and is unchanged. Also a test for something the scoping of the optimization bootstrap could plausibly have broken and did not. A new index is deliberately not armed, because it is expected to earn its optimization through the change count - and under eventual indexing nothing bumps that count at mutation time, since enqueue only queues the operation. The count is bumped when the operation is applied, on the executor thread, so such an index does reach the switch on its own. The test pins it end to end, with no optimize() call anywhere: 300 changes against a threshold of 200, and the switch has to happen by itself. * GigaMap/jvector: keep each eventual callback inside one builder generation The monitor-only switch rests on an argument about background callbacks that was stated too broadly, and one path did not satisfy it. applyGraphUpdate read the index field for its containment test and then the builder field three more times, once per operation. Every one of those is an independent volatile read, and the switch publishes a replacement while holding no builderLock at all, so the method could straddle the publication: mark the node deleted in the graph being abandoned, then add the same ordinal to the replacement, which already carries it from the replay. That throws. applyGraphRemove had the narrower form of the same split, testing containment on one generation and deleting from another. Both now read the builder once and derive the graph from that reference, the way internalAddGraphNodeIdempotent already did. Within one generation the operation is correct either way: on the old builder it writes a change the replacement already has, into a graph that is deliberately not closed; on the new one it re-adds an ordinal that is already there, which the idempotent path tolerates. ARCHITECTURE.md said the callbacks "cannot corrupt the result" without this condition, and now states it. The switch also had nothing to say about teardown. close() takes the write lock without the monitor, so it can close the builder and the searcher pools while a monitor-only rebuild is running, and the rebuild would then publish over it - resurrecting a graph on a closed index, whose next search finds a null searcher pool. The three-phase version caught this with its captured-builder check under the write lock; that protection is restored, as a check that the builder the switch was planned against is still the index's own immediately before publishing. It narrows the window to the publishing writes themselves rather than closing it outright: doing that needs common exclusion between the switch and close(), which the pre-existing readLock-then-monitor cycle in embedded search currently rules out. And the optimization bootstrap was keyed off the wrong thing. It asked whether the index already held vectors, meaning to identify an index restored from storage - but an index registered on an already-populated GigaMap reads a non-empty count too, while being every bit as new, since its entities arrive immediately afterwards through the backfill and each one counts. It is now keyed off initializeAfterLoad, which is the one path that reaches a restored instance, and consumed when used so that a later re-initialization does not arm a second one. The test covers both registration orders; verified that the populated-map case fails on all three attempts with the vector-count form restored. One test correction. queuedGraphUpdatesSurviveTheSwitch asserted that callbacks really were outstanding when the switch ran, which depends on the background thread's scheduling and could fail a run in which nothing was wrong. The assertion is gone: whether a particular run overlapped does not change what must hold afterwards, because the guarantee comes from the snapshot being taken under the monitor rather than from the timing. An attempt to pin the overlap with a barrier is not included, and deliberately: adding an entity from the publication hook looks like one, but the hook runs on the switching thread and is therefore reentrant on the monitor, manufacturing an interleaving production cannot produce - a mutation started during the switch, which would otherwise have to wait for the monitor the switch is holding. * GigaMap/jvector: ask whether an index needs an optimization, rather than remembering that it did The bootstrap for an index that cannot earn a scheduled optimization was a request: armed once at initialization, cleared once consumed. Both ends of that were wrong in a way a flag cannot fix, and the two reviews of it asked for opposite corrections - clear it more eagerly, so a declined switch does not leave it standing; and clear it less eagerly, so an optimization that declined does not consume it. Both are right about a request. Neither is a problem for a question. There is no flag now. The background manager asks the index on every tick whether it needs an optimization it cannot earn, and the index answers from its current state: restored from storage, configured for in-memory PQ, not yet switched, and holding enough vectors to train. A restored index below the codebook's minimum answers no, so it costs nothing while it could not switch anyway; when enough vectors arrive it answers yes, and the switch happens on the next tick however far it still is from minChangesBetweenOptimizations. A remembered request would have been spent on the optimization that declined in between, with nothing left to ask again. Once the switch has happened the answer is no for good. requestInitialOptimization, clearOptimizationRequest and the flag behind them are gone, and so is the clearing call in optimize(). restoredFromStorage stays, but as what it always was - a fact about the instance, not a request, so it is no longer consumed. The publication order was also wrong, and this is the one that could corrupt a graph. Codes went last so that isPqCompressionActive() could not report a switch before the graph was in place. But the replacement builder scores every incoming node against the code store, and trackPqCode is a no-op while there are none - so a background callback that reached the new builder in the window before the codes were published would insert a node with no code of its own, link it by a code that was not there, and leave it that way. The codes go first now. Nothing else depends on the order: they are keyed by ordinal, ordinals are source entity ids, and both graphs carry the same ones, so codes visible before the graph are already correct for the graph still in place. What isPqCompressionActive() reports a few instructions early is true when it says it - a search at that moment really would score from those codes, and score correctly. The restored path had no behavioural coverage, which is how it could have been keyed off the wrong thing and stayed green. It has a real storage round trip now: store 300 entities, reload, and with the threshold at 50,000 and no optimize() call anywhere, the switch has to happen on a scheduled tick by itself. Verified to fail on all three attempts with the carve-out disabled. Two documentation contradictions found in the same pass. The deprecated trainCompressionIfNeeded still told callers the in-memory transition happens under the builder lock, which has not been true since it moved to the monitor. And VectorIndexConfiguration introduced approximateScoring as a dimension of the on-disk format, when PQ_IN_MEMORY governs traversal for an in-memory index too. * GigaMap/jvector: stop re-adding graph nodes that are already there The flake the reviewer saw was not a flake. queuedGraphUpdatesSurviveTheSwitch really did lose entity 902, and the same loss reproduces here about four runs in fifteen once the test asks the question precisely. internalAddGraphNodeIdempotent made an add idempotent by removing the ordinal first and then adding it back. removeNode strips the node's own entry from the graph but not the backlinks its neighbours still hold, so the next insertion that picks one of those stale references dies inside ConcurrentNeighborMap with "old is null". The callers that drain these operations catch and log, and the module has no SLF4J binder under test, so the throw was invisible - and it left the node removed and never re-added. A silently lost graph node, from an operation whose whole purpose was to be safe to repeat. It needed this change to become reachable in anger. The helper is older, but until this branch the background add callbacks did not go through it, and an ordinal it saw was one no graph held yet. Routing applyGraphAdd and applyGraphBatchAdd through it put it in front of ordinals that are already live - and after the in-memory PQ switch that is every queued add at once, because the replay has just inserted all of them. One pass of the drain would churn the entire graph through remove-and-re-add, and some node would not survive it. A node that is already there needs nothing added. The helper now refreshes the code, clears a deleted bit if one is set - an add for a present-but-deleted ordinal does mean the entity is back, which is what the resurrect path already does - and returns. The raw removeNode is kept only for the branch where the node is absent from layer 0, where it purges an upper-layer remnant that would otherwise make the add throw, and where there is no live node whose neighbours could be left pointing at it. Measured: dozens of swallowed NullPointerExceptions per run before, none after, across four runs; the test fails 4 of 15 times before and 0 of 15 after. The churn is gone as well, which is most of the work the drain after a switch used to do. The test was also asking the wrong question. It asserted that every entity is in its own top ten, which a search cannot answer: a node that is present but ranked out of the window is indistinguishable from one that is gone, so the assertion could report a loss for a recall wobble, and it needed approximate traversal to prove an exact property. It now reads the published graph and asserts membership directly. Recall keeps its own test, with a floor.
Section 12 still described the metadata layout as ending at structuralModCount "with the current format at v4", which section 10 contradicts on the same page - the format is v5 and carries four configuration fields after that one. The stale sentence predates the two format dimensions and was missed when they landed. Section 10 stays the one authoritative layout, and section 12 now points at it rather than repeating a version number that can drift again.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
An unresolved critical close/switch race and moderate PQ persistence, dimension-resolution, and lifecycle issues remain, along with documentation corrections.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Promotes jvector compression changes to main, including rc.9, format v5, NVQ storage, and configurable PQ scoring.
Changes:
| File | Summary |
|---|---|
gigamap/jvector/src/test/java/org/eclipse/store/gigamap/jvector/VectorIndexNullVectorTest.java |
Tests sparse and null-vector compression behavior. |
gigamap/jvector/src/test/java/org/eclipse/store/gigamap/jvector/VectorIndexInMemoryPqTest.java |
Tests in-memory PQ lifecycle and scoring. |
gigamap/jvector/src/test/java/org/eclipse/store/gigamap/jvector/VectorIndexConfigurationTest.java |
Tests configuration and compatibility behavior. |
gigamap/jvector/src/main/java/org/eclipse/store/gigamap/jvector/VectorStorage.java |
Defines INLINE and NVQ storage modes. |
gigamap/jvector/src/main/java/org/eclipse/store/gigamap/jvector/VectorIndices.java |
Supports configuration-aware index rebuilding. |
gigamap/jvector/src/main/java/org/eclipse/store/gigamap/jvector/VectorIndexConfiguration.java |
Adds compression configuration APIs and presets. |
gigamap/jvector/src/main/java/org/eclipse/store/gigamap/jvector/TrainingVectorProvider.java |
Provides training samples. |
gigamap/jvector/src/main/java/org/eclipse/store/gigamap/jvector/PQCompressionManager.java |
Manages PQ training and compression. |
gigamap/jvector/src/main/java/org/eclipse/store/gigamap/jvector/NVQCompressionManager.java |
Manages NVQ training and encoding. |
gigamap/jvector/src/main/java/org/eclipse/store/gigamap/jvector/GraphFormat.java |
Encapsulates persisted format settings. |
gigamap/jvector/src/main/java/org/eclipse/store/gigamap/jvector/DiskIndexManager.java |
Implements format v5, NVQ graphs, and PQ sidecars. |
gigamap/jvector/src/main/java/org/eclipse/store/gigamap/jvector/BackgroundTaskManager.java |
Supports restored-index optimization scheduling. |
gigamap/jvector/src/main/java/org/eclipse/store/gigamap/jvector/ApproximateScoring.java |
Defines traversal scoring modes. |
gigamap/jvector/README.md |
Updates user-facing configuration documentation. |
gigamap/jvector/pom.xml |
Upgrades the jvector dependency to rc.9. |
gigamap/jvector/ARCHITECTURE.md |
Documents format and lifecycle internals. |
docs/modules/gigamap/pages/indexing/jvector/use-cases.adoc |
Updates use-case examples. |
docs/modules/gigamap/pages/indexing/jvector/index.adoc |
Updates feature and limitation documentation. |
docs/modules/gigamap/pages/indexing/jvector/configuration.adoc |
Documents configuration options. |
docs/modules/gigamap/pages/indexing/jvector/advanced.adoc |
Documents compression, formats, and sidecars. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…encoder does, and end the restored generation at removeAll Two defects found reviewing the promotion, both narrow, both permanent once reached. GraphFormat resolved the automatic subspace sentinel as dimension / 4, while PQCompressionManager resolves the same sentinel as Math.max(1, dimension / 4). Below dimension four those disagree: the manager encodes one byte per vector and the metadata records none. A dimension that small is legal, since the builder asks only that it be positive, and sidecarFitsTheGraph compares exactly those two numbers - so an on-disk PQ_IN_MEMORY index at dimension one, two or three would reject its own sidecar and rebuild on every load, silently, because a rejected load self-heals from the store. The clamp is now in both places, and GraphFormatTest pins the resolution against the encoder's rather than against a literal, so the two cannot drift apart again. restoredFromStorage was never cleared when internalRemoveAll tore the index down and re-initialised it. What comes back from that is a new, empty generation whose entities arrive afterwards and are counted like any other index's, so it earns its optimizations the ordinary way - but the flag kept claiming the carve-out reserved for an index that cannot earn one, and a refill past the codebook's training minimum could then switch on a scheduled tick while nowhere near minChangesBetweenOptimizations. It is cleared in closeInternalResources, which is the teardown that ends a generation and is reached from both removeAll and close, and from nothing else. Both tests were checked to fail without their fix: the subspace one on dimensions one through three, the removeAll one on all attempts, with reruns disabled. Also brings the write-path and load-path sections of ARCHITECTURE.md up to the implementation. They still described writeIndex as taking a pq manager and choosing between a fused graph and a plain one, which predates NVQ and the sidecar entirely, and the load path still spoke of verifying four metadata fields when there are nine and a sidecar to check beside them.
|
Round one on the promotion. Four findings, three fixed in Two were real defects, both narrow and both permanent once reached.
Both verified to fail without their fix, reruns disabled. The documentation finding was correct and understated. The write-path section described a The Worth keeping in proportion: the scheduled path cannot reach it, since 272 default / 176 slow, green, |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Unresolved critical persistence and concurrency issues remain.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 4
In code that hasn't changed since last review
gigamap/jvector/src/main/java/org/eclipse/store/gigamap/jvector/VectorStorage.java:28
INLINE alone does not make traversal read full-precision vectors: with ApproximateScoring.FUSED_PQ, the fused PQ codes still drive traversal and can miss candidates. The decision guide's “Maximum recall” row should qualify the recommendation as INLINE + NONE (and explain that the scoring dimension can independently introduce approximation).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…h for a manager a teardown can have taken Two defects in the persist path, both found reviewing the promotion. A persist that trained a codebook could then skip the write. The decision to skip is made on the same "is training pending" predicates that training has just turned false, and training runs first, so an index that was otherwise idle trained a codebook and then took the shortcut past the write that was the entire reason it trained. The codebook lived in heap only, and every later persist skipped for the same reason - the index stayed uncompressed on disk for good while reporting compression as configured. The route in is the shutdown persist, which deliberately does not train, because shutdown must not wait for k-means. An index closed without an earlier persist therefore leaves an uncompressed graph and comes back incremental, clean, and with training due, which is precisely the state the shortcut is for. trainCompressorsBeforeLocking now reports whether it trained anything that is not on disk yet, and a persist that did cannot skip. The test measures the graph file across the two sessions: without the fix it stays byte-identical at 100,876 bytes, which is the clearest statement of the bug there is. The same method also read this.pqManager and this.nvqManager again after releasing the monitor, to train through them. It already knew better one block earlier - it re-reads both under the monitor with a comment explaining that ensureIndexInitialized recreates them - but training deliberately runs with no lock held, and internalRemoveAll and close take the write lock without this monitor and null both fields. A persist concurrent with either could therefore throw a NullPointerException out of trainFrom. Both references are now captured under the monitor and used throughout, including by the decline witnesses at the end. One observation recorded rather than acted on, since it is neither of the above: jvector's PQ training tolerates the degenerate inputs one would expect it to reject - 300 identical vectors, 300 zero vectors, two distinct values - and trains a codebook for all of them. It fails only on NaN or infinity, and it fails there through a Java assert, so it raises an AssertionError rather than a RuntimeException. The catch around training handles RuntimeException, so with assertions enabled such a vector aborts the persist instead of falling back to an uncompressed graph, and without them the codebook is simply trained on the bad input. Worth its own change.
… not just storage VectorStorage's decision guide recommended INLINE for maximum recall on the grounds that traversal reads full precision. That is only true when the scoring dimension leaves it alone: with FUSED_PQ or PQ_IN_MEMORY the codes drive traversal whether the vectors beside them are quantized or not, so INLINE on its own buys an exact reranking pass and nothing about which candidates reranking gets to see. The row now names INLINE with NONE, and says why that one row needs both settings when the rest of the table is about storage alone.
|
Round two. Three findings fixed across Two real defects in the persist path, both pre-existing from #828 and #830 rather than anything the promotion introduced. A persist that trained a codebook could then skip the write. The skip is decided on the same "is training pending" predicates that training has just turned false, and training runs first - so an otherwise idle index trained a codebook and then took the shortcut past the write that was the entire reason it trained. It lived in heap only, every later persist skipped for the same reason, and the index stayed uncompressed on disk for good while reporting compression as configured. The route in is not exotic: the shutdown persist deliberately does not train, because shutdown must not wait for k-means. An index closed without an earlier persist therefore leaves an uncompressed graph and comes back incremental, clean and with training due - exactly the state the shortcut is for. The test walks it across two sessions and measures the graph file: without the fix it is byte-identical at 100,876 bytes. The same method dereferenced The The sidecar finding I could not substantiate, so I have not acted on it. It needs a PQ training failure that throws a
The only failures I could produce are If there is a The 272 default / 177 slow, green, |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
One or more issues must be addressed before approval.
Review effort: Lite
Findings: 2
In code that hasn't changed since last review
gigamap/jvector/src/main/java/org/eclipse/store/gigamap/jvector/ApproximateScoring.java:48
This description is inconsistent with the actual search dispatch: INLINE + NONE returns the exact provider backed by the GigaMap, while NVQ + NONE traverses using the graph's quantized vectors. Calling this mode “no approximate scoring” and saying it always reads the graph's storage misstates both the lookup cost and the candidate-selection behavior; please describe the two storage cases explicitly.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
ApproximateScoring.NONE described itself as scoring "directly from whatever VectorStorage the graph carries", one read per candidate. That reads as one behaviour with a storage-shaped detail, and it is two: with INLINE traversal scores exactly, from the full-precision vectors in the GigaMap, and with NVQ it scores from the graph's own quantized copy - approximate, despite the name of the constant, and cheaper per hop because nothing is read from the GigaMap until reranking. The difference that matters is not the lookup cost but candidate selection. Quantization error changes which nodes traversal visits, and a node it never reaches is one the exact reranking pass cannot recover. Both cases are now spelled out, together with the part that does hold for both: reranking is exact, so the scores and the ordering returned are exact either way. That also makes the maximum-recall guidance in VectorStorage legible from this side - INLINE with NONE is the one pairing that is exact all the way through.
|
Round three, and it is converging: both persist-path fixes from last round are confirmed resolved, and the only new finding is a documentation one, fixed in
On the two standing findings, my position is unchanged, and for the sidecar one I went and tested it harder rather than repeating myself. Twenty-one input shapes now, and PQ training succeeds on all of them - the degenerate values, twelve dimensions that do not divide evenly by four, exactly 256 vectors and 257, more subspaces than dimensions. The only failures remain NaN and infinity, which raise an I have left both open rather than resolving them, because in both cases the reasoning is sound and only the trigger is unestablished or the fix is out of scope here:
272 default / 177 slow, green, From here this is a review decision rather than more work: both remaining items are judgement calls about scope that I have argued one way and can implement the other way in minutes if the call goes differently. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Unresolved documentation and implementation clarifications remain for sidecars, fallback scoring, and training edge cases.
Review effort: Lite
Findings: 2
In code that hasn't changed since last review
gigamap/jvector/src/main/java/org/eclipse/store/gigamap/jvector/NVQCompressionManager.java:47
trainFrom explicitly returns without training when the collected sample is below MIN_VECTORS_FOR_NVQ_TRAINING (16), which can occur for sparse/null-embedding corpora even when the entity count passes the gate. Therefore “Training cannot decline” and the claim that only exceptions need a witness are inaccurate; document the small-sample guard so maintainers do not remove the retry-suppression logic or assume a quantizer is always available.
gigamap/jvector/src/main/java/org/eclipse/store/gigamap/jvector/VectorIndexConfiguration.java:301
This API documentation still says the directory contains only .graph and .meta, but PQ_IN_MEMORY also creates a required {name}.pqv sidecar containing the codebook and codes. Please document that conditional third file here so callers do not omit it during backup or cleanup.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…n the directory listing Three places asserted that NVQ training cannot decline, on the reasoning that a mean is defined for any non-empty sample and only an exception could leave the manager untrained. The reasoning is right about the mathematics and wrong about the code: trainFrom returns without training below MIN_VECTORS_FOR_NVQ_TRAINING, a sanity floor of 16 that exists so the quantization range is not fitted to a handful of points the rest of the data will not resemble. An embedded index with enough entities and too few embeddings reaches it, because the count that gates the attempt is parentMap.size() in that mode. The behaviour was never wrong - nvqTrainingFailedAtModCount is set whenever an attempt leaves the manager untrained, so it already covers the decline as well as the exception. Only the documentation was, and it was the kind that invites someone to remove the retry suppression as dead weight, or to assume a quantizer is always there after a successful persist. All three now say what the floor is, when it is reached, and that the witness covers both outcomes. Separately, the indexDirectory contract listed only the graph and the metadata. PQ_IN_MEMORY writes a third file, and it is not incidental: the graph header carries no codebook in that mode, so the sidecar is the only copy, and an index whose metadata says it traverses on PQ codes is rejected and rebuilt from the store when it is missing. Callers copying or pruning the directory need to know that, so the listing now names it, says when it appears, and says to keep it with the graph.
|
Round four. No new code findings - the two open items are the standing ones. Both new documentation findings were correct, and the first of them caught a factual error of mine. Fixed in "NVQ training cannot decline" was simply untrue, in three places. I had reasoned from the mathematics - a mean is defined for any non-empty sample, so only an exception could leave the manager untrained - and the code disagrees: The behaviour was never wrong: The The two standing findings are unchanged and remain open deliberately, with the reasoning in their threads: the 272 default / 177 slow, green, |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
One or more issues must be addressed before approval.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…the index doPersistToDisk trains before it takes any lock, because k-means is seconds to tens of seconds and holding the write lock for it would stall every search. A close that starts later can therefore finish first: it shuts the background task manager down, tears the transient state down under the write lock, and returns. The persist then takes the lock, finds nothing there, and calls ensureIndexInitialized - which rebuilds the builder, the disk manager and a fresh background task manager. The caller does not re-check the field, so that executor thread outlives close() with nothing left to shut it down. The hazard was already understood on the shutdown path, where a guard skips exactly this and its comment spells out the leak. It was never extended to the ordinary one, and there it cannot be written the same way: "no index present" also describes an index that has simply never been used, which a persist should initialise rather than refuse. So the discriminator is explicit. close() sets a closed flag, and doPersistToDisk checks it as the first thing it does under the write lock. Both sides touch it while holding that lock, which is where the guarantee comes from rather than from the field being volatile: either the persist reads it and stops, or it takes the lock first and close waits for it to finish. internalRemoveAll deliberately does not set it - that teardown is followed by a rebuild, and such an index must still initialise on demand. The test drives the two calls in sequence rather than racing them, since the ordering is settled by the lock rather than by timing, and asserts on the background manager because that is the part that leaks a thread. It needed a configuration that actually runs one: the first version used a config with no background features at all, so nothing was recreated either way and it passed with the guard removed. With one configured it fails without the guard, holding a live BackgroundTaskManager after close().
|
Final Copilot round. One new finding, and it was a good one - fixed in A persist that arrives after This is not the switch race, and unlike that one it closes cleanly: the persist takes the write lock and The hazard was already understood on the shutdown path, where a guard skips exactly this and its comment spells out the leak. It had simply never been extended to the ordinary path. The test earns a note of its own: the first version of it was useless and said so. It used a configuration with no background features, so nothing was recreated either way and it passed with the guard removed. With a background manager configured it fails without the guard, holding a live Closing state
The two tracked items are the in-memory PQ switch publishing over a closed index - whose obvious fixes are blocked by pre-existing lock-ordering cycles - and the sidecar-after-deterministic-training-failure case, whose trigger I could not produce across 21 input shapes. Both carry their full analysis, a proposed design, and in the second case a separate defect found while probing it: NaN and infinity embeddings fail through jvector Everything else the review raised across the five rounds is fixed, with each behavioural fix checked to fail without its change. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…memory switch costs A single NaN component made a quantized index return nothing at all, permanently. validateVector checked null and dimension and nothing else, so the value reached the quantizer - which fits its parameters to the data, so it propagated into the global mean and the per-subvector ranges and from there into every vector the graph stores. Traversal then scored NaN against everything, no candidate compared greater than another, and search came back empty. Measured on NVQ with NONE scoring: ten hits before the persist that trains the quantizer, zero after. It did not heal when the offending entity was removed, because the quantizer is adopted from the loaded graph rather than retrained - the index stayed blank until rebuilt from scratch. INLINE with FUSED_PQ and NVQ with FUSED_PQ survived it in the same probe, and the exact modes are unaffected by construction, since they fit nothing to the data. NaN is not an exotic input. Normalising a zero vector produces it, and so does any division by a zero norm in an ordinary embedding function. So it is refused at the door, for embeddings and for query vectors alike. A query cannot poison anything, but it cannot answer anything either - every comparison against NaN is false - so it now says so instead of returning an arbitrary result or none, silently. Also documents what the in-memory switch to PQ_IN_MEMORY costs, which was understated. The existing text said the switch holds the GigaMap lock and that a large index makes it an O(n) rebuild. It did not say how long that is, and the number is the part that matters: measured at dimension 64, about 2 s at 5,000 vectors, 4 s at 10,000, 10 s at 25,000, 19 s at 50,000, so several minutes at a million. Every write to the map waits for the whole of it, and it is triggered by the background optimization rather than by anything the application chose - so the documentation now says to call optimize() at a quiet moment on a large index rather than leaving it to the scheduler. Finally, mutationsAfterTheSwitchStayConsistent asserted something no search can answer reliably, and had been failing about once per full suite run. An embedded vec-vec update refreshes the node PQ code and leaves its edges alone, and optimize() does not put that right: cleanup() prunes and re-diversifies neighbourhoods a node already has, it never re-inserts a node where its new vector moved it to. Only a persist rebuilds from the store. So a narrow search window measured whether traversal happened to stumble onto the node through its old neighbours - it failed at k=5 and still failed at k=25 - while a graph-spanning beam width fixed the flake by destroying the test, because with every node visited the exact reranking pass returns the entity whether its code was refreshed or not. The assertion now reads the code store directly: the updated ordinal must score better than every other ordinal for a query at its new vector, which holds only if its code encodes that vector. Deterministic across twelve runs, and it fails on all three attempts with the refresh removed.
|
Both findings addressed in 1. Non-finite vectors are rejectedConfirmed and reproduced, and the reproduction narrowed it: with assertions disabled, as in production, it is Worth noting for the severity: with assertions enabled the failure looks completely different -
2. The switch cost is documented, with numbersI measured it independently rather than relaying yours, and the two agree. At Now in three places: 3. The flaky test, which turned out to be a real misunderstanding of mine
Widening the window does not fix it - it failed at k=5 and again at k=25 - and widening the beam until traversal spans the graph fixes the flake by destroying the test, because with every node visited the exact reranking pass returns the entity whether its code was refreshed or not. I tried that and caught it passing with the code refresh deliberately removed. It now reads the code store directly: the updated ordinal must score better than every other ordinal for a query at its new vector, which holds only if its code encodes that vector. Deterministic over twelve runs, and it fails on all three attempts with the refresh removed. The two full-suite runs since are clean. 272 default / 181 slow, The two open findings stay as you found them - tracked, with their analysis, and resolved on the threads as tracked, not fixed so the green checks do not read as repairs. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The persistent-format migration and concurrency-sensitive compression lifecycle require final human validation.
Review effort: Balanced
Findings: None
In code that hasn't changed since last review
trainCompressionIfNeeded() can still create an unpersisted codebook on a loaded, clean…gigamap/jvector/src/main/java/org/eclipse/store/gigamap/jvector/VectorIndex.java:3956
trainCompressionIfNeeded() can still create an unpersisted codebook on a loaded, clean incremental index. Because this call trains the manager outside doPersistToDisk(), the next persist gets trainedForThisPersist == false; isPqTrainingPending() is also false once training succeeds, so the clean-incremental shortcut skips writeIndex(). The index then reports PQ as active while the graph or .pqv remains uncompressed until another graph mutation forces a write. Record that this method trained new state and make the next non-shutdown persist bypass the clean shortcut.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…each the disk too The same defect as the one fixed for the persist path, reached through the other door. trainCompressionIfNeeded exists so a caller can pay the training cost at a moment of their choosing rather than inside a persist, and doing so leaves the state a persist would otherwise have produced for itself already made. Both questions the clean-incremental shortcut asks then answer the wrong way round: this persist trained nothing, and nothing is pending either, because the manager is already trained. So the shortcut skipped the write, the codebook stayed in heap, and every later persist skipped for the same reason - leaving the index reporting compression as active while the graph on disk did not carry it. The persist cannot infer this, so the call records it. The flag is cleared once a persist has actually written rather than once one has started: a persist that fails on the way leaves the codebook exactly as stranded as it was, and the next one has to know that. Verified the same way as its twin, on the graph file across two sessions: without the fix it stays byte-identical at 100,876 bytes.
|
This round reported no findings and confirmed the A codebook trained through My earlier fix tracked training done by the persist. It could not see training done before one, and the persist has no way to infer it, so the call now records it. The flag clears once a persist has actually written rather than once one has started: a persist that fails on the way leaves the codebook exactly as stranded as it was, and the next one needs to know that. Verified the same way as its twin, on the graph file across two sessions - without the fix it stays byte-identical at 100,876 bytes, the same signature the first one had. 272 default / 182 slow, I am not requesting another review - this one arrived on its own after the previous push rather than by request. If the automation posts one more, the two tracked follow-ups are the only things I expect it to keep raising. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…st its writers The documentation added for the switch cost said that writes wait and searches carry on against the pre-switch graph. The second half is wrong, and wrong in the direction that matters: everything the map does waits, reads included, and searches against this index most of all. The reasoning behind the claim was that a search takes only the read lock while the switch takes no builderLock at all, so the two cannot exclude each other. That overlooks the first thing a search does. ensureIndexInitialized runs before the read lock is taken, and it enters the parentMap monitor to settle the deferred graph rebuild - so a search arriving during the switch blocks there, before it ever reaches the index. The ordering is deliberate and documented on ensureGraphRebuilt; it simply was not carried through into what the switch costs. Measured at 20,000 vectors on four threads started 400 ms into a switch of 8.6 s: search waited 7.9 s against a 5 ms baseline, and get, iterate and add waited the same 7.9 s. The first attempt at this measurement timed the search and the get on one thread, which made the get look unaffected because by then the switch was over - worth recording, since that is exactly the shape of mistake the original claim was. All three places now say the same thing: advanced.adoc, the README limitation, and the release note in the promotion PR. The table gains a 20,000-vector row from these measurements.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.