Skip to content
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

fixedparser optimisation (rewrite rules) is a bit fiddly #11

Open
chessai opened this issue Jan 9, 2019 · 5 comments
Open

fixedparser optimisation (rewrite rules) is a bit fiddly #11

chessai opened this issue Jan 9, 2019 · 5 comments

Comments

@chessai
Copy link
Collaborator

chessai commented Jan 9, 2019

look at the following gist: https://gist.github.com/chessai/39dfce8b2a56a05f3c48bd49ac52d066

it contains pairs of .hs files and their core output as a result of \module -> ghc module -O2 -ddump-simpl -dsuppress-all -fforce-recomp

each .hs file contains a parser for the 'Foo' datatype, defined as

data Foo = Foo Word64 Word64 Word64 Word64

in foo.hs, we use full applicative style. the core output is completely optimal.

in fooM.hs, we use monadic style. the core output is optimal for the first two parses, but the second two fail to optimise.

in fooA.hs, we use monadic style, but with -XApplicativeDo enabled. the core output is optimal for the latter three parses, but the first fails to optimise.

@chessai
Copy link
Collaborator Author

chessai commented Jan 9, 2019

actually, the first foo.core (applicative style) output is identical to the core when -XApplicativeDo is enabled. but when i change the fields of Foo to be Word32, the core becomes optimal in all cases.

@chessai
Copy link
Collaborator Author

chessai commented Jan 9, 2019

ah, i was missing an INLINE pragma on fixedBigEndianWord64. this fixed the issue in the previous comment about the core being optimal in all cases (it's not now).

so, to recap where i am now:

foo.hs - optimal
fooM.hs - optimal except in second two parses
fooA.hs - optimal

@chessai
Copy link
Collaborator Author

chessai commented Jan 9, 2019

i'm going to compare across word-types now

@chessai
Copy link
Collaborator Author

chessai commented Jan 9, 2019

for the word32 type, the monadic style (sans applicative-do) performs better than the word64 type

@chessai
Copy link
Collaborator Author

chessai commented Jan 9, 2019

https://gist.github.com/chessai/a1090722d0a16d2f9c23e314a5b53a58 this gist is more immediately comprehensive than me talking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant