| Implementation | Time | vs TS | Status |
|---|---|---|---|
| native-optimized | 17.14 ms | 1.03x faster ✅ | WINNER |
| ts | 17.70 ms | 1.00x (baseline) | - |
| worker | 32.05 ms | 0.55x | Structured cloning overhead |
| native | 30.44 ms | 0.58x | C++ parsing overhead |
- ✅ External buffers (zero-copy transfer)
- ✅ V8's optimized JSON.parse() on main thread
- ✅ Large batch sizes (1024)
- ✅ Optimized parsing loop
- Result: 3% faster than TS!
- ✅
napi_define_propertiesfor bulk property setting - ✅ Optimized array creation
- ✅ Larger I/O buffers (128KB)
- Still slower due to C++ parsing overhead
- ✅ Larger batch sizes (512)
- ✅ Optimized array operations
- Still slower due to structured cloning overhead
- Zero-copy buffer transfer - No string copying
- V8's JIT-optimized JSON.parse() - Faster than C++ parser
- Background I/O - File reading in C++ thread
- Efficient batching - Fewer callbacks
Native-optimized implementation is now faster than the TS parser! 🎉
The key insight: Use V8's optimized JSON.parse() instead of C++ parsing + object construction.