Summary: The Result type admits a Functor instance and I've found it useful.
Reviewed By: simonmar
Differential Revision: D41469853
fbshipit-source-id: 619941cf58e679dd2f7a483362d2c108e0aec452
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Summary: Add `Ord` to `SimpleWrite` and `assertEqualIgnoreOrder` that sorts lists before comparison
Reviewed By: ahaym
Differential Revision: D26985618
fbshipit-source-id: 2c5f34775815a2d1af4a304fd0ce2719dc9417a6
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
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
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
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
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
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
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
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
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
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
Summary:
# Why
When compile by using GHC 8.8, it complains about unused import
Reviewed By: pepeiborra
Differential Revision: D23910247
fbshipit-source-id: 734f63af851bfbe898a03f9d0738ce2cca594c00
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
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
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