[Haskell-cafe] Fast JSON validation - reducing allocations
ben at smart-cactus.org
Thu May 11 18:40:14 UTC 2017
Ccing Luke Maurer under the assumption that he will appreciate seeing
the fruits of his labor.
David Turner <dct25-561bs at mythic-beasts.com> writes:
> Dear Café,
> There's a copy of the relevant code for option 4 at
> https://github.com/DaveCTurner/json-validator. I've hacked around with it a
> bit since producing the numbers above, so it's now apparently a bit slower
> than Aeson but allocates less too (~65kB).
> Could anyone help, e.g. by pointing me at the bit in the Core that is
> allocating within the main loop?
While turning this over in my head I realized that this is the sort of
program which may be helped significantly by GHC 8.2's improved join
point handling. Indeed the timings seem to support this hypothesis:
time 22.84 μs (22.76 μs .. 22.94 μs)
1.000 R² (1.000 R² .. 1.000 R²)
mean 22.84 μs (22.76 μs .. 22.94 μs)
std dev 297.4 ns (221.8 ns .. 378.8 ns)
Alloc rate 4,015,256,078,038 bytes per MUT second
time 9.221 μs (9.141 μs .. 9.318 μs)
0.998 R² (0.996 R² .. 1.000 R²)
mean 9.163 μs (9.084 μs .. 9.356 μs)
std dev 399.8 ns (193.0 ns .. 745.4 ns)
variance introduced by outliers: 54% (severely inflated)
Alloc rate 123,141,635 bytes per MUT second
Wow! I suspect your allocations have now vanished.
I didn't verify that the improvement really was due to more join points,
but it seems quite likely. Well done Luke!
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 487 bytes
Desc: not available
More information about the Haskell-Cafe