Engineering · Ingestion, measured

54,000 pages searchable in under 10 minutes All 368 FinanceBench filings, with crash-safe checkpoints on, in 9.6 minutes instead of 12.1. Adding embedding hosts did nothing: the limit was our own code.

In 30 seconds
  • We take the 368 public filings of FinanceBench, 54,120 pages, and measure how long until every one of their 561,645 passages is searchable. In November it took 12.1 minutes, and later builds were slower.
  • The import stalled at about 550 passages a second whether we used two embedding hosts or three. The hosts were not the limit. Our own Python was: the per-passage work around each call ran in just two processes.
  • Six fixes, each measured: vectors sent as binary, a token count skipped when it cannot matter, more embedding processes, embedding workers that write to the database themselves, crash-safety checkpoints written 16 parts at a time instead of one by one, and one storage client kept instead of a new one for every call.
  • Result: 9.6 minutes with checkpoints on, 8.9 with them off, on 10 rented servers.
9.6 min
54,120 pages searchable, checkpoints on (12.1 in November)
1,900/s
Passages a second at peak, against a ceiling of about 550 before
5×
Less CPU per passage in the embedding step (1.64 ms to 0.31 ms)

Searchable: every passage written to the vector database and every document reported ready. Times from the first byte uploaded.

The wrong suspect

More hosts, same speed.

Every passage is turned into a vector by an embedding model (bge-m3) that we rent from hosted providers. When the import slowed, the hosts looked like the obvious cause: they throttle, they answer "too many requests". So we added a third one. Nothing changed: about 550 passages a second with two hosts or three, with 64 or 128 calls in flight.

The hosts were in fact mostly idle: in six minutes they had received a few hundred calls, while each embedding job took 100 to 120 seconds. The time went somewhere between the job and the host. Every embedding job did three things in Python before and after its call: it counted the tokens of each passage with the model's tokenizer, it decoded the reply (a thousand numbers per passage, written out as text in JSON), and it read the whole section of the document it came from to pick out its own 256 passages. And all of it ran in two Python processes for the whole fleet, one on a permanent server and one on the head of the burst. A Python process runs one thread at a time, however many cores the server has.

Fix 1

Five times less CPU per passage.

  • Vectors as binary. The embeddings API can return each vector as one base64 string of raw floats instead of a list of numbers in JSON. On DeepInfra the reply for 128 passages went from 2.9 MB to 0.7 MB, and decoding from 0.32 ms to under 0.05 ms per passage. OpenRouter accepts it too; Cloudflare ignores it and still answers in JSON.
  • No tokenizer when it cannot matter. The count existed to refuse a passage too long for the model. But no tokenizer produces more tokens than a text has bytes, so a passage with fewer bytes than the model's limit cannot be too long, and needs no count. That holds in any script: a Chinese character is three bytes and about one token, so it is counted high, never low. Only a text long enough to come close is counted for real.
  • Each job reads only its own texts. The step that cuts a document into passages now also writes, once, the texts to embed; an embedding job reads that short list instead of parsing the whole section three times over.
  • Half-size vectors. The database stores vectors as 16-bit floats, so the workers now save them that way too: half the bytes to storage and back.

Measured on the same 2,048 passages: the CPU of the embedding step fell from 1.64 ms to 0.31 ms per passage. And the embedding readers now run in several processes: four on the head of the burst, which has 16 cores, two on the permanent server.

Fix 2

The next wall: writing to the database.

Embedding sped up, and the import reached about 780 passages a second, then stopped climbing. This time the queue that filled was the write queue: over a thousand batches waiting. Each batch was written by a separate job that downloaded the section's passages again, downloaded the vectors the embedding job had just saved, rebuilt the records and only then wrote them.

Worse, the burst servers had never been given the address of the vector database. Every write of the whole fleet ran on the permanent server's eight write workers, the same server that also runs a database node.

Now the embedding job writes its own batch: it already holds the passages and the vectors, so the second download, the second parse and the round trip through storage disappear. Each process allows four writes at once, so the database is never flooded. The vectors are still saved to storage on the side, for recovery. And the burst head now reaches the database over the private network. A batch whose embedding job cannot write, on an older worker for instance, still gets a write job of its own: nothing is lost silently. The result: 1,900 passages a second at peak, and the whole library in 8.9 minutes.

Fix 3

Crash safety, without the crash in speed.

A web server can stop at any time: a deploy, a crash. So every document's ingest is a durable workflow (we use DBOS on Postgres): each answer from the fleet is recorded as it arrives, and a server that restarts carries on where it stopped instead of reading the document again. With that switched on, the import started minutes late.

We reproduced it on a laptop: 368 documents at once, a fake fleet answering each part in about a second, so a document should reach its embedding stage in about 4 seconds. Recording one step per part, as we did, means about 8,800 steps, and each step costs the workflow engine database round trips and Python of its own. A bigger connection pool did not help; at 64 connections it got worse. Fewer steps did:

368 documents at onceFirst document at embeddingWorst wait for any other work
One part a step, 8 connections (before)142 s43 s
One part a step, 32 connections116 s29 s
One part a step, 64 connections243 s90 s
16 parts a step, 16 connections (now)18 to 23 s3 to 4 s

Recording 16 parts at a time means a server that dies mid-step sends that group again, a few seconds of work. We killed a reading halfway on purpose: it resumed, sent only the steps that were not finished, and stored exactly what an uninterrupted reading stores.

One more thing surfaced while profiling the web server under that load: 31% of its CPU went into building a fresh storage client for every single call, 30 places in the code each making their own. One client kept per process removed it. With both fixes, the library is searchable in 9.6 minutes with checkpoints on.

The whole FinanceBench library, 54,120 pages: searchable in 9.6 minutes, and a server can crash at any point without losing a document.
Fair to ourselves

What this says, and what it does not.

  • One library. All runs used the same 368 filings, mostly text PDFs. Libraries full of scans or spreadsheets read differently; the reading steps are described in How we ingest thousands of documents in minutes.
  • Ten rented servers. The burst used 10 servers of 16 cores, rented by the hour for the import and then removed. An idle server is now kept until the hour already paid for it ends, so a second import within that hour costs nothing more.
  • Hosted embedding. The peak of 1,900 passages a second is shared across three providers serving the same open model; their limits are now the next ceiling.
  • Laptop benchmarks are laptop benchmarks. The CPU and checkpoint figures were measured on a laptop with a local database; the full runs on our servers are what count, and they are the 8.9 and 9.6 minutes above.

How it was run

  • FinanceBench's 368 public filings uploaded in one batch, each read, cut into passages and embedded with bge-m3 (Cloudflare Workers AI, OpenRouter and DeepInfra), into one Qdrant collection of 4 shards.
  • Jobs on a RabbitMQ queue; reading jobs placed by Ray across the burst servers; one web process coordinating every document. Run on 28 November 2026.

For how the reading itself is split into jobs, see How we ingest thousands of documents in minutes; for what the library is used for once it is in, VectoGrid scores 90% on FinanceBench.

Need a large library searchable today, not next week?

Talk to us

Published 28 November 2026 · Philippe Vergnet, VectoGrid