Jiffy 2.0.2

Changes

  • Reduce encoder memory allocations #301

    Flush the buffer into iolist segments with a chunk size that doubles (up to 64KB). Large documents should now have O(log n) allocations.

  • Encode maps directly without an intermediate ejson proplist #302

    Encode a map from a flat [k1, v1, ...] list built from a map iterator instead {k,v} tuples. To drive yielding properly a new $map_ref$ stack marker but otherwise it’s a regular old list. Saw a 5% median speedup on tests with lots of json objects like gsoc and neutral on others.

  • Fix out-of-bounds heap write in string encoder #304

    This fixes a segfault when a corner case of long strings starting with lots escapes (to push e->i high enough) then also followed by long runs of non-escapes. That explains why property tests never caught this. The fix is to check the buffer size if he have a buffer already before returning. If it’s too small, return otherwise release and allocate one of the right size. To ensure we catch these kind of errors in the future, enhance property tests by switching to PropEr (code borrowed from Apache CouchDB). For belt-and-suspenders and also added some deterministic tests as well for the issue.

Scheduling Benchmark Update

Updated bench with jiffy 2.0.2 and replacing simdjsone with glazer, a neat and fast replacement for simdjsone. As concurrency increases there is more pressure on GC and contention on dirty CPU scheduler. Jiffy’s yielding architecture proves its worth. The built-in json module does fairly well and degrades predictably, too:

./bench_scheduling.sh
...
scheduler responsiveness check
  input:       citm-catalog.json duration: 2000
  schedulers:  12 online
  impls:       json, jiffy, glazer, jsone, jsx

[json]
  1x encdec                    n=108 p50=109.5ms p95=166.3ms p99=170.2ms max=172.2ms
  12x encdec                   n=108 p50=110.2ms p95=162.2ms p99=169.1ms max=170.7ms
  24x encdec                   n=97 p50=221.7ms p95=366.6ms p99=404.3ms max=425.7ms

[jiffy]
  1x encdec                    n=364 p50=32.4ms p95=41.3ms p99=46.3ms max=49.8ms
  12x encdec                   n=382 p50=31.2ms p95=38.5ms p99=43.6ms max=48.1ms
  24x encdec                   n=373 p50=65.4ms p95=97.7ms p99=118.8ms max=146.6ms

[glazer]
  1x encdec                    n=24 p50=242.6ms p95=712.4ms p99=712.4ms max=713.2ms
  12x encdec                   n=24 p50=245.7ms p95=844.2ms p99=849.1ms max=855.6ms
  24x encdec                   n=24 p50=1398.2ms p95=1628.4ms p99=1632.5ms max=1639.5ms

[jsone]
  1x encdec                    n=60 p50=188.6ms p95=234.8ms p99=237.0ms max=237.2ms
  12x encdec                   n=60 p50=187.4ms p95=331.4ms p99=338.5ms max=351.5ms
  24x encdec                   n=62 p50=359.2ms p95=570.7ms p99=601.3ms max=687.6ms

[jsx]
  1x encdec                    n=36 p50=305.1ms p95=449.3ms p99=455.5ms max=458.5ms
  12x encdec                   n=36 p50=310.3ms p95=657.2ms p99=666.8ms max=674.6ms
  24x encdec                   n=24 p50=1068.3ms p95=1203.0ms p99=1368.8ms max=1387.9ms
1 Like