4 ms·
anyone know what the V8 engine uses?
by tmikaeld 7y ago
anyone know what the V8 engine uses?
- fulafel 7y agoMost JSON parses are small. Does this have bigger spin-up overhead? Also the memory handling requirements of working with GC'd JS data are very particular, this sounds like it has its own way with memory.
- jkeiser 7y agosimdjson's spinup overhead is minimal, it runs at a pretty steady rate no matter the size of document: https://github.com/simdjson/simdjson/blob/master/doc/growing.png https://github.com/simdjson/simdjson/blob/master/doc/growing... It's also still faster than other parsers in our tests, even on the smallest documents (https://github.com/simdjson/simdjson/issues/312#issuecomment-597223884)--its https://github.com/simdjson/simdjson/issues/312#issuecomment... advantage is just smaller, like 1.1x and 1.2x instead of 2.5x :) It really starts to pull ahead somewhere between 512 bytes and 1K.
- saagarjha 7y agoThis, perhaps: https://chromium.googlesource.com/chromium/src/+/refs/heads/master/base/json/json_parser.cc https://chromium.googlesource.com/chromium/src/+/refs/heads/...?
- Leszek 7y agoV8 has a hand rolled JSON parser which feeds directly into our object model without any intermediate data structures. This allows us to take advantage of structural knowledge, e.g. we assume that objects in an array have the same shape (and just verify this before falling back to pointer chasing through transition trees). I keep meaning to look into SIMD for both this and ordinary tokenisation, last time I tried it the bookkeeping overheads and alignment requirements weren't worth the speedup but it's always worth re-evaluating.
- deleted 7y ago[deleted]
- lioeters 7y agoHere's the JSON parser for V8. I'd never looked at it before, but it's surprisingly straight-forward and readable. https://github.com/v8/v8/blob/master/src/json/json-parser.cc https://github.com/v8/v8/blob/master/src/json/json-parser.cc