Repository navigation
Conversation
A cleanup scan can now start just past the token of a row it issued, in that row's lane, instead of at the first lane's prefix. A resumed scan seeks past the rows already deleted instead of reading their tombstones. Only a scan from the start proves a namespace empty. The lifecycle driver's scans still start at the first lane.
`VectorBulkBuildTuning` holds the construction threads, the fewest vectors a bulk build is started for, and the memory bulk builds may hold together (`VectorBulkBuildMemory`): off, which is the default, automatic, or an explicit byte count. The automatic budget is what the process's memory ceiling leaves beside the larger of its configured memory and what the rest of the process holds, with an eighth of the ceiling kept free. `DbConfig::configured_memory_bytes` is what the configuration lets the process hold (caches, vector stores, the build planning cache and the write buffer), `DbConfig::write_buffer_bytes` the write buffer alone, and `config::resident_anonymous_bytes` the anonymous memory the process holds now.
`LabelSource::over` reads the rows of ids the caller took from the label's bitmap itself, by one scan where they are dense in their key range and by point reads otherwise, as a build step's source does, under `ReadBounds` instead of one step's limits. `LabelSource::open` is now that reader over the ids one step takes. `upper_id`, `cursor_id` and `source_key` give a reader the build's bound, the id a cursor stands at and the key of an id's row.
`BulkVectors` holds the vectors of a source in entity order and `BulkGraph::construct` links them on a given number of threads, with the caller's layer for each node and the degree limits, beam widths and neighbor selection a serial insert uses, counting the vectors it has linked and stopping when cancelled. `BulkGraph::unlink` removes a node whose entity changed after it was read. Every neighbor that lost its link to the node is linked again from the neighbors and their own neighbors, with the selection the serial delete uses, so a graph many nodes were unlinked from stays as densely linked as a serial build under the same deletes. The graph stays symmetric: a node a full row refuses is not linked, and a neighbor keeps the links it has. Every link change is recorded (`LinkChange`), so rows already stored can be staged again. An unlink runs on the calling thread and costs 4.3 ms at 128 dimensions and 20.9 ms at 1,536, at the default degree. `VectorIndex::stage_bulk_node`, `stage_bulk_link_change` and `stage_bulk_metadata` stage a graph's rows through the typed writers a serial insert uses: the rows have today's encodings and differ from a serial build's only in which edges they hold. Nothing uses the builder yet.
`IndexOperationDriver::parked_until` names an operation whose next step could only wait for something the process will signal. The step that parks an operation releases its claim with its own commit, so the family's lane goes to other operations at once, and the dispatcher passes over the operation until the driver stops reporting it or the returned time passes. The default never parks.
A validation step read as many applied-state rows as the entity ceiling lets a scan step decode, 512 by default, and proved the partition of every one of them with a metadata read. A build of a million entities took 2,000 such steps and 90 s on S3: little beside a serial scan of half an hour, and 40% of a build whose scan stores a graph linked in memory, which the next commit adds. A step now reads up to 4,096 rows, which it only deletes, and proves a partition once for the rows that follow one another in it: every read of a step sees one snapshot, so the next row of the same partition proves nothing more. The entity ceiling still bounds the partitions a step proves, and the transaction ceilings what it deletes, so a step that fences writers stays short. An unpartitioned build validates in a few hundred steps; a partitioned one whose every row names another partition validates as before.
A bulk build does the work of the serial `Scan` stage in three passes: it reads the rows of the label's members into memory, links the whole graph in parallel, and writes every row once from lifecycle steps that reread the source, so an entity changed since it was read is left to its queued operation. It reads the source the serial scan reads, the label's bitmap up to the build's bound. The read pass takes the members once and reads their rows in runs, each under a snapshot of its own, so no transaction is open for the length of the read; a run that storage fails for a moment is read again in place. Stored state. A bulk attempt is stored as vector build stage 0x07: the serial scan's progress and one `u8`, the bulk attempts started for the operation since it was last at the serial stage. After three attempts that did not store their graph the build scans serially. Nothing else stored changes: rows are written by the writers a serial insert uses. A release from before this one cannot decode the stage and refuses to open the database as a writer while a build is at it, so bulk builds are off unless `HELIX_VECTOR_BULK_BUILD_MEMORY_BYTES` turns them on (`auto` or a byte count; unset or `0` is off), and with them off no bulk stage is stored. A build that blocks, or that runs with bulk builds off, first deletes what it stored and returns to the serial stage, so a blocked record is one every release reads. Failures. A bulk attempt that fails where a serial build may not (a construction or staging thread that does not start or panics, a write step that panics, a torn graph, an upload of the count that fails for good) never blocks the build and is not tried again: what it stored is deleted and the serial scan builds the index at once. Source changes. A row changed after the read pass is taken out of the graph before the graph is written, on the lifecycle step, which costs 4.3 ms a row at 128 dimensions and 20.9 ms at 1,536. A step spends at most a quarter of a second on such rows. A build whose unwritten nodes would hold, at the share changed so far, more changed rows than an eighth of the graph gives its attempt up and scans serially at once: bulk is the slower way past a changed share of 14% at 1,536 dimensions. Memory. A build reserves its memory before it reads a row, for the exact number of the label's members, and scans serially when no budget would hold it. The budget is measured against what the rest of the process holds while no build runs; what builds leave resident is taken to be theirs, so a build that fitted before another ran fits after it, and what is resident beyond everything the builds reserved is the rest's. A build that cannot reserve the whole write buffer writes only while the memtables hold less than two flush windows. Waiting. A build that waits for its turn, for the memory of running builds, for its own read and link passes or for a flush parks its operation and takes no step until it is woken. Status. `vector_build_path` reports how a build constructs its graph and `vector_bulk_build` the bulk attempt, its phase and its progress. A writer reports the bulk stage for as long as a restart would find it: until the step, or the abort, that left it is uploaded.
The server reports `vector_build_path` and `vector_bulk_build` in the status of a vector build. No SDK models them; each one's decoding test now covers a status that carries them.
The setting that turns them on and why it is off by default, the status fields, what an attempt is and when the build falls back to a serial one, what discarding and aborting a partly written build cost, and the rules for upgrading and for rolling back to an image from before them (v0.0.18 and earlier). Regenerates the docs bundle.
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
| let durable = match self.storage() { | ||
| HelixStorage::Writer(writer) | ||
| if sightings.is_some() || index_lifecycle::is_aborting_vector_build(&operation) => |
There was a problem hiding this comment.
get_index_operation reads sightings before opening its snapshot. After a restart with bulk builds disabled, the call can read None, pause, then resume after the worker has deleted the abandoned graph and applied Scan, but before that change uploads. The saved None skips the durable read, so the response stops reporting the bulk stage while storage still contains 0x07.
An operator following the rollback instructions can then start an older image that refuses the store and takes the writer role from the running server. Check sightings again after reading the applied record, while keeping the protection against forgetting newer sightings.
| let min_vectors = self.tuning.min_vectors().max(1); | ||
| if rows < min_vectors || (!*probed && source.holds_fewer_vectors_than(min_vectors).await?) { | ||
| return Ok(Begun::Next( | ||
| self.serial(operation_id, VectorSerialBuildReason::TooFewVectors), | ||
| )); | ||
| } | ||
| *probed = true; |
There was a problem hiding this comment.
begin runs holds_fewer_vectors_than before checking the memory budget or acquiring the preparation turn. With the default threshold, this can read and decode 4,096 vector rows, or inspect up to 32,768 members, inside one lifecycle step—even when the build cannot fit.
The probe spans multiple 64 MiB runs without stopping at the step's total input-byte limit. Large source rows therefore make other vector operations wait through a long scan before this build falls back to serial. Reject builds that cannot fit before probing, and give the probe a total byte or step bound.
| impl Drop for Turn { | ||
| fn drop(&mut self) { | ||
| self.parking.wake_all(); | ||
| } |
There was a problem hiding this comment.
Turn::drop wakes waiting builds before _permit is dropped. On another runtime thread, a woken build can call try_acquire_owned while the permit is still held and park again. Releasing the permit then sends no further wake through Parking, leaving the build idle until another event or the 30-second deadline.
Release the permit explicitly before calling wake_all.
Three contracts failed on CI's runners and passed on a fast machine. Two asserted how many nodes a step unlinks, under the driver's real bound of 250 ms of unlinks a step: a slow, busy runner reaches the time before the count. The contracts' drivers now unlink without a bound in time, so a step unlinks by its counts on every machine, and only the contract of the time bound sets one. One retried a step whose lost commit had started the build's read and link passes, and expected the retry to collect them. Offered while they still ran, the retry parked and stored nothing. The retry now waits, as the worker does, until the passes have woken the build. The wait for a parked build no longer fails after the 30 s park limit, which the passes of a source of a few thousand rows can exceed on a starved machine: it and the two other waits for background tasks share one liveness bound of ten minutes. Tests only.
This adds an in-memory "bulk" path for building an unpartitioned vector index. On real S3 it builds a 1M x 128-dim index in 143 s against 1,775 s for the serial build on main, with the same recall.
It is off by default. One stored byte is new (below), and an older image refuses a store that holds it, so this release only teaches every image to read it. Turn it on with
HELIX_VECTOR_BULK_BUILD_MEMORY_BYTES=auto(or a byte count) once every node that can become writer runs an image with this change.How it works
When it falls back to the serial build
Stored data
One change, already approved: build stage byte
0x07in the index operation record, carrying the existing source-scan payload plus oneu8(bulk attempts started). Nothing else stored changes: no new key, value field, tag, merge operand, WAL content or storage version. A bulk-built graph uses today's row encodings; only the edges differ from the ones a serial build would choose.With the feature off, no
0x07is ever written. Turned off mid-build, the build deletes what the attempt stored and returns to the serialScanstage, which an older image reads.Numbers
Real server on real S3, release, aarch64, binary built from the head of this branch. Single runs unless it says otherwise. The serial baselines are main's.
0x07; with bulk turned off the build returns toScanand the older image opens the store and finishes it.Also in this PR
Validate a vector build's applied state 4,096 rows a stepis its own commit. It applies to every vector build, serial and partitioned included, and is not switched by the bulk setting.Resume a vector cleanup scan after a deleted row: the bulk path deletes an abandoned attempt's rows in bounded steps and resumes after the last row it deleted. Existing cleanup behaviour is unchanged.vector_bulk_buildobject (attempt, limit, phase, progress, wait reason). No new stage names; the Go, Python, TypeScript and Rust SDKs decode it.Not covered
readyzwith 200 while every request fails, and at 1M rows about 0.5% of rows are not returned by a search with their own vector under either build path.Testing
commands::auth::tests::the_callback_port_is_free_again_after_the_callbackin the CLI suite fails with "Address already in use" in 3 of 10 suite runs and passes alone. This branch does not touchcrates/cli.