Skip to content

feat: add pure TypeScript Loro runtime#1045

Merged
zxch3n merged 2 commits into
mainfrom
docs/current-encoding-format
Jul 18, 2026
Merged

feat: add pure TypeScript Loro runtime#1045
zxch3n merged 2 commits into
mainfrom
docs/current-encoding-format

Conversation

@zxch3n

@zxch3n zxch3n commented Jul 18, 2026

Copy link
Copy Markdown
Member

Summary

  • add loro-js, a pure TypeScript Loro runtime with Text, Map, List, MovableList, Tree, Counter, events, undo, ephemeral state, JSONPath, and version transitions
  • implement Rust-compatible update and snapshot codecs, generated interoperability fixtures, and Rust-to-TypeScript round-trip coverage
  • add indexed sequence, ordered-state, style, deletion, and history paths so public operations match the Rust runtime's asymptotic behavior
  • compress snapshot SSTables with interoperable LZ4, stream DeltaRLE decoding, and defer non-frontier history construction for initial snapshots
  • document the current encoding format, runtime performance architecture, benchmarks, and publishing changesets

Why

Loro currently requires the WASM package for JavaScript consumers. This adds a portable TypeScript implementation while preserving the existing binary format and public behavior.

The initial implementation also exposed high-priority scaling failures: merged commits repeatedly copied and reduced complete history, concurrent Fugue insertion scanned growing origin chains, bulk List inserts emitted one operation per item, and large snapshots retained uncompressed or allocation-heavy intermediate data. This branch removes those paths and adds focused regressions.

Performance

Using zxch3n/crdt-benchmarks with the local build:

  • B4: more than 180 seconds before the fixes, 2.846 seconds after them
  • B3.5: 288 ms, versus 303 ms for the published Loro WASM adapter
  • B3.3 snapshot: 240,032 bytes, down from about 7.95 MB and comparable to the WASM result
  • 60k List and 120k Text updates now match the WASM adapter's encoded sizes

C1.1 remains a documented JavaScript representation and constant-factor gap rather than a known asymptotic regression.

Validation

  • pnpm --dir loro-js check
  • cargo test -p loro --test loro_js_interop
  • pnpm --dir loro-js bench:complexity -- 1000,2000,4000,8000
  • pnpm --dir loro-js bench:b4 -- 259778 3
  • zxch3n/crdt-benchmarks B3.3, B3.5, B4, and C1.1 traces

@zxch3n
zxch3n marked this pull request as ready for review July 18, 2026 07:35
@github-actions

Copy link
Copy Markdown
Contributor

WASM Size Report

  • Original size: 3053.22 KB
  • Gzipped size: 1009.02 KB
  • Brotli size: 707.57 KB

@zxch3n
zxch3n merged commit 68587bc into main Jul 18, 2026
2 checks passed
@lodystage
lodystage Bot deleted the docs/current-encoding-format branch July 18, 2026 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant