Commit Graph

148 Commits

Author SHA1 Message Date
Jonathan Coens
f890195300 Bump stackage-lts version in stack.yaml
Summary: Bump to a more recent stackage-lts

Reviewed By: niteria

Differential Revision: D5257292

fbshipit-source-id: 8f3aa86c699e6b91d55998d03dab0d0440993317
2017-06-15 11:33:47 -07:00
Jonathan Coens
e97eb57514 Update TestExampleDataSource to find location of LoadCache.txt via envvar if it exists
Summary: This provides a way to override test file locations for other build systems.

Reviewed By: yfeldblum

Differential Revision: D5218507

fbshipit-source-id: 7087ca13afb105b727ecf3f7dfdaecd26d27ea81
2017-06-12 10:40:29 -07:00
Jonathan Coens
2fa7cc30f5 Change HAVE_APPLICATIVEDO check to GHC version check
Reviewed By: simonmar

Differential Revision: D5201670

fbshipit-source-id: 113ef66073e1836fa572ef3fceeb82adc87f253b
2017-06-07 13:27:41 -07:00
Bartosz Nitka
549dcaa30a Don't import Data.Typeable.Internal
Summary:
It doesn't exist in GHC 8.2 and it appears that
Data.Typeable just works.
This should fix https://github.com/facebook/Haxl/issues/70.

Differential Revision: D5086644

fbshipit-source-id: e3e48ea7d603bbdf4fd78b4acd5125761ce799b2
2017-05-18 07:35:31 -07:00
Simon Marlow
7506526500 Haxl.Core should export cachedResultWithShow
Reviewed By: codemiller

Differential Revision: D5060572

fbshipit-source-id: 9e46fc324796c97e02575d3bfb1e4a45f04cb28d
2017-05-15 05:18:37 -07:00
Simon Marlow
1e0d31e278 Fix text dependency
Summary: text prior to 1.2.1.0 doesn't work because we need the Binary instance

Reviewed By: niteria

Differential Revision: D5027630

fbshipit-source-id: d6eeefb40a19ae2c0aaccaad868dc42ed4976ea5
2017-05-09 04:18:48 -07:00
Simon Marlow
1030e210b9 Fix build with GHC 7.8.x
Reviewed By: niteria

Differential Revision: D5027635

