Commit Graph

313 Commits

Author SHA1 Message Date
Andreas Abel
7255eb04d4 Bump dependencies and CI (#158)
Summary:
- include latest GHCs in CI
- ~~latest minor version is determined by haskell-actions/setup~~
- ~~freeze file is a bad cache key as it contains a time stamp, use the build plan instead (the correct choice)~~

~~Successful CI run at: https://github.com/andreasabel/Haxl/actions/runs/6725224644~~
CI running here: https://github.com/andreasabel/Haxl/pull/1

Pull Request resolved: https://github.com/facebook/Haxl/pull/158

Reviewed By: simonmar

Differential Revision: D66102814

Pulled By: josefs

fbshipit-source-id: a31dbf74b7086d909c2a2c1508a749341cde11c0
2024-11-19 05:14:57 -08:00
Josef Svenningsson
fb2cabbcef Add copyright headers
Reviewed By: simonmar

Differential Revision: D62383590

fbshipit-source-id: 9d0e60f524be8c40c9934ed4458f5202cbf377a6
2024-09-10 03:36:24 -07:00
Simon Marlow
993125fe28 Compile with GHC 9.2.4
Reviewed By: pepeiborra

Differential Revision: D61711791

fbshipit-source-id: c32f12ce18155f93fb5b6c64f17a0fdce8a057d8
2024-08-30 03:11:19 -07:00
Simon Marlow
6c86542a18 Update CI and bump version to 2.5.1.0 (#159)
Summary: Pull Request resolved: https://github.com/facebook/Haxl/pull/159

Reviewed By: donsbot

Differential Revision: D57851842

Pulled By: simonmar

fbshipit-source-id: 020209099e136a9e1b2a7934c927adb62e4ae5e8
2024-05-28 06:19:32 -07:00
Pepe Iborra
42b72a2daf scheduler hint with request
Summary: https://www.internalfb.com/diff/D57330122?dst_version_fbid=975275170917805&transaction_fbid=1863882647422768

Reviewed By: simonmar

Differential Revision: D57379154

fbshipit-source-id: 77593417465cf6d34e0813abc2dffaa389ba1584
2024-05-16 05:40:04 -07:00
Josef Svenningsson
6cd30c084d Convenience Functor instance for Result
Summary: The Result type admits a Functor instance and I've found it useful.

Reviewed By: simonmar

Differential Revision: D41469853

fbshipit-source-id: 619941cf58e679dd2f7a483362d2c108e0aec452
2022-11-23 03:01:39 -08:00
Rui Gonçalves
ef52a522fb Generalize Haxl.Core.Monad.mapWrites
Summary:
On my last diff I forgot to generalize `mapWrites` in Haxl core, leaving it working only with `WriteTree`s. Mapping functionality is needed if we want to use alternative data structures.

Luckily, the function can be trivially generalized by mapping the `Monoid` instead and exposing `mapWriteTree` to lift a function mapping elements to one mapping `WriteTree`s.

Reviewed By: josefs

Differential Revision: D39500863

fbshipit-source-id: c0c140544e135814575bc1500fec649fabc1fdec
2022-09-15 02:35:41 -07:00
Rui Gonçalves
260a97b757 Allow any Monoid to be used as write storage in Haxl monad
Summary:
Currently, the `Haxl` monad stores writes using a hardcoded sequential data structure, a `WriteTree`. This makes it efficient to append new writes and merge two collections of writes, operations needed for `Haxl` to perform memoization efficiently.

However, in some cases storing and reading logs this way is inefficient in terms of space and time. A very simple example is a counter that can be incremented during `Haxl` computations. A `WriteTree Int` would store one entry per increment, while this case could be trivially represented using a single `Int`.

On this diff I'm changing the core monad implementation to accept any monoid as write structure. Rather than dealing with individual write objects inserted into a collection, writes are provided as monoids which get merged on each write.

**This is a breaking change**, as Haxl's `w` now represents the whole write log rather than a single write. However, `WriteTree` was kept and made a monoid, so `WriteTree w` can be used by clients in place of `w` to keep the same behavior.

Reviewed By: josefs

Differential Revision: D39305208

fbshipit-source-id: 7b488682280cda170e8b156765f69c3377bcadfc
2022-09-14 04:23:51 -07:00
Joshua Chia
b334db4656 Allow hashable 1.4 and time 1.11 (#153)
Summary: Pull Request resolved: https://github.com/facebook/Haxl/pull/153

Test Plan: https://github.com/facebook/Haxl/actions/runs/2475703672

Reviewed By: buridiaditya

Differential Revision: D37074253

Pulled By: watashi

fbshipit-source-id: 9c24d96b940fbf1a1ac393056832dfdf22ae5d4c
2022-06-10 13:43:22 -07:00
Joseph Morag
fd017a6ee3 Build with ghc 9.2 (#152)
Summary:
Bumps bytestring upper bound to <0.12 and fixes some non-canonical monoid and monad definitions that don't use semigroup/applicative.

Pull Request resolved: https://github.com/facebook/Haxl/pull/152

Test Plan: sandcastle + CI on github

Reviewed By: josefs

Differential Revision: D36320446

Pulled By: watashi

fbshipit-source-id: 53d82674be0235bf204cd17c9ee6f61d05177143
2022-05-12 11:28:13 -07:00
Simon Marlow
40d45c1a6a Update version to 2.4.0.0 (#151)
Summary: Pull Request resolved: https://github.com/facebook/Haxl/pull/151

Reviewed By: pepeiborra

Differential Revision: D35647399

Pulled By: simonmar

fbshipit-source-id: 200ba220f582f1de8344fd4f467c8ec9bc90633a
2022-04-14 08:48:45 -07:00
Jan van Brügge
626f8a6a66 Allow aeson 2.0 (#148)
Summary:
Only needed changes to the tests, the main library is untouched.

Also updates the stack.yaml to use GHC 9.0.2

Pull Request resolved: https://github.com/facebook/Haxl/pull/148

Reviewed By: simonmar

Differential Revision: D35500924

Pulled By: pepeiborra

fbshipit-source-id: 16619084c4f2d76c9495fd778401f8bab66e26d2
2022-04-11 03:11:20 -07:00
Jan van Brügge
ca65bb92d0
Fix warnings for -XStarIsType (#149)
This is backwards compatible for all GHC >= 8.0
2022-04-06 15:55:36 +01:00
Josef Svenningsson
18e222f58d Benchmark JK datasource in Haxl
Summary:
This diff defines an accurate way of benchmarking the JK datasource in Haxl. The Spec variant are the ones to look at.
I've kept the Haxl flavored tests as a cautionary tale but they just end up benchmarking hashtable lookup.

Reviewed By: buridiaditya

Differential Revision: D32499846

fbshipit-source-id: 885bb438ca2615a8816379517b16a33745a4f33e
2022-03-29 02:41:41 -07:00
Dmitry Vinnik
47e93999a8 docs: add GH button in support of Ukraine (#147)
Summary:
Our mission at [Meta Open Source](https://opensource.fb.com/) is to empower communities through open source, and we believe that it means building a welcoming and safe environment for all. As a part of this work, we are adding this banner in support for Ukraine during this crisis.

Pull Request resolved: https://github.com/facebook/Haxl/pull/147

Reviewed By: simonmar

Differential Revision: D34649194

Pulled By: dmitryvinn-fb

fbshipit-source-id: 6bb709a7ed5587667f13aadd7facba04ca9d3546
2022-03-07 09:39:07 -08:00
Zejun Wu
1c991973aa Fix profling build for tests (#146)
Summary:
Fix profling build for tests and update TARGETS to include profling build for
tests in contbuild.

Closes #146

Reviewed By: simonmar

Differential Revision: D34542444

fbshipit-source-id: 0e188f5b31bf30e684dbcb1447cbfeac779add02
2022-03-01 13:37:13 -08:00
Zejun Wu
6deb0cac0d Include the ReportFlags in logging samples
Summary:
Log the ReportFlags in Haxl Env to some data sets. This can help us group
samples by differnet report flags and check stats like the allocation overhead
for enabling stats or profiling.

Reviewed By: josefs

Differential Revision: D33436458

fbshipit-source-id: 092e36b361e0f27ae061d8d6c81b7fdf467bfb61
2022-01-06 10:07:30 -08:00
YaroslavPodorvanov
7a043e0adf Fix logo path to can view logo (#145)
Summary:
fix logo path

Pull Request resolved: https://github.com/facebook/Haxl/pull/145

Reviewed By: josefs

Differential Revision: D33074727

Pulled By: watashi

fbshipit-source-id: 82cfca9fe31fa3cbfb547012e4fb52a18abf2a26
2021-12-14 16:44:45 -08:00
nalchevanidze
115b3be9f4 support GHC 9.0.1 (#144)
Summary:
new GHC 9.0 parser fails on space before strict operator

![image](https://user-images.githubusercontent.com/18636038/138489244-9321cc80-5bdf-4496-80ef-6afb289a2f13.png)

this pull request supports GHC 9.0 by removing this space.

Pull Request resolved: https://github.com/facebook/Haxl/pull/144

Reviewed By: josefs

Differential Revision: D33074741

Pulled By: watashi

fbshipit-source-id: 78579a041f939c0d9a0690a0e88f2ba881972332
2021-12-14 16:41:52 -08:00
Zejun Wu
461e12f4d7 Fix unused-record-wildcards warnings reported by ghc-8.10.2
Summary: Fix unused-record-wildcards warnings reported by ghc-8.10.2 on github.

Reviewed By: josefs, simonmar

Differential Revision: D33030387

fbshipit-source-id: 012e3935576eb1da7529d8a5500f1e884f64cc28
2021-12-13 12:12:07 -08:00
Zejun Wu
8c645b0e20 Include label stack in HaxlException when ReportExceptionStack is on
Summary:
Add a new `ReportFlag` `ReportExceptionStack`. When it is enabled, we will
include the label stack in `HaxlException`. This will allow us provide stack
in `HaxlException` in non-prof rts. The label stack can also provide details
at different level compared to the `CostCentreStack`:

* with `-fprof-auto` or `-fprof-auto-top`, we can get reasonably detailed ccs.
* label stack only works well when enough labels are added either manually or
  by preprocessing.
* label stack works better for cases where the different `Haxl` computations
  are constructed dynamically in some common framework, where we also create
  dynamic labels.

Reviewed By: simonmar

Differential Revision: D32936619

fbshipit-source-id: 4aacd576dff062706a848a93f60d93982e4b8717
2021-12-09 20:40:29 -08:00
Zejun Wu
30afbce0fe Make report flags a bitmask instead of sequential numbers
Summary:
Make report flags a bitmask instead of sequential numbers. The reporting
behavior may not be strictly ordered, some reporting behavior can be enabled
independently. By not using magic numbers, it will also be easier to introduce
new reporting behavior.

We plan to add a new `ReportExceptionStack` flag include label stack in
`HaxlException` in the future, which can be enabled independently with
`ReportFetchStack`.

Reviewed By: simonmar

Differential Revision: D32933603

fbshipit-source-id: 4028aa91b68caa738684a77392c916970b4605c9
2021-12-09 20:40:29 -08:00
Zejun Wu
360a69f726 Remove AllocationLimitExceeded special case in rethrowAsyncExceptions
Summary:
Remove special handling of AllocationLimitExceeded in rethrowAsyncExceptions.
AllocationLimitExceeded is child of SomeAsyncException since it's publicly
available in base-4.8 (ghc 7.10), so for all ghc versions we support
(ghc >= 8.2), we don't need this.

Reviewed By: pepeiborra

Differential Revision: D32474812

fbshipit-source-id: 7d0d53b7bf55d3d4965c653cf404db2675f7b961
2021-11-17 13:07:00 -08:00
Aditya Buridi
bba3e8c49f Adds support to store stats from Datasource.
Summary:
- Update the result variable to accept `DataSourceStats` data from datasource.
- Log `DataSourceStats` into `statsRef`

Reviewed By: josefs

Differential Revision: D30726773

fbshipit-source-id: d54a303e925260f91720d6855c3fb289017642e8
2021-09-16 01:54:09 -07:00
Aditya Buridi
fc7f4cf84d Adds new type to support DataSource stats returned from remote.
Summary: `DataSourceStats` is used to store the statistics data returned from datasource query. `FetchDataSourceStats` is used to log this into the `statsRef` inside of Env.

Reviewed By: josefs

Differential Revision: D30726774

fbshipit-source-id: d38b40c6842f1dec9c04b600b38bb01fb62eaaf9
2021-09-16 01:54:09 -07:00
Zejun Wu
575d8560c5 Track the label stack instead of the current one during execution
Summary:
Keep track of the label stack as a NonEmpty list instead of just the current
label. While we can always reconstruct the label stack from the
`profileTree`, we need reverse the edge to do so and it's not efficient
it we repeated doing this during the execution.

Reviewed By: pepeiborra

Differential Revision: D30526429

fbshipit-source-id: 84db2924a0327df8edbb20c952607d4fac2de0f0
2021-09-14 11:21:14 -07:00
Dylan Yudaken
8f018dc9cf Enqueue fallback results onto the completion queue (#143)
Summary:
Pull Request resolved: https://github.com/facebook/Haxl/pull/143

Rather enqueue fallback results onto the completion queue, to better mimic what happens in a real fetch.
This allows `F <$> a <*> b` to fetch both a and b, even if a throws an exception.

Reviewed By: josefs

Differential Revision: D28964005

fbshipit-source-id: e50814498919a0d8f1ccf5113c419243684d81de
2021-06-09 04:31:35 -07:00
Dylan Yudaken
b30c4ac85d Change type of CompleteReq (#142)
Summary:
Pull Request resolved: https://github.com/facebook/Haxl/pull/142

Change type of CompleteReq to accept a ResultVal rather than an Either. This prepares it for being used in the next diff, and should be a no-op as the transform happened before use anyway

Reviewed By: josefs

Differential Revision: D28964006

fbshipit-source-id: ddfb6fc1ca66363c38b70eaf48fe90d26fae657d
2021-06-09 04:31:35 -07:00
Dylan Yudaken
5c49986786 check fallback datacache for cacheResultWithInsert (#141)
Summary:
Pull Request resolved: https://github.com/facebook/Haxl/pull/141

There are two ways into the DataFetch cache, through cacheResult, and dataFetch. The fallback only worked for dataFetch, and this diff adds cacheResult. This allows tests to inject state such as time through the fallback, and that should allow consistent tests

Differential Revision: D28534164

fbshipit-source-id: 64811913742c98708eb7f0cf3d651d3a12816323
2021-05-19 07:03:27 -07:00
Dylan Yudaken
54fcaf77b7 add stats when using fallback cache (#140)
Summary:
Pull Request resolved: https://github.com/facebook/Haxl/pull/140

Stats can still be important with the fallback cache, as this provides a way to tie fetches to labels

Reviewed By: josefs

Differential Revision: D27265549

fbshipit-source-id: f264c39de259e65cff7f510c2f79b7d8b5c31f52
2021-03-24 03:09:20 -07:00
Josef Svenningsson
96435994d5 Remove unnecessary Typeable constraint for SubCache
Summary: The constraint isn't needed.

Reviewed By: simonmar

Differential Revision: D27189237

fbshipit-source-id: 7fc6740e7ce9ca1ade68c0fda8850a45fb03e47d
2021-03-22 03:55:56 -07:00
Jiayuan Ma
09386c47a0 Sort writes in Haxl Write tests
Summary: Add `Ord` to `SimpleWrite` and `assertEqualIgnoreOrder` that sorts lists before comparison

Reviewed By: ahaym

Differential Revision: D26985618

fbshipit-source-id: 2c5f34775815a2d1af4a304fd0ce2719dc9417a6
2021-03-11 14:04:09 -08:00
Dylan Yudaken
4052d9d245 allow a fallback datacache lookup (#139)
Summary:
Pull Request resolved: https://github.com/facebook/Haxl/pull/139

This diff allows the user to insert a fallback datacache lookup, which will allow test caches to be injected into the running of a Haxl computation

Reviewed By: simonmar

Differential Revision: D26691327

fbshipit-source-id: ad901697a6bff08adddd6cc98ab9c4e64227098f
2021-03-11 06:16:09 -08:00
Mark Hay
210830b252 Add function that runs a computation and transforms the writes performed within
Summary: Adds `mapWrites`, which runs a computation and returns the result, and also maps over the performed writes with the provided function

Reviewed By: DylanZA

Differential Revision: D26615745

fbshipit-source-id: 1478b0658a2054f87e9f21352e6a18832398ad78
2021-03-01 08:28:04 -08:00
Aditya Buridi
f3736effe1 Clears the writeLogsRef/writeLogsRefNoMemo in runHaxlWithWrites
Summary: `writeLogsRef`/`writeLogsRefNoMemo` are not cleared after the `runHaxlWithWrites` execution inspite of returning the write logs. This causes the writes to keep piling up across computations with the same env.

Reviewed By: DylanZA

Differential Revision: D26049434

fbshipit-source-id: f03742dc0cf1d7969b9fa2529a68371ab6280fd7
2021-02-02 02:34:23 -08:00
Josef Svenningsson
8eb966ccf7 Use Github Actions instead of Travis CI (#138)
Summary:
Pull Request resolved: https://github.com/facebook/Haxl/pull/138

We're migrating off of Travis CI. This diff enables github actions for CI instead.

Reviewed By: watashi

Differential Revision: D25588039

fbshipit-source-id: 4d4b03736eec25212e6bff29ec59377f82ab27c3
2020-12-17 03:41:59 -08:00
Szymon Nowicki-Korgol
419989455b Ensure Haxl is compatible with GHC 8.8
Reviewed By: pepeiborra

Differential Revision: D25004134

fbshipit-source-id: 3039e9d623c026478fe83434baff36c41db17799
2020-11-17 01:28:24 -08:00
Aditya Buridi
769213ea57 Adds schedulerHint tests for DataSource (#136)
Summary:
Pull Request resolved: https://github.com/facebook/Haxl/pull/136

Adds unit test for schedulerHint in DataSource. Currently tests the TryToBatch and SubmitImmediately modes. Tests fail if
. Batch size is not equal to the no of requests in `TryToBatch` mode
. More than one request is submitted in `SubmitImmediately` mode.

Reviewed By: DylanZA

Differential Revision: D24922114

fbshipit-source-id: f786b93e9e0b7c7c731ede5fc54780d9e1b87432
2020-11-16 08:14:20 -08:00
Dylan Yudaken
4ce9cf8751 Make profiling calculations strict within the profiling scope (#135)
Summary:
Pull Request resolved: https://github.com/facebook/Haxl/pull/135

Do not allow lazy evaluation to leak out of the profiling scope. This only makes calculations strict to WHNF, but that is enough to let user code add a `force` if it desires.

Reviewed By: josefs

Differential Revision: D24859691

fbshipit-source-id: 3c0e795abd07574858149298541f0d2418ed1cbf
2020-11-12 07:24:29 -08:00
Dylan Yudaken
290462ff7d fix negative timestamps
Summary: accidentally used t0-t1 which is correct for allocations (as they are negative), but not correct (obviously) for time

Reviewed By: myszon

Differential Revision: D24536509

fbshipit-source-id: a6e79d1f3864682487f037b30152b14275127e22
2020-10-26 05:58:27 -07:00
Dylan Yudaken
3918e2c53b Track local memos in profiling (#134)
Summary:
Pull Request resolved: https://github.com/facebook/Haxl/pull/134

Local memos should be profiled too.
If users do not want this, it would be trivial to add a field to MemoCall to show what type of memo it is, but I do not think it is necesary.

Reviewed By: anubhav94N

Differential Revision: D24189842

fbshipit-source-id: 379c80fe9b670e1c4b04fa22337ca8714903aad3
2020-10-16 11:52:50 -07:00
Ray Shih
0f57820ee5 fix missing import for ghc 8.2 (#132)
Summary:
Pull Request resolved: https://github.com/facebook/Haxl/pull/132

It worked in our build system since we don't test with 8.2, and it failed with 8.2 TravisCI tests in open source repo

Reviewed By: watashi

Differential Revision: D24115332

fbshipit-source-id: accfb5cf1961bebe112538bccb425808dc7cbaa1
2020-10-08 05:26:25 -07:00
Dylan Yudaken
12b7d9a67f Add time to profile (#131)
Summary:
Pull Request resolved: https://github.com/facebook/Haxl/pull/131

To track down bugs where a single label is taking a long time, but is not allocating - it is useful to store wall clock time on labels.
This is obviously only an estimate, due to the lazy nature of Haskell - but it will at least give a clue to where to start looking.

Reviewed By: anubhav94N

Differential Revision: D24083517

fbshipit-source-id: e778c1c9125104c53935bb7ecc2ab0d6134e386c
2020-10-06 04:38:21 -07:00
Ray Shih
19bb3469f1 fix Typeable type don't reconsile problem
Summary:
# what

For unknown reason, without TypeFamilies, GHC 8.8 don't understand `Typeable (r a)` just means `b ~ r a, Typeable b`, and complaints it can be simplified.

Reviewed By: pepeiborra

Differential Revision: D23910571

fbshipit-source-id: d4beb5c5e0dfe5b8715373ebeb1daa3680b6b66c
2020-09-28 02:17:00 -07:00
Ray Shih
88d5d6370e remove unused import
Summary:
# Why

When compile by using GHC 8.8, it complains about unused import

Reviewed By: pepeiborra

Differential Revision: D23910247

fbshipit-source-id: 734f63af851bfbe898a03f9d0738ce2cca594c00
2020-09-28 02:17:00 -07:00
Josef Svenningsson
0be0c0d66c Fix uses of type families
Summary: GHC 8.8 requires TypeFamilies extension to typecheck DataCache.

Reviewed By: pepeiborra

Differential Revision: D23817037

fbshipit-source-id: 7a622b95b57db207b4fc4e7585f85e2f331328ef
2020-09-22 04:16:22 -07:00
Anubhav Bindlish
f091b89b94 Expose unsafeChooseFirst
Reviewed By: watashi

Differential Revision: D23654295

fbshipit-source-id: fe2d023c01d30d58cd678209a40289eaded5aea5
2020-09-11 16:35:25 -07:00
Dylan Yudaken
90cd612eed fix acocunting of label hits (#130)
Summary:
Pull Request resolved: https://github.com/facebook/Haxl/pull/130

Label hits were incorrectly counted when a Blocked computation was hit

Reviewed By: anubhav94N

Differential Revision: D23573141

fbshipit-source-id: 79f4e17fe5fa0002a9e334e401ca1620ce07ff5b
2020-09-11 08:46:04 -07:00
Dylan Yudaken
fe44803c40 supoprt classifying exceptions as ignored for stats (#129)
Summary:
Pull Request resolved: https://github.com/facebook/Haxl/pull/129

Some datasources will throw exceptions but this does not indicate a problem with the datasource itself. This can make the statistics difficult to use to track actual problems versus problems with the way the datasource is used.
Here we allow the datasource to classify some failures to be ignored by the stats collection. They are not simply ignored however - but stored in a new field `fetchIgnoredFailures`

Reviewed By: josefs

Differential Revision: D23475953

fbshipit-source-id: a35ee0fc44ae98db86ae56573f5e7462e0355709
2020-09-10 03:19:22 -07:00
Anubhav Bindlish
c087cbcd0f Add function to choose output of faster computation
Summary:
This diff adds a function `unsafeChooseFirst`, which takes two haxl
comptuations as input, and returns the output from whichever computation
finishes first. The other (unfinished) computation is not evaluated any
further.

Reviewed By: DylanZA

Differential Revision: D23402857

fbshipit-source-id: f5b395a48ae92deab652f7f13366d6e8829c65d9
2020-09-01 12:14:56 -07:00