Closed parsonsmatt closed 2 months ago
Thanks for taking the time @parsonsmatt, this is really appreciated. :)
RE aeson dependency footprint : to fight that, there once was https://github.com/haskell-hvr/microaeson I wonder how it compares performance-wise...
I'm not sure - #1559 uses Text
and Map
and doesn't get close. I suspect the machinery in toEncoding
and the other Value -> Builder
is the secret sauce.
I did actually try the toEncoding . toJSON
, and it was slightly slower, but only ~10% worse than the toEncoding
variant.
The implementation of toEncoding
on a [a]
to pretty simple -
list :: (a -> Encoding) -> [a] -> Encoding
list _ [] = emptyArray_
list to' (x:xs) = openBracket >< to' x >< commas xs >< closeBracket
where
commas = foldr (\v vs -> comma >< to' v >< vs) empty
{-# INLINE list #-}
><
is <>
but pushed into Encoding
.
Hi, thank you for this PR, but Haddock now lives full-time in the GHC repository! Read more at https://discourse.haskell.org/t/haddock-now-lives-in-the-ghc-repository/9576.
Let me know if you feel it is still needed, and I'll migrate it. :)
Fast JSON
As usual, testing on
persistent
.With
--quickjump
:--quickjump
is what actually uses the JSON stuff, so let's try running with that.Baseline
We generate the JSON index twice - which seems weird? The two calls are very different. Feels like it should be folded in to a single thing.
With
aeson
andtoEncoding
Comparison
Overall a pretty large improvement.
Unfortunately, using
aeson
directly is likely out of the question - there are far too many dependencies. Even if we were to core out the important bits, that would requireunordered-containers
,vector
, andattoparsec
, none of which are boot packages.Still, I think this PR demonstrates that a faster JSON representation is worth pursuing.