Skip to content

Commit 0897ab2

Browse files
committed
Bump to 0.4.7
1 parent e279cf2 commit 0897ab2

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,25 @@ Apple-to-apple: both sides produce a materialized partial object on every chunk.
169169

170170
Stock parsers re-parse the full buffer on every chunk — O(n²). VectorJSON maintains a **live JS object** that grows incrementally on each `feed()`, so `getValue()` is O(1). Total work: O(n).
171171

172+
### What about single-shot JSON.parse?
173+
174+
For one-shot full materialization, `JSON.parse` is faster — it's highly optimized C++ running inside V8. On small payloads it's orders of magnitude faster. On large payloads (500KB+) VectorJSON approaches parity but never beats it for full access:
175+
176+
```
177+
bun --expose-gc bench/parse-stream.mjs (one-shot section, CI results)
178+
179+
1 KB JSON.parse 2.16M ops/s VectorJSON 1.37K ops/s JSON.parse wins
180+
10 KB JSON.parse 9.64K ops/s VectorJSON 1.37K ops/s JSON.parse wins
181+
500 KB JSON.parse 490 ops/s VectorJSON 466 ops/s ~equal (0.95×)
182+
2 MB JSON.parse 183 ops/s VectorJSON 172 ops/s ~equal (0.94×)
183+
```
184+
185+
VectorJSON is not a replacement for `JSON.parse`. It wins in different scenarios:
186+
- **Streaming**: O(n) incremental vs O(n²) re-parse on every chunk
187+
- **Partial access**: read 3 fields from a 100KB payload without materializing the other 97%
188+
- **Worker transfer**: tape transfer skips re-parsing on the main thread
189+
- **Deep compare**: WASM tape-level comparison with zero JS allocations
190+
172191
### Why this matters: main thread availability
173192

174193
The real cost isn't just CPU time — it's blocking the agent's main thread. Simulating an Anthropic `tool_use` content block (`str_replace_editor`) streamed in ~12-char chunks:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vectorjson",
3-
"version": "0.4.6",
3+
"version": "0.4.7",
44
"description": "O(n) WASM SIMD JSON parser for AI agents — stream fields instantly, abort errors early, offload parsing to Workers",
55
"type": "module",
66
"main": "dist/index.js",

0 commit comments

Comments
 (0)