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

Improve performance with inlining trick? #74

Open
mikeplus64 opened this issue Aug 23, 2018 · 3 comments
Open

Improve performance with inlining trick? #74

mikeplus64 opened this issue Aug 23, 2018 · 3 comments

Comments

@mikeplus64
Copy link

*traverse*, *cata*, *pure*, etc. can all potentially be implemented using recursive class instances like

class Thing xs where thing :: thing xs
instance Thing '[] where {-# INLINE thing #-} thing = _
instance Thing (x ': xs) where {-# INLINE thing #-} thing = _

which would allow them to be zero overhead, and, hopefully, for GHC to be able to eliminate generics-sop overheads entirely. I'm not sure whether sList has the effect of tricking GHC into doing this already but that does seem possible.

Cons: yet longer compile times, yet more dictionaries to pass around.

@mikeplus64
Copy link
Author

TBD minimal amount of Thingy classes necessary to actually do this :-)

@kosmikus
Copy link
Member

I know.

This is implemented in https://github.com/well-typed/generics-sop/tree/wip/static-case-opt

Unfortunately, in my tests so far, this often increases compilation time and only very unreliably improves performance, as it is difficult to get GHC's inliner to be sufficiently aggressive without any negative side effects. So while this branch exists for several years, I haven't ever merged it.

More recently, I've also experimented with stream fusion in https://github.com/well-typed/generics-sop/tree/wip/stream-fusion This is not yet quite done, so I cannot tell yet whether it might work.

@ghost
Copy link

ghost commented Dec 20, 2021

I've just opened #148, which might provide the solution to the compilation times problems.

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

2 participants