Memory & RAG
~8 min readUpdated: December 2026

Orion Rust Vector Search: Moving 1.7 TB Off Postgres and pgvector

Orion Rust vector search engine replacing 1.7 TB pgvector with blob-backed sharding in Smoke Monkey

Circleback migrated 1.7 TB of unindexed meeting embeddings off PostgreSQL and pgvector into Orion, a custom Rust search engine backed by S3/GCS blob storage. Serving 3.5 million monthly searches (nearly 90% from AI agents via MCP, API, and CLI), Orion cuts tail latency from 20-40 seconds to tens of milliseconds and reduces search infrastructure costs by 90%.

Technical Review: Smoke Monkey Core Architecture Team
Tested on Node.js 18+ & BunTypeScript 5.x
Quick Answer & Executive Definition

Orion Rust Vector Search: Moving 1.7 TB Off Postgres and pgvector: Circleback migrated 1.7 TB of unindexed meeting embeddings off PostgreSQL and pgvector into Orion, a custom Rust search engine backed by S3/GCS blob storage. Serving 3.5 million monthly searches (nearly 90% from AI agents via MCP, API, and CLI), Orion cuts tail latency from 20-40 seconds to tens of milliseconds and reduces search infrastructure costs by 90%. Designed as a zero-dependency, open-source TypeScript architecture under the MIT License with native Model Context Protocol (MCP) support and deterministic phase state machines.

Key Architectural Takeaways
Quick Implementation Exampleorion-rust-rag-agent.ts
orion-rust-rag-agent.tstypescript
import { createAgent } from '@smoke-monkey/harness';
// Connect Smoke Monkey Harness to a sharded Rust/blob vector MCP server
const agent = createAgent({
agentId: 'orion-meeting-rag-agent',
provider: 'openai-compatible',
baseUrl: 'http://127.0.0.1:8080/v1',
model: 'Qwen/Qwen3.8-27B',
workspacePath: process.cwd(),
mcpServers: {
orionSearch: {
command: 'npx',
args: ['-y', '@smoke-monkey/mcp-orion-search', '--bucket', 's3://meeting-index-prod'],
env: {
ORION_ALLOCATOR: 'jemalloc',
ORION_SHARD_CACHE_DIR: '/var/cache/orion/shards',
},
},
},
permissions: {
read_file: 'allow',
write_file: 'ask',
run_command: 'ask',
},
});
async function main() {
const result = await agent.run(
'Query meeting shards for Q4 pricing decisions across authorized tenant IDs and summarize action items.'
);
console.log('RAG Summary:', result.summary);
}
main().catch(console.error);
Video Guides

Watch: Related Video Guides

How I Added Vector Search to my Course (Postgres + PGVector )

Do You Really Need a Vector Database? pgvector vs Dedicated

How Blob-Backed Sharding, CAS Writes, and jemalloc Work

Orion adopts a Turbopuffer-inspired object-storage model while eliminating external embedding pipelines and keeping all customer data inside a single VPC. Because S3 and GCS objects are immutable once written, Orion separates write durability from background compaction:

  1. Compare-And-Swap (CAS) Manifest Commits: When ingesting a transcript, Orion writes an immutable segment object and performs a conditional CAS update on a lightweight manifest file listing active segments. Concurrent writers cannot clobber each other, and a background compactor merges small files into larger search-optimized segments.
  2. Application-Computed Shard Filtering: Orion itself stores zero ACL tables. Every MCP or API query supplies the caller's authorized meeting IDs, and Orion hashes those IDs directly to the subset of shards containing them, skipping cold meeting history completely.
  3. Fixing Allocator & Serialization Bottlenecks: Profiling preview traffic against production uncovered two non-obvious traps: the default Linux system allocator retained freed heap pages after bursty indexing (resolved by switching to jemalloc), and Node/Prisma ORM layers repeatedly copied large binary transcript buffers before reaching Rust, triggering multi-hundred-millisecond GC pauses.

Do Not Quantize Embeddings Blindly in Production

In Circleback A/B testing across 30+ tuning experiments, quantized embedding models improved raw vector throughput but degraded retrieval recall on edge queries, so production Orion retains full-precision embeddings paired with fast shard pruning.

Reproducible Rust + jemalloc Vector Service Configuration

To replicate Orion's allocator tuning and object-store sharded layout in a self-hosted Rust RAG service for Smoke Monkey MCP agents, enable tikv-jemallocator and shadow-test against production queries before dropping your pgvector table:

bash
# 1. Initialize a Rust search worker with jemalloc and object_store crates
cargo new orion-worker && cd orion-worker
cargo add tikv-jemallocator object_store tokio serde_json

# 2. Configure jemalloc decay timers to aggressively return freed pages to the OS
export MALLOC_CONF="dirty_decay_ms:1000,muzzy_decay_ms:1000,narenas:4"

# 3. Run shadow traffic parity checks comparing pgvector recall vs sharded blob index
cargo run --release -- \
  --manifest-uri s3://prod-rag-index/manifest.json \
  --cache-dir /mnt/nvme/orion-cache \
  --shadow-compare-pg "$DATABASE_URL"
Google Search Questions & Answers

Frequently Asked Questions

Q:Why did Circleback build Orion instead of using Turbopuffer or Elasticsearch?

Turbopuffer stores vectors but requires an external embedding pipeline, which was Circleback’s single highest search expense, whereas Elasticsearch requires keeping cold meeting indices warm on continuously running SSD nodes. Orion generates embeddings in-process and stores cold segments in cheap S3/GCS blob storage.

Q:Why did switching to jemalloc fix Orion’s memory retention in Rust?

Under spiky transcript ingestion and compaction workloads, the default glibc/system allocator held onto freed heap arenas instead of returning pages to the kernel. Switching to jemalloc stabilized resident set size (RSS) on multi-tenant machines shared with other microservices.

Q:How does Orion enforce multi-tenant permissions without an auth database?

The application tier resolves which meeting IDs a user or MCP agent is authorized to access and passes that ID list with each query. Orion hashes those IDs to open only the matching shards, guaranteeing zero cross-tenant scans.

Q:How much faster and cheaper is Orion compared to pgvector?

Worst-case large-account searches dropped from 20-40 seconds (with 700 ms unindexed chunk scans) to under 100 ms chunk lookups and tens of milliseconds in Orion core, while total search infrastructure cost dropped by roughly 90% (one-tenth of prior spend).

Related Alternatives & Comparisons

Related Architecture Guides

View all guides

Build with Smoke Monkey Harness

Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.

npm install smoke-monkey-harness