Commit Graph

216 Commits

Author SHA1 Message Date
Paul O'Shannessy
456d5d2a1b Adopt Contributor Covenant
Summary:
In order to foster healthy open source communities, we're adopting the
[Contributor Covenant](https://www.contributor-covenant.org/). It has been
built by open source community members and represents a shared understanding of
what is expected from a healthy community.

Reviewed By: josephsavona, danobi, rdzhabarov

Differential Revision: D17104640

fbshipit-source-id: d210000de686c5f0d97d602b50472d5869bc6a49
2019-08-29 23:20:50 -07:00
Anubhav Bindlish
1119155782 Move trace_ function to Core.Util (#102)
Summary:
Pull Request resolved: https://github.com/facebook/Haxl/pull/102

I want to use the trace_ functionality in rest of Haxl code as well.
Instead of defining it in each module, let's move this to Haxl.Core.Util. It's
better also because this module is not exported from haxl.

Reviewed By: watashi

Differential Revision: D16523067

fbshipit-source-id: f7e75cdd6920247a778100c22730bd113009e9aa
2019-07-29 07:06:24 -07:00
Zejun Wu
680c222e12 Improve outgoneFetchesTest
Summary:
This test is flaky and failed in recent travis ci run:

https://travis-ci.org/facebook/Haxl/jobs/560169278

2ms is too small and a context switch or gc can affect the order of events.
Let's enlarge this to 100ms, which is similar to what we have in
FullyAsyncTest.

Reviewed By: anubhav94N

Differential Revision: D16522892

fbshipit-source-id: d27dd0b185115fd2ab0df9496b0811066e731305
2019-07-26 13:56:05 -07:00
Zejun Wu
c8a04950cb Expose andThen to perform computations sequentially
Summary:
We have define this in tests and other libraries. Let's simply expose this
functionality from `Haxl.Prelude` as it can be useful in a few cases.

Reviewed By: anubhav94N

Differential Revision: D16522569

fbshipit-source-id: b35726e9ad172a36d76b755498fbb53d9a9db188
2019-07-26 13:56:05 -07:00
Anubhav Bindlish
3329d57961 Add dupableCacheRequest function
Summary:
Right now, Haxl throws a `DataSource` error if we try to cache a
request that already exists in the `Haxl` cache. For unit tests, it seems
useful to allow the cache to be overwritten. Adding a new function to do this.

Reviewed By: simonmar

Differential Revision: D16280746

fbshipit-source-id: febafb4f3a2c0087aff204ab442911b022712362
2019-07-17 13:24:10 -07:00
Anubhav Bindlish
56bf9e9722 Fix type of withCallGraph (#100)
Summary:
Pull Request resolved: https://github.com/facebook/Haxl/pull/100

The type of this function should be `GenHaxl u w a`

Reviewed By: josefs

Differential Revision: D15392634

fbshipit-source-id: e98818d0558616f38edaaa86fea8a44ed062c878
2019-05-17 08:03:21 -07:00
Karen Ang
67638ce8bd Move CallGraphRef to Haxl Env
Summary:
Adds the ability for one to record the function callstack within the `Haxl` monad.
The main function is `withCallGraph`, and supporting types are in `Haxl.Core.CallGraph`.

Reviewed By: watashi

Differential Revision: D14857851

fbshipit-source-id: daab97e8144ff63104ad9e79a3a792a4471e5588
2019-05-14 14:22:50 -07:00
Anubhav Bindlish
5f2ebd2580 Add correctness tests for outgone-fetches logging (#99)
Summary:
Pull Request resolved: https://github.com/facebook/Haxl/pull/99

This adds unit tests to haxl, to make sure we are tracking the outgone
fetches correctly..

Reviewed By: simonmar

Differential Revision: D14683672

fbshipit-source-id: 49a318f0b8aa38c2af154fcbe0946122e70b9565
2019-05-09 06:46:56 -07:00
Anubhav Bindlish
c365886e79 Log outgone fetches to Env
Reviewed By: simonmar

Differential Revision: D14467207

fbshipit-source-id: 4c3f551034c2f253a0c8bfff47e0dbc170131255
2019-05-09 06:46:56 -07:00
Anubhav Bindlish
da963ddc34 Fix build for ghc-7.8.x
Summary:
Travis build is failing on ghc-7.8, as `<$>` is not available for that version
https://travis-ci.org/facebook/Haxl/builds/518421734

(Note: this ignores all push blocking failures!)

Reviewed By: lolotp

Differential Revision: D14877878

fbshipit-source-id: bfd13f910142ede2f5a54906c508aba9105509d6
2019-04-10 13:32:39 -07:00
Zejun Wu
697a47a7c3 Correct the allocation values logged from backgroup fetch
Summary:
The allocatin counter is keep decreasing, so the number returned by
`getAllocationCounter` is negative. We want to absolute value to be consistent
with other fetches.

Reviewed By: simonmar

Differential Revision: D14839122

fbshipit-source-id: d6e475b209c4a14823fcaff8c0ea17cbbd5bdbb1
2019-04-10 11:03:47 -07:00
Anubhav Bindlish
f99afd1354 Add WriteTests to haxl.cabal
Summary: Whoops forgot to do when I added the test file.

Reviewed By: zilberstein

Differential Revision: D14874686

fbshipit-source-id: 5bb4b83368f03e9867516b3876acb83ea8aa6852
2019-04-10 10:52:58 -07:00
Anubhav Bindlish
50748be3af Add benchmark tests for writes
Summary:
Add benchmarks for sequential and parallel writes.

Ran the benchmark for 10^6 writes
parallel - 0.19s
seq - 0.07s

Running in parallel probably has more contention for the IORef

Reviewed By: simonmar

Differential Revision: D14386951

fbshipit-source-id: 164972e714eac14406fc106df073474d141e9ca0
2019-04-10 09:48:57 -07:00
Anubhav Bindlish
b03f2e5102 Add correctness tests
Summary:
Most important thing I want to test is that when a memoized
computation happens again - the writes are indeed duplicated in the
environment. This diff adds tests for different ways memoized computation can
happen in conjunction with non-memoized computation..

Reviewed By: simonmar

Differential Revision: D14386667

fbshipit-source-id: a03a9a41697def968bf6e11ad66b9dd9f3a9a7f1
2019-04-10 09:48:57 -07:00
Anubhav Bindlish
dc6eeb46ef Fix haxl core tests
Summary:
Expose a conveniece wrapper `runHaxlWithWrites` which returns the writes along with
the result of the `Haxl` computation.

Reviewed By: simonmar

Differential Revision: D14386668

fbshipit-source-id: 95757916691f7b9b1291c7dceae7eafe8738cfca
2019-04-10 09:48:57 -07:00
Anubhav Bindlish
70f5bad436 Add writes to IORef in Env
Summary:
Here I try to populate the writes done as part of a Haxl computation
in an IORef inside the Environment.

`IVar` which is the synchornisation point,
also acts as the point where we store intermediate writes for Haxl
computations, so they can be memoized and reused whenever a memoized
computation is done again. This is done inside `getIVarWithWrites` function.

This works, because we create new IVars when running a memo computation
or a data fetch, and it is only at these places where we need to create a new
environment with empty writes to run the computation in. So I run every memoized
computation in a new environment (with empty writes) and populate the writes in this new
environment. At the end of the memoized computation, I look up these writes from the `IVar`
and also add them to the original environment. This way ultimately all writes are correctly
propagated upwards to the top level environment user passes to `runHaxl`.
This logic lives inside `execMemoNow`.

Reviewed By: simonmar

Differential Revision: D14342181

fbshipit-source-id: a410dae1a477f27b480804b67b2212e7500997ab
2019-04-10 09:48:57 -07:00
Zejun Wu
ca0c71441d Fix travis CI for cabal new-sdist and build against ghc-8.6.4
Summary:
CI failed because of recent change in cabal-head that sdist is now new-sdist
instead of v1-sdist and the ouput path is different.

We also build against ghc-8.6.4 instead of ghc-8.6.2 now as this is the latest
stable version of ghc-8.6.

Reviewed By: alexanderGugel

Differential Revision: D14815535

fbshipit-source-id: 80514188fc4c2d00a10cf7dd1d710eb28ec02e50
2019-04-08 13:00:39 -07:00
Zejun Wu
532445ba5e Collect allocation stats for background fetch
Summary:
Right now, we get no alloication infroamtion for background fetch at all.
This is because the allocation usually happen in a thread and we only get
back the control in a callback. As a improvement, we can just use the total
allocation in the child thread as the allocation.

While individual allocation won't be correct if `putResult` is called more than
once. The total sum and amortized allocation will still be helpful stats.

Reviewed By: simonmar

Differential Revision: D14734588

fbshipit-source-id: 6beed3741a496d308bdcec75eb0f0e0bbfbbae38
2019-04-05 15:08:33 -07:00
Zejun Wu
3dde86f794 Also run travis CI against ghc-8.4.4 and ghc-8.6.2
Summary: Change ghc-8.4.3 to ghc-8.4.4 and add ghc-8.6.2.

Reviewed By: karen

Differential Revision: D13363035

fbshipit-source-id: 988f13f0a0022d2deec6d03c30cc8ee17a85d252
2018-12-06 16:26:18 -08:00
Zejun Wu
df3d53c79b Fix compile warnings for ghc-8.4
Summary: `(<>)` is exposed by `Prelude` now, add guard to suppress those warnings.

Reviewed By: karen

Differential Revision: D13144913

fbshipit-source-id: 856de3b1d4e206c50d12ac79bdf48194ecc7cc78
2018-11-20 21:00:31 -08:00
Simon Marlow
4638736ac6 Add a warning about concurrent runHaxl calls
Reviewed By: malmerey

Differential Revision: D13067528

fbshipit-source-id: 08ba93fda2f6518eaedea0956d198a59255b16d9
2018-11-15 01:42:39 -08:00
Simon Marlow
24494b5e31 Fix lower bound on base; we don't support GHC 7.6.3 (#96)
Reviewed By: watashi

Differential Revision: D10011102

fbshipit-source-id: f607e2a6bc9ec11bbb107b94f6d94d70411df1f4
2018-09-24 15:56:57 -07:00
Simon Marlow
e187bc2474 Updates for GHC 8.4.x and 8.6.x (#97)
Summary: And bump version to 2.0.1.1

Reviewed By: anubhav94N

Differential Revision: D10011092

fbshipit-source-id: 4d45f79fb4c89112d29d40f0d53a50441a443729
2018-09-24 14:20:57 -07:00
Majd Al Merey
a6d9563ced - Use SourceCode Location to Calculate Memoization Labels
Summary:
Use the source location of the `memo` statement to calculate the memoization label as opposed to the memoization key. This is to make sure that multiple `memo` calls in the same declaration will get different labels.

This enables to remove `memoUniqueText` and the related pragma as `memoUnique` will now have a Text label by default.

Reviewed By: simonmar

Differential Revision: D9779196

fbshipit-source-id: 89d2ce6d5a6ebc4a6b8246a5ef561ecf8e18c522
2018-09-24 10:35:26 -07:00
Kyle Nekritz
9f4574d8a4 Fix code of conduct link.
Summary: Thanks cmarkle for noticing in https://github.com/facebookincubator/fizz/pull/5

Reviewed By: dark

Differential Revision: D9195501

fbshipit-source-id: bdbe1588cdcd353d60fcaab14a4fac8bd2256355
2018-08-07 09:35:56 -07:00
Ryan Menezes
4400409acb get rid of num_rounds
Summary:
This diff removes the scuba field as described in the task, as well as removing numRounds from Stats. This involved removing the numRounds assertion from expectRounds* functions, which I chose to rename to expectResult* (lmk if you prefer something different there).

Within Stats, I merely deleted the numRounds function. I didn't go looking for anything deeper to clean up because it looked like `rs` was used in other functions.

Reviewed By: zilberstein

Differential Revision: D8963298

fbshipit-source-id: d367b53007be03bd290222c676539680acd9f929
2018-07-25 09:21:34 -07:00
Andrew Farmer
2f8204cc2a Add Monoid instance for StateStore
Summary: Add a monoid instance for merging two StateStores.

Reviewed By: watashi

Differential Revision: D8961041

fbshipit-source-id: f6539ec0f0915b572a42ab34c098a9be6c8664f1
2018-07-23 18:35:36 -07:00
Simon Marlow
aba36943e5 Fix more links
Reviewed By: anubhav94N

Differential Revision: D8713114

fbshipit-source-id: f96908948cf3fdcfe667f62d7e42fe3808f2cdf7
2018-07-03 13:50:28 -07:00
Julian Priestley
04208454e8 Handle dumping an empty cache
Summary: dumpCacheAsHaskellFn generates an empty `do` block if the cache is empty.

Reviewed By: codemiller

Differential Revision: D8712898

fbshipit-source-id: fcaf4a0cc6c5416155aebda8fe68f3f026d8d025
2018-07-02 10:20:15 -07:00
Simon Marlow
9e6d3c3523 Bump to 2.0.1.0
Summary: The MemoVar export causes a minor version bump

Reviewed By: anubhav94N

Differential Revision: D8588703

fbshipit-source-id: 8dfb5ed5f44a681810860080b8413fc61bf58c89
2018-06-25 04:05:40 -07:00
Simon Marlow
b3e7a632af Empty commit to re-sync internal repo
fbshipit-source-id: b3a5238e4f6f9fbf57260b4191c86cb291481c16
2018-06-22 14:49:44 +01:00
Simon Marlow
bf2cf4dce5 Update the example facebook Haxl data source
Reviewed By: codemiller

Differential Revision: D8056786

fbshipit-source-id: a33a43be5f54691645c82d812a7d706265e9ed19
2018-06-22 06:09:02 -07:00
Simon Marlow
b31e7aaf4b Update facebook example readme.md
Reviewed By: codemiller

Differential Revision: D8179581

fbshipit-source-id: 658daf7b55f01242be7358ce263957eef4e6820c
2018-06-22 05:41:09 -07:00
Alexander Biehl
1bc9bdedc2 Expose MemoVar type (#94)
Summary:
Unfortunately we can't refer to `MemoVar` in type signatures otherwise.
Closes https://github.com/facebook/Haxl/pull/94

Reviewed By: codemiller, malmerey

Differential Revision: D8531175

Pulled By: simonmar

fbshipit-source-id: 03a2b27da9b71d6b7a4a9fdbd4dfbdfe744eabc8
2018-06-20 07:05:05 -07:00
Oleg Grenrus
a8e6d16310 Allow aeson-1.4
Summary: Closes https://github.com/facebook/Haxl/pull/93

Reviewed By: watashi

Differential Revision: D8379516

Pulled By: malmerey

fbshipit-source-id: 5f77333490636714c8b951a5bba6f26329a8e4fd
2018-06-12 11:53:25 -07:00
Karen Ang
e356bf98bb Ensure that calls to memo have globally unique keys
Summary: Rewrites calls of `memo` to `memoUnique` to ensure that the keys are globally unique

Reviewed By: xich

Differential Revision: D8085641

fbshipit-source-id: 6de214ed0e2195d59a46752edb28fc4ad591110f
2018-05-29 14:38:11 -07:00
Oleg Grenrus
6582f45c21 Remove aeson bound from test-suite
Summary:
It's inherited from the library anyway.
Closes https://github.com/facebook/Haxl/pull/91

Reviewed By: simonmar

Differential Revision: D8074585

Pulled By: malmerey

fbshipit-source-id: 35955c2426df0725835a4351ee140012ac102c82
2018-05-21 04:49:10 -07:00
Simon Marlow
f0d157522f One more try to fix the doc links
Reviewed By: zilberstein

Differential Revision: D8059959

fbshipit-source-id: 390f14cb572e81998a781971316a51f87caa588f
2018-05-18 12:20:08 -07:00
Simon Marlow
79e81825ef 2.0.0.1
Summary:
minor version bump required so that I can update the Hackage package
to fix the URLs.

Reviewed By: codemiller

Differential Revision: D8057062

fbshipit-source-id: 2204d28a965df3933b7acf5b81c62b4380835e63
2018-05-18 11:55:27 -07:00
Simon Marlow
abf1e3fc6c Fix documentation links (#89)
Reviewed By: codemiller

Differential Revision: D8056514

fbshipit-source-id: 16044a28a2925ed66124444bdcd78825c0dc32c6
2018-05-18 08:17:14 -07:00
Oleg Grenrus
adb6d5c28f Support GHC-8.4.1 (SMP), lax bounds
Summary: Closes https://github.com/facebook/Haxl/pull/88

Reviewed By: simonmar

Differential Revision: D7365219

Pulled By: niteria

fbshipit-source-id: 28ff85b065000e367ef919b970bc59a76faa15fb
2018-03-22 13:08:28 -07:00
Simon Marlow
61646c5f99 Use Proxy where applicable
Summary:
In general it's better to use Proxy than to use undefined arguments
when passing types.

This is one API change I had lying around that we should get in before
a Haxl 2 release, so that we only force one round of breakage for
clients.

Reviewed By: zilberstein

Differential Revision: D7254826

fbshipit-source-id: d5f7ec9ac8586da845760c0ffa1ddbcfef1d13c6
2018-03-14 08:58:16 -07:00
Simon Marlow
84521bbbc5 Fix build with GHC 7.8.4
Reviewed By: xich

Differential Revision: D6925303

fbshipit-source-id: ff0cd2ffd2f888c61038372031aa105467adbc84
2018-02-08 07:17:21 -08:00
Simon Marlow
aff472bc25 Fix profiling test
Summary: I noticed this test was broken in `cabal test` recently.

Reviewed By: mic47

Differential Revision: D6857296

fbshipit-source-id: ca7d15ba841f1dc79acccf1cd4999e8fcea994c8
2018-02-01 07:42:18 -08:00
Simon Marlow
6b75496a29 Correctly account for allocation done in child threads
Summary:
This isn't pretty, but it's the least intrusive and most efficient way
I could find to do it.

The tricky part is that when doing multiple putResults in the same
child thread, we have to ensure the *last* one (and only the last one)
is putResultFromChildThread.

Reviewed By: xich

Differential Revision: D6519631

fbshipit-source-id: 1c3c40f311031ac4cc8ed82daefcb7740b91541e
2018-01-10 08:51:53 -08:00
Jade Auer
550d1a5e1d Add FB contrib info & code of conduct
Summary:
Add FB standard code of conduct and rough contributing file (based on Duckling's).
ref: https://fburl.com/aedakn3u
Closes https://github.com/facebook/Haxl/pull/83

Reviewed By: mic47

Differential Revision: D6668802

Pulled By: simonmar

fbshipit-source-id: 72c7c98ea3a7d2ed54021741914b7d2cbb2b9878
2018-01-09 12:50:21 -08:00
Noam Zilberstein
d7cefbca1c log to sigma_datasources scuba table
Summary:
It is useful to have a separate scuba table to record datasource stats where the datasource name is a row instead of a column. This allows us to do more complex aggregations over time/allocations/etc of ALL datasources not per each individual one.

The way it's set up now I rate limit on the datasource name. I'm not sure if this is the right move, maybe I should rate limit on both the datasource and the context? I also log each fetch as a separate row. This might end up being expensive, but it allows us to get more detailed information about batch sizes (ie p95, avg, sum). If we combined all fetches for each datasource then we'd get less detailed information, but it may be more practical.

Reviewed By: sameenjalal, simonmar

Differential Revision: D6492647

fbshipit-source-id: 28399ece277f93616786bdfb18264a0250aa238b
2018-01-09 09:35:35 -08:00
Simon Marlow
c1c789a71f Change license to plain BSD3
Reviewed By: mic47, niteria

Differential Revision: D6519157

fbshipit-source-id: 7fd977837bb7dd8463d697d685107aaf07c95255
2017-12-08 04:33:35 -08:00
Ionut Victor Anghelcovici
f21b94f417 Enable caching while recording tests for uncachedRequest
Summary:
Try different approaches, but ended up with this. At first I wanted to use SIEnv, but that is not available from Core (Fetches.hs) and we don't want that dependency.
Then I tried creating a haxlsh command for it, but I didn't like it as it will be not useful. So I pass it via the haxlConfig and set the env just before running the test.

The only thing that I am not sure about is if we need to deprecate uncachedResponse. The new signature is a more restricted type that implements the Show type class. As this
was already called with responses everywhere, it seems to work out of the box.

I am a bit confused though for the BlackBird issue. Memcache will fail Set, but shoudn't fail Get as that is using dataFetch which is cached already. It might have been another issue.

Reviewed By: simonmar

Differential Revision: D6195542

fbshipit-source-id: 483d7ec4f32a27b8c9cbfb5d9b129abe40a93c54
2017-11-10 08:22:11 -08:00
Simon Marlow
eecd856bf9 Add changelog for 2.0.0.0
Reviewed By: codemiller

Differential Revision: D6259667

fbshipit-source-id: 2839430f56668f4c9904fdf041f619be8472953f
2017-11-08 08:04:09 -08:00