New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize TH toEncoding #596

Merged
merged 2 commits into from Oct 18, 2017

Conversation

Projects
None yet
2 participants
@Lysxia
Contributor

Lysxia commented Oct 8, 2017

Benchmarks

AesonCompareAutoInstances is the one that is in benchmarks/, just to check that I didn't introduce any performance regression. The SmallRecord file compares results with a record having 5 fields.

The speedup is in the BigRecord/encode/th case.

The reason for the slowdown was that we were using a recursive function to convert lists of pairs (whose size is known statically) to a comma-separated encoding.

@bergmark

Cool, thanks!

instance ToJSON v => GKeyValue v (DList Pair) where
gPair k v = DList.singleton (pack k .= v)
instance (v ~ Value) => KeyValuePair v (DList Pair) where

This comment has been minimized.

@bergmark

bergmark Oct 8, 2017

Collaborator

Is there a reason this isn't KeyValuePair Value (DList Pair) ?

This comment has been minimized.

@Lysxia

Lysxia Oct 8, 2017

Contributor

It improves type inference. Otherwise the TH deriving results in ambiguous type variables and we would need more type annotations.

@bergmark bergmark added this to the 1.3.0.0 milestone Oct 8, 2017

@bergmark bergmark merged commit 07564d8 into bos:master Oct 18, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@Lysxia Lysxia deleted the Lysxia:opti-th-encode branch Nov 13, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment