Commit Graph

156 Commits

Author SHA1 Message Date
Simon Marlow
10a8a50df0 Fix bug in withEnv
Summary:
The problem was that we could lose the correct Env if a continuation
got blocked and restarted.

Reviewed By: niteria

Differential Revision: D5985280

fbshipit-source-id: f8afdb9d4db38781b33a8bddde46c031a133dec1
2017-10-05 13:11:49 -07:00
Simon Marlow
b67f7f6370 Haxl 2
Summary:
This is a complete reworking of the way that Haxl schedules I/O.  The
main benefits are:

* Data fetches are no longer organised into rounds, but can be
  arbitrarily overlapped with each other and with computation.  The
  scheduler supports an arbitrary queue of work items which it can
  evaluate while data-fetching is taking place in the background.  To
  take advantage of this, data sources must implement a new form of
  `PerformFetch`, namely `BackgroundFetch`.  The old forms of
  `PerformFetch` are still supported, but won't benefit from any
  additional concurrency.

* It is now possible to specify on a per-data-source basis whether
  fetching should be optimised for batching or for latency.  A request
  to a data source that doesn't benefit from batching can be submitted
  immediately.  This is done with the new `schedulerHint` method of
  `DataSource`.

Reviewed By: niteria

Differential Revision: D4938005

fbshipit-source-id: 96f12ad05ee62d62474ee4cc1215f19d0a6fcdf3
2017-10-03 00:28:54 -07:00
Simon Marlow
762d110041 Add preCacheComputation
Summary:
Restricted version of cachedComputation, useful for abusing
memoization for mocking functions.

Reviewed By: niteria

Differential Revision: D5861480

fbshipit-source-id: c3978bb675e260591bb99b7dd2219775a9422907
2017-09-19 07:48:40 -07:00
SSHz
d2ee0dd9c2 fix typos in Haxl/Core/Monad.hs
Summary: Closes https://github.com/facebook/Haxl/pull/72

Differential Revision: D5498033

Pulled By: mic47

fbshipit-source-id: b3ed98467859698709859cac412f5b6b53e8bbdc
2017-07-26 09:43:15 -07:00
SSHz
f5bf102f40 fix typos in tests/BatchTests.hs
Summary: Closes https://github.com/facebook/Haxl/pull/71

Differential Revision: D5494735

Pulled By: watashi

fbshipit-source-id: d7da88a66bd3f344db9daa6c6814382ef2584568
2017-07-25 17:52:20 -07:00
Bartosz Nitka
f1df1cb368 Prepare for 0.5.1.0 release
Summary:
We need a release for GHC 8.2.1 compatibility:
https://github.com/facebook/Haxl/issues/70

(Note: this ignores all push blocking failures!)

Reviewed By: simonmar

Differential Revision: D5488485

fbshipit-source-id: 61ae115e7456beb1dd8855d387690e13a1e09bdc
2017-07-25 04:24:40 -07:00
Bartosz Nitka
142f53c473 Test with GHC 8.2.1
Summary: GHC 8.2.1 has been released.

Reviewed By: watashi

Differential Revision: D5478389

fbshipit-source-id: 1be337521e409bbb4c01ef9b22d164973519a3aa
2017-07-23 22:08:55 -07:00
Zejun Wu
2da8d5354b Fix build when eventlog is enabled
Summary:
Build with eventlog is enabled was broken by refactoring, this should fix
it.

Reviewed By: xich

Differential Revision: D5410539

fbshipit-source-id: fd2dc97d9d853bcd6bc4b322c3995eec765227eb
2017-07-12 15:49:18 -07:00
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