[Haskell-cafe] Fast JSON validation - reducing allocations

Mikolaj Konarski mikolaj at well-typed.com
Fri May 12 13:26:52 UTC 2017


Truly impressive. Amazing.

I wonder what style of coding of inner loops
leads to such good results in 8.2. Is it easy to describe?
Or is the answer "any" or "simplest" or "natural"? If not,
can it be captured as some recursion combinators perhaps?

>> json-validator-exe --regress allocated:iters +RTS -T
>
> Here it is,
>
> GHC 8.0.2
>
>     benchmarking json-validator/Automaton/testEvent
>     time                 34.81 μs   (33.48 μs .. 36.10 μs)
>                          0.991 R²   (0.988 R² .. 0.994 R²)
>     mean                 34.04 μs   (33.28 μs .. 34.99 μs)
>     std dev              2.828 μs   (2.423 μs .. 3.247 μs)
>     allocated:           1.000 R²   (1.000 R² .. 1.000 R²)
>       iters              65924.651  (65895.364 .. 65951.510)
>       y                  -4175.284  (-46736.295 .. 39814.235)
>     variance introduced by outliers: 78% (severely inflated)
>
>
> GHC 8.2
>
>     benchmarking json-validator/Automaton/testEvent
>     time                 9.021 μs   (8.923 μs .. 9.162 μs)
>                          0.998 R²   (0.994 R² .. 1.000 R²)
>     mean                 8.970 μs   (8.905 μs .. 9.232 μs)
>     std dev              341.4 ns   (94.90 ns .. 711.7 ns)
>     allocated:           0.973 R²   (0.956 R² .. 0.984 R²)
>       iters              343.033    (332.692 .. 354.606)
>       y                  -7326.339  (-57269.638 .. 47222.231)
>     variance introduced by outliers: 47% (moderately inflated)


More information about the Haskell-Cafe mailing list