---
title: "Decision: Keep the Markdown engine in Rust + WASM"
url: https://memory.wiki/5DWOm2ya
updated: 2026-05-14T18:15:49.480Z
hub: https://memory.wiki/hub/demo
concept_count: 12
source: "memory.wiki"
---
# Decision: Keep the Markdown engine in Rust + WASM

> Recurring conversation that I'm now closing.

## The question that keeps coming up

"Why not just use `remark` / `markdown-it` / `marked`? They run in JS, no WASM boundary, no Rust build step."

## The answer

We've measured this three times across the last six months. The Rust + WASM build via `comrak` is:

- **2.3x faster on cold render** (a 200KB doc renders in 4.1ms vs ~9.5ms for `remark`)
- **Reference-correct** on GFM. `remark`'s plugin stack drifts on tables, task lists, and footnotes in ways we hit in user reports.
- **Stable**. The build is `cargo build --target wasm32-unknown-unknown` + `wasm-bindgen`. Three commands. The CI pipeline is 38 seconds end to end.

The friction:
- We can't use `syntect` (the C bindings don't compile to WASM cleanly). Highlighting moved client-side to highlight.js. That's a Phase 1 paper cut that became permanent. Fine.
- `wasm-opt` is disabled in our release profile because the current upstream rejects bulk-memory operations that LLVM emits. We accept the ~8% size hit until the toolchain catches up.

## The case I'd entertain re-litigating

If `markdown-rs` (also Rust → WASM) caught up to `comrak` on GFM fidelity AND shipped TypeScript types, we'd evaluate. As of 2026-Q2 it's not there. Saved as a watch item.

## Receipts

- Bench harness: `packages/engine/benches/render.rs` (16 test docs, p95 across 1000 runs)
- The last argument I had with myself about this: 2026-02-14, when I was tired and considered punting WASM. The 30-min experiment that morning settled it: `marked.parse(largeDoc)` blocked the main thread for 80ms+. The WASM call doesn't.


---

## Concepts in this document
- **Supabase** _(entity)_
  Backend-as-a-service providing authentication, database, and row-level security without separate auth overhead.
- **Vendor consolidation** _(concept)_
  The operational principle of reducing authentication surfaces, SDKs, and control planes by keeping vector search within the existing Postgres infrastructure.
- **pgvector** _(entity)_
  PostgreSQL extension providing vector data type and HNSW indexing for efficient similarity search.
- **Anthropic** _(entity)_
  Incumbent AI vendor mentioned as competitive threat with integrated memory and user lock-in.
- **Performance Optimization** _(concept)_
  Critical performance considerations driving technical architecture decisions.
- **AI-First Architecture** _(concept)_
  Design philosophy that assumes AI capabilities replace traditional manual processes.
- **Supabase Postgres** _(entity)_
  The existing database infrastructure that pgvector extends, serving as the single unified platform for relational and vector queries.
- **comrak** _(entity)_
  The Rust markdown parser selected for production use due to GFM compliance and performance.
- **Cost Optimization** _(tag)_
  Financial considerations in technology and vendor selection decisions.
- **Rust + WASM** _(entity)_
  Core technology stack providing performance advantages for markdown rendering.
- **Anthropic Haiku 4.5** _(entity)_
  The selected reranker model chosen to rerank hybrid retrieval results in the hub-recall pipeline.
- **AI-First Design** _(concept)_
  Product philosophy prioritizing AI agent compatibility over traditional user patterns.

## Concept relations (within this doc's concepts)
- **AI-First Architecture** synergizes with **Vendor consolidation**
- **Performance Optimization** balanced priorities **Cost Optimization**
- **Vendor consolidation** reduces complexity costs **Cost Optimization**
- **Anthropic** supports strategy **Vendor consolidation**
- **Supabase** enables approach **Vendor consolidation**
- **Supabase** hosts **pgvector**
- **Supabase** exemplifies approach **Vendor consolidation**
- **Supabase** reduces complexity **Vendor consolidation**
- **Supabase** integrates **pgvector**
- **Supabase** exemplifies strategy **Vendor consolidation**
- **Vendor consolidation** guides **Supabase**

_Hub canonical:_ https://memory.wiki/hub/demo
_Concept digest:_ https://memory.wiki/raw/hub/demo?digest=1&compact=1
