-
Notifications
You must be signed in to change notification settings - Fork 21
Replace dunai by automata/state machines #299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Mar 26, 2024
Merged
0f5a463
to
1b8e153
Compare
turion
commented
Mar 29, 2024
turion
commented
Mar 29, 2024
turion
commented
Mar 29, 2024
turion
commented
Mar 29, 2024
turion
commented
Mar 29, 2024
turion
commented
Mar 29, 2024
turion
commented
Mar 29, 2024
turion
commented
Mar 29, 2024
turion
commented
Mar 30, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Check whether all primitives in automata are inline
- Fix copyrights, make clear that API is inspired heavily by dunai
fe28b13
to
7195216
Compare
14986af
to
f8f7205
Compare
turion
commented
Apr 18, 2024
09b273e
to
8e7b836
Compare
64f9a8b
to
46240bd
Compare
30a3b78
to
a7cfe80
Compare
99df94d
to
9757ea2
Compare
CC @ners I'm pretty close to merging now :) one leftover FIXME and a final review from my side. In case you want to review, feel free! |
4951fa0
to
4ef6c57
Compare
f2c35e4
to
6ea30bf
Compare
Closed
turion
commented
May 13, 2024
This was referenced Jun 4, 2024
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Unfortunately there are two reasons that force me to drop the dependency on dunai, and replace it by an implementation of effectful Mealy state machines.
dunai
is incompatible with transformers 0.6, mtl 2.3, GHC 9.6: Allow GHC 9.6 #215,dunai
: Does not build withtransformers-0.6
because ofListT
ivanperez-keera/dunai#402dunai
: Space leak in rhine-bayes example program? #227dunai
:morphGS
is probably inefficient ivanperez-keera/dunai#370Work done
This PR replaces dunai by a effectful Mealy state machines, in the initial encoding. The implementation is heavily inspired by https://github.com/lexi-lambda/incremental/blob/master/src/Incremental/Fast.hs and https://github.com/turion/essence-of-live-coding. It solves the two problems:
ListT
.Benchmark
The benchmark is a simple word count implementation which counts the words of Shakespeare's complete works. Its purpose is to show how much overhead
dunai
andrhine
introduce. It includes:text
IORef
sIORef
sFor a non-Haskell baseline, the standard
wc
completes the benchmark in 30 ms on my reference machine.Result with state automata
wc
with around 90 ms. There are faster word count implementations thanwc
in Haskell, but this benchmark is about the overhead introduced by the frameworks, so I wrote a baseline implementation that is the fastest conceivable program which I can imagine a Rhine program being optimized to.IORef
introduces factors of 1.2-1.5.dunai
is far behind with a 10x slowdown.Comparison: No automata
I will introduce the benchmark before this PR (#285). With Rhine depending on dunai, it is vastly slower: In the direction of 100x against wc, and still over 2x over dunai, which means that clock erasure does not optimize well. The abstractions introduced in dunai-dependent Rhine are far from zero-cost.
Open questions, to dos
machines
) I'm aware of use the final encoding which doesn't optimize well.rhine
repository until this PR is merged, and pull it out later.MSF
has all the same type class instances that dunaiMSF
hasResamplingBuffer
s should also have initial encoding, this should speed up largerSN
s.stack.yaml
can be simplified because of removed reverse dependencies & version bounds. Answer: No they cannot, I'm still using dunai in the benchmarks.automaton
against e.g.streaming
,machines
etc. Benchmarks for automaton #311