fbshipit-source-id: 3be0347e5e79c11dcd8d2333ba155f0e429ca015
2017-05-09 04:03:37 -07:00
Simon Marlow
a9dd8ee43e Fix license spec in the .cabal file (#67)
Reviewed By: codemiller

Differential Revision: D4938031

fbshipit-source-id: 1ac10bec8a6d53ab3863a9045c0d3a9ee696369a
2017-04-24 05:38:39 -07:00
Simon Marlow
493c42fa0f Handle exceptions correctly in async datasources
Reviewed By: zilberstein, niteria

Differential Revision: D4868473

fbshipit-source-id: 0daf35e23f7ca4e87c3316786f3ac7a8ee7148cf
2017-04-19 12:27:42 -07:00
Oleg Grenrus
6a218f9110 Allow aeson-1.2
Summary: Closes https://github.com/facebook/Haxl/pull/69

Differential Revision: D4897787

Pulled By: watashi

fbshipit-source-id: aa8cbcb52822b0a1a3d31112313f495fc11efe1c
2017-04-16 18:53:48 -07:00
Jonathan Coens
2bc00c77b1 Add vanilla stack.yaml file
Summary: Adds a simple `stack` file using the latest version of stackage.

Reviewed By: watashi

Differential Revision: D4843970

fbshipit-source-id: 938a16de769210661064157084f5eac42c7c0494
2017-04-07 14:04:02 -07:00
Oleg Grenrus
f3d340924c Bump more bounds
Summary:
- `binary-0.9` is accidental major jump and is now deprecated, I'm not sure what's best to do, cabal solver should pick `-0.8.x.y.` version
- `HUnit` and `time` changes do not affect use in haxl.
Closes https://github.com/facebook/Haxl/pull/68

Differential Revision: D4843906

Pulled By: JonCoens

fbshipit-source-id: b97c78e644a170745d7a29aab5c137e86f7018be
2017-04-06 10:18:42 -07:00
Simon Marlow
60f1c6b872 Add pOr and pAnd
Summary:
These two operators are subtly non-deterministic, but can potentially
improve performance significantly in cases where

* We don't want to use .|| because it's too sequential
* We don't want to use || because it forces us to do wasted work

(and equivalently for &&).

The implementation is a bit subtle, see Note [tricky pOr/pAnd]

Reviewed By: xich

Differential Revision: D4611809

fbshipit-source-id: 832ace29dfc44e48c14cc5d4f52a0114ee326c92
2017-02-27 09:19:51 -08:00
Simon Marlow
b5821182cf Fix the profile test in haxl-core-unit
Summary:
I didn't look into this too deeply but I'm guessing it was because the
constant expression had been lifted out, so I made it not a constant
expression.

Reviewed By: JonCoens

Differential Revision: D4521430

fbshipit-source-id: 687075d8486b38743b3bd8b9a9f26aa198b2d258
2017-02-08 01:32:25 -08:00
Oleg Grenrus
990b80cbc6 Test with GHC 8.0.2
Summary:
If this goes ok, can we have a release?
Closes https://github.com/facebook/Haxl/pull/66

Reviewed By: simonmar

Differential Revision: D4409114

Pulled By: niteria

fbshipit-source-id: 6d6e88f1cf7b9ae2d851eaa86966f2eb417b4d7e
2017-01-12 10:01:33 -08:00
Oleg Grenrus
d8f2eeed13 Allow vector-0.12, time-1.7; Drop unused directory
Summary: Closes https://github.com/facebook/Haxl/pull/65

Reviewed By: xich

Differential Revision: D4391469

Pulled By: niteria

fbshipit-source-id: d9a54fe6c4a255c0e82b26aca2849265fd7e8b53
2017-01-08 12:31:32 -08:00
Oleg Grenrus
d77b818a82 Allow aeson-1.1
Summary:
Alternatively we could change dependency to `aeson-compat`, which has less major version bumps (because it has smaller public API surface, yet one have to be careful .e.g. not to rely on instance implementations).
Closes https://github.com/facebook/Haxl/pull/64

Differential Revision: D4385525

Pulled By: xich

fbshipit-source-id: 72246e0f9144728e618de7bfcf983531bd3d281a
2017-01-05 17:01:26 -08:00
Zejun Wu
03d434fbd6 Include request in the uninitialized data source error
Summary:
Include request in the uninitialized data source error so we will
know which request is not in cache or triggering this problem.
This will increase the size of error message, but in production
this should not happen as we should sanitize data source is
initizlied correctly.

Reviewed By: codemiller

Differential Revision: D4342674

fbshipit-source-id: ec3506285806e749dccade5ba5eb8cfdb25a5671
2016-12-19 10:16:36 -08:00
Oleg Grenrus
b0a5f7b8a8 Rename Show1 to ShowP
Summary:
Resolve #62
Closes https://github.com/facebook/Haxl/pull/63

Reviewed By: JonCoens

Differential Revision: D4299180

Pulled By: niteria

fbshipit-source-id: 0bcbefd26184d1e7ad5de99a806ce0cf4b57d1a6
2016-12-09 14:31:39 -08:00
Bartosz Nitka
b8cb1d850f Bump version before release
Summary: Closes https://github.com/facebook/Haxl/pull/61

Reviewed By: darshankapashi

Differential Revision: D4222554

Pulled By: niteria

fbshipit-source-id: d634be076eef94c00277952e6c8bc1920b052f89
2016-11-22 14:16:26 -08:00
Bartosz Nitka
c3d650e173 Allow HUnit 1.5
Summary:
According to #1965:

> Stackage nightly builds will soon move to HUnit-1.5.
Closes https://github.com/facebook/Haxl/pull/60

Reviewed By: xich

Differential Revision: D4221036

Pulled By: niteria

fbshipit-source-id: d3b011c7510ab9eceed9a1afdce0e55ed0983cf0
2016-11-22 13:01:33 -08:00
Oleg Grenrus
bc791fd734 Allow HUnit-1.4
Summary: Closes https://github.com/facebook/Haxl/pull/59

Reviewed By: niteria

Differential Revision: D3987227

Pulled By: algoriddle

fbshipit-source-id: 3be85a3eef2f40fd0a0efe0aee09714646632b4f
2016-10-07 05:46:38 -07:00
Oleg Grenrus
f80fe801a2 Make haxl compile cleanly with stack build --pedantic
Summary: Closes https://github.com/facebook/Haxl/pull/56

Reviewed By: JonCoens

Differential Revision: D3973977

Pulled By: simonmar

fbshipit-source-id: 527e17407dbeb3376955733949b0edb8b581122a
2016-10-05 05:46:30 -07:00
Jonathan Coens
f5ecbea752 Drop NFData from Haxl Monad
Summary: `GenHaxl` having an `NFData` instance is apparently a lie. Remove this functionality

Reviewed By: simonmar

Differential Revision: D3967290

fbshipit-source-id: 1da91dcd6470de0f911e8a29b86c4aa5d6c7301f
2016-10-04 05:16:28 -07:00
Gergely Szilvasy
98b403f0a4 fix package
Summary: Some of the test files were not listed in haxl.cabal

Reviewed By: kuk0

Differential Revision: D3951346

fbshipit-source-id: 8e6677a728acde3713c618a6383b2de510b1ac86
2016-09-30 10:01:37 -07:00
Gergely Szilvasy
187bd49f54 increasing version in haxl.cabal
Summary: Increasing package version before uploading on hackage.

Reviewed By: JonCoens

Differential Revision: D3944387

fbshipit-source-id: 146ed68970b7d3d6486b0e10f7d183e60e37257b
2016-09-30 03:16:33 -07:00
Jonathan Coens
78052b9625 Derive NFData instance for GenHaxl
Summary: Having an NFData instance allows forcing calls that return a Haxl computation to run.

Reviewed By: xich

Differential Revision: D3906781

fbshipit-source-id: e49448152695383031af6d315a20dbcd1c10720c
2016-09-22 11:16:33 -07:00
Andrew Farmer
528bba5565 Add unit test to demonstrate withLabel with pure/haxl exceptions
Summary:
Labels which throw Haxl exceptions are recorded, but pure exceptions bubble up
and labels are lost. This test demonstrates this.

Reviewed By: simonmar

Differential Revision: D3672479

fbshipit-source-id: fab10878e7eb067e0c65bcf401d75604c333007f
2016-08-22 08:31:36 -07:00
Oleg Grenrus
bc4a25c61e Support aeson-1
Summary: Closes https://github.com/facebook/Haxl/pull/54

Reviewed By: kuk0

Differential Revision: D3696720

Pulled By: niteria

fbshipit-source-id: f04ba17a24a74dcc0de8b1c4336c59e28d5a427d
2016-08-10 08:16:40 -07:00
Andrew Farmer
8a69ddcc0d Import Control.Applicative in MemoizationTests for GHC < 7.10
Summary: GHC prior to 7.10 didn't export <$> in the prelude.

Reviewed By: watashi

Differential Revision: D3659220

fbshipit-source-id: af95574bc33f593fe0deb9217a963a7d9d9b0a16
2016-08-02 20:16:33 -07:00
Andrew Farmer
69ede7d79d Import Control.Applicative in Haxl.Core.Memo for GHC 7.8 support
Summary: Prior to GHC 7.10, <$> was not in the prelude, so requires an explicit import.

Reviewed By: watashi

Differential Revision: D3656379

fbshipit-source-id: 43925bc9c483ee712b04976d6fa6cb6b9d9b998e
2016-08-02 11:17:01 -07:00
Andrew Farmer
1ca0643c10 Add travis build status badge to readme
Summary:
The 7.8 build keeps breaking, but no one notices until someone opens an issue.
With the travis badge, breakage will at least be visible from the github
landing page for Haxl repo.

Reviewed By: zilberstein

Differential Revision: D3656468

fbshipit-source-id: 5537ab78b9dd44a5a3f07e7e3db7f73ec959f096
2016-08-02 10:46:36 -07:00
Andrew Farmer
c34ea3a3fd Expose MiddleException for access to eName function.
Summary: Expose MiddleException because the `eName` function is useful.

Reviewed By: watashi

Differential Revision: D3635507

fbshipit-source-id: bec3fac0b4f7c009c57d14857d46576ffc5ab826
2016-07-28 09:31:28 -07:00
Kubo Kovac
10623dc6ee add show instances for core types
Summary: add show instances for core types

Reviewed By: JonCoens

Differential Revision: D3613250

fbshipit-source-id: aa3bacdbb938666352859078ccf93fc24f3e8652
2016-07-25 15:46:29 -07:00
P. C. Shyamshankar
3cc0b3e054 Add 1-ary and 2-ary function memoization machinery
Summary:
This revision generalizes the existing memoization framework to 1-ary and 2-ary
functions (namely functions of type (a -> GenHaxl u b) and (a -> b _> GenHaxl u c)).

For every support arity (currently 0, 1, and 2), a family of functions {
newMemoWithX, prepareMemoX and runMemoX } are provided. newMemo itself is
generic across all arities.

Reviewed By: simonmar

Differential Revision: D3555791

fbshipit-source-id: 010a9889d42327607c8b03a5f7a609ee0c70de49
2016-07-25 06:16:28 -07:00
Kubo Kovac
d7483ccf6b fix haddock
Summary: fix code examples in haddock

Reviewed By: sykora

Differential Revision: D3605259

fbshipit-source-id: ff7bfa1cb6a1d592967c9b69ac5e37de95d1b502
2016-07-22 07:16:27 -07:00
P. C. Shyamshankar
bff7b643f5 Refactor cachedComputation to use newMemo/runMemo.
Summary:
This revision refactors cachedComputation to only contain logic relevant to
where the request-scope memo lives; memo creation and running logic is delegated
to newMemo(with) and runMemo.

Comments in cachedComputation have been moved over to newMemo/runMemo, and a
benchmark for cachedComputation has been added to monadbench. Surprisingly,
performance might have improved, albeit very slightly.

Reviewed By: simonmar

Differential Revision: D3514791

fbshipit-source-id: b2f0627824adc79b766e4f4e28c4af957ff00a00
2016-07-06 03:31:25 -07:00
Simon Marlow
549c14fb26 Track stack traces of dataFetch calls when profiling
Summary: This diff collects the stack traces of `dataFetch` calls, when `reportLevel` >= 5 and profiling is on.  Zero overhead for non-profiled code.

Reviewed By: niteria

Differential Revision: D2535947

fbshipit-source-id: fd43c20edd5455bd5e41113059fc69206b998e44
2016-07-05 02:31:24 -07:00
P. C. Shyamshankar
7cd98c4076 Add createMemo/updateMemo helpers, with monadbench test-case.
Summary:
This diff adds the createMemo and updateMemo helper functions, which abstract
the memoization reference management logic of cachedComputation. This separates
the work of *how* a memoized computation is created/updated, from *where* the
memo reference lives, allowing the same code to be used to manage request-scope
and feature-scope memos simultaneously.

A refactor of cachedComputation to use this abstraction is forthcoming.

Reviewed By: simonmar

Differential Revision: D3492803

fbshipit-source-id: 9dadd3860d5bec3bf776eef7c1bd610c25283729
2016-07-01 08:31:28 -07:00
Jonathan Coens
3d14694b22 Add allocation statistics per data source per round
Summary: Track and report allocation usage for data sources and rounds

Reviewed By: simonmar

Differential Revision: D3488169

fbshipit-source-id: 39c853ec89881e9f7d8d32b1a8d0a878c847a33e
2016-06-28 03:01:27 -07:00
Katie Ots
f1256b6ae7 Improve clarity in Haxl documentation
Summary: Improve clarity in Haxl documentation

Reviewed By: niteria

Differential Revision: D3462720

fbshipit-source-id: e73f149b05b87ea10ef43f051f88a269ca91ca66
2016-06-21 05:31:32 -07:00
Jon Coens
3a88f2a088 Merge pull request #50 from adarqui/typo
Just a typo fix
2016-06-21 09:13:19 +01:00
Andrew Darqui
a90363a03c typo fix 2016-06-21 02:48:30 -04:00
P. C. Shyamshankar
a7b3552d5c Add memoization benchmarks to monadbench
Summary:
Memoized operations were not represented in monadbench, this diff fixes that. Three tests are included:

1. Unmemoized computation, repeated N times.
2. Memoized computation, repeated N times.
3. Memoized computation, repeated N times **under different memo keys**

Reviewed By: simonmar

Differential Revision: D3444238

fbshipit-source-id: b2df534232acd5c02f9f6aea030c55d5cc846eb0
2016-06-20 02:46:24 -07:00
P. C. Shyamshankar
43f95ee605 Add memoHits to sigma profiling framework.
Summary: Integrate counts of memoized computation access into the profiling framework. Every call to `cachedComputation` logs one hit, including the first one.

Reviewed By: simonmar

Differential Revision: D3430491

fbshipit-source-id: a799c0e603c7bc94813da9801d7f4931a011131d
2016-06-15 03:31:34 -07:00
Andrew Farmer
922717e736 Add :profile command
Summary:
Add a :profile command to haxlsh to view lightweight profiling data.
Has optional flags to sort output on a given column, or filter rows by name
with a regex.

Useful for iterating while trying to squash allocation issues.

Differential Revision: D3429989

fbshipit-source-id: 3631afbac6f7a8580b1c46fae8039bacaa996ab3
2016-06-14 09:17:25 -07:00
Gergely Szilvasy
251ad5c3e5 Version bounds on binary package
Summary:
Putting version bounds on binary package in haxl.cabal
Closes https://github.com/facebook/Haxl/pull/48

Reviewed By: watashi

Differential Revision: D3371245

Pulled By: algoriddle

fbshipit-source-id: 574cbbe3ee081bd4e8af7c91fa89cf6ab6a03029
2016-06-07 15:16:29 -07:00
Gergely Szilvasy
4c5a07b98f Fix compilation error on 7.8.4 due to missing import
Summary: Adding missing import

Reviewed By: xich

Differential Revision: D3390552

fbshipit-source-id: 0a083bb9612f2923207880b813f10bf471af1497
2016-06-05 03:34:29 -07:00
Gergely Szilvasy
1893551564 Unbreak cabal test
Summary: Some tests were failing, but we ignored the test failures by not checking the return value from the test runner. This patch fixes both the test runner and the tests.

Reviewed By: watashi

Differential Revision: D3379609

fbshipit-source-id: 0a1278879faa5beb0f9779ddfaa622cdbf05a73f
2016-06-04 15:31:43 -07:00
Andrew Farmer
9d5db2ae63 Optimize Haxl Monad
Summary:
This diff does two things:

1. Claws back performance lost to lightweight profiling, and then some.
Haxl monad with lightweight profiling is now faster than it was before
lightweight profiling was added.

par1 and tree are ~20% faster.
seqr is ~10% faster.
par2 and seql are unchanged.

2. Eliminate redundant constraints on some exported functions.
Wherever types on exported functions changed, they became less
constrained with no loss of functionality. Notably, the *WithShow
functions no longer require pointless Show constraints.

Now the gory details:

Monadbench on master (before lightweight profiling):

  par1
  10000 reqs: 0.01s
  100000 reqs: 0.11s
  1000000 reqs: 1.10s
  par2
  10000 reqs: 0.02s
  100000 reqs: 0.41s
  500000 reqs: 2.02s
  seql
  10000 reqs: 0.04s
  100000 reqs: 0.50s
  500000 reqs: 2.65s
  seqr
  200000 reqs: 0.02s
  2000000 reqs: 0.19s
  20000000 reqs: 1.92s
  tree
  17 reqs: 0.48s
  18 reqs: 0.99s
  19 reqs: 2.04s

After D3316018, par1 and tree got faster (surprise win), but par2 got worse, and seql got much worse:

  par1
  10000 reqs: 0.01s
  100000 reqs: 0.08s
  1000000 reqs: 0.91s
  par2
  10000 reqs: 0.03s
  100000 reqs: 0.42s
  500000 reqs: 2.29s
  seql
  10000 reqs: 0.04s
  100000 reqs: 0.61s
  500000 reqs: 3.89s
  seqr
  200000 reqs: 0.02s
  2000000 reqs: 0.19s
  20000000 reqs: 1.83s
  tree
  17 reqs: 0.39s
  18 reqs: 0.77s
  19 reqs: 1.58s

Looked at the core (-ddump-prep) for Monad module.
Main observation is that GHC is really bad at optimizing the 'Request r a' constraint because it is a tuple.

To see why:

  f :: Request r a => ...
  f = ... g ... h ...

  g :: Show (r a) => ...
  h :: Request r a => ...

GHC will end up with something like:

  f $dRequest =
    let $dShow = case $dRequest of ... in
    let $dEq = case $dRequest of ... in
    ... etc for Typeable, Hashable, and the other Show ...
    let g' = g $dShow ... in
    let req_tup = ($dShow, $dEq, ... etc ...) in
    h req_tup ...

That is, it unboxes each of the underlying dictionaries lazily, even though it only needs the single Show dictionary.
It then reboxes them all in order to call 'h', meaning none of the unboxed ones are dead code.
I couldn't figure out how to get it to do the sane thing (unbox the one it needs and pass the original dictionary onwards).
We should investigate improving the optimizer.

To avoid the problem, I tightened up the constraints in several places to be only what is necessary (instead of all of Request).

Notably:

Removed Request constraint from ShowReq, as it was completely unnecessary.
All the *WithShow variants do not take Show constraints at all. Doing so seemed to violate their purpose.
The crucial *WithInsert functions only take the bare constraints they need, avoiding the reboxing.
Since *WithInsert are used by *WithShow, I had to explicitly pass a show function in places.
See Note [showFn] for an explanation.

This gave us back quite a bit on seql, and a bit on seqr:

  par1
  10000 reqs: 0.01s
  100000 reqs: 0.08s
  1000000 reqs: 0.90s
  par2
  10000 reqs: 0.02s
  100000 reqs: 0.36s
  500000 reqs: 2.18s
  seql
  10000 reqs: 0.04s
  100000 reqs: 0.55s
  500000 reqs: 3.00s
  seqr
  200000 reqs: 0.02s
  2000000 reqs: 0.18s
  20000000 reqs: 1.73s
  tree
  17 reqs: 0.39s
  18 reqs: 0.79s
  19 reqs: 1.54s

Finally, addProfileFetch was getting inlined into dataFetchWithInsert.
This caused some let-bound stuff to float out and get allocated before the flag test.
Adding a NOINLINE prevented this, getting about 10% speedup on par2 and seql.
Doing the constraint work above enabled this, because otherwise the call to
addProfileFetches was creating the reboxing issue where it didn't exist before.

  par1
  10000 reqs: 0.01s
  100000 reqs: 0.08s
  1000000 reqs: 0.89s
  par2
  10000 reqs: 0.02s
  100000 reqs: 0.35s
  500000 reqs: 1.98s
  seql
  10000 reqs: 0.04s
  100000 reqs: 0.53s
  500000 reqs: 2.72s
  seqr
  200000 reqs: 0.02s
  2000000 reqs: 0.17s
  20000000 reqs: 1.67s
  tree
  17 reqs: 0.39s
  18 reqs: 0.82s
  19 reqs: 1.65s

Reviewed By: simonmar

Differential Revision: D3378141

fbshipit-source-id: 4b9dbe0c347f924805a7ed4c526c4e7c9aeef077
2016-06-04 15:20:42 -07:00