-
Notifications
You must be signed in to change notification settings - Fork 481
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
Investigate suboptimal code generated by AsData #6770
Comments
@ana-pantilie this is the performance issue I talked to you about earlier. |
@ana-pantilie I looked a bit into this, and wrote a more efficient pattern synonym by hand: see To answer the two questions above:
That said, the hand written pattern synonym is more efficient than the TH generate one, and we should modify the TH to generate the more efficient version. |
I opened a GHC issue regarding 1: https://gitlab.haskell.org/ghc/ghc/-/issues/25666 |
There's actually a much simpler solution: use |
@zliu41 I can confirm that pattern matching using a |
I found two issues when looking at the generated code in
patternMatching.pir.golden
x
,y
,z
,w
are all non-strict bindings. This causes their bodies to be evaluated every time they are referenced, which is whypatternMatching
is slower thanrecordFields
. If CSE is turned on, thenpatternMatching
does become much cheaper, becauseforce x
,force y
etc. are considered common subexpressions and are factored out. However, it is not great to have to rely on CSE, which is unreliable. Can we generate more strict code fromAsData
?Tuple4
also has some overhead. Is it possible to generate code that doesn't use tuples? Ideally it should look like this:The text was updated successfully, but these errors were encountered: