YuktaiDocs v5.3.12

Rust engines

Rust engines

YuktAI has two engines written in Rust and compiled to WebAssembly: grid search and number/date sorting, and the page RAG search. Since 5.3.11 they are the default. They return exactly the same results as TypeScript, only faster on big data. Time them here on your own sizes.

1. Grid: TypeScript vs Rust

Benchmark

1,000 to 300,000

Runs each engine 5 times and shows the middle time.

TypeScript

Rust

app/staff/page.tsx
"use client"
import { YuktaiGrid } from "@yuktishaalaa/yuktai"

<YuktaiGrid
  data={rows}
  columns={columns}
  rowKey="id"
  engine="auto"          // "ts" | "rust" | "auto" (Rust from 10,000 rows)
  showSearchTime         // "· 0.9 ms · Rust" next to the row count
  onSearchTime={(t) => console.log(t.ms, t.engine)}
/>

2. Page RAG: TypeScript vs Rust

Benchmark

100 to 100,000 (one per staff row)

Each engine searches 20 times; the top 5 passages are compared.

lib/search.ts
import { createContextIndex } from "@yuktishaalaa/yuktai"

const index = createContextIndex({ rows, columns, rowKey: "id", includePage: false, engine: "rust" })
const hits = index.search("security engineer in chennai", 5)

How the engines work

Small and self-contained

The Rust code is no_std, compiled to WebAssembly and embedded in the YuktAI script as base64. There is no extra file to host, no bundler setting, and it works offline.

Same results, proved

Rust runs the same rules as TypeScript (Unicode-aware tokens, prefix matching, BM25 with the same idf), and parity tests check that every query returns the same rows and passages in the same order.

Safe fallback

Rust is the default since 5.3.11 (engine: "ts" keeps TypeScript only). If WebAssembly is missing or blocked, TypeScript runs instead with the same results, and grid.engine says "ts".

Content Security Policy

Sites with a CSP need 'wasm-unsafe-eval' in script-src for the Rust engines. This site's netlify.toml shows a working policy.