-
Notifications
You must be signed in to change notification settings - Fork 37
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
Terrible performance with singletonized maps #375
Comments
It's not actually necessary to build any singletons to get sluggish performance either. goo :: Bar :~: 'Just ('(1, "a"))
goo = Refl will take a while too. |
I'm not sure what you mean by "sluggish performance" here. Are you talking about the runtime performance? If so, then I'm not able to reproduce the issue, since the following: {-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
module Main where
import qualified Data.Singletons.Prelude as P
import Data.Singletons.Prelude.Foldable
import Data.Type.Equality
import SingMap
type Foo = FromList (P.Zip ((P.EnumFromTo 1 50)) (P.Replicate 50 "a"))
type Bar = Smallest Foo
goo :: Bar :~: 'Just ('(1, "a"))
goo = Refl
main :: IO ()
main = print goo Runs quite quickly for me (after compiling):
If you're talking about the compile times, then yes, that's likely to be quite slow. Unfortunately, I don't know of a way to mitigate this on |
Compilation (even with |
I agree with Ryan on this. I think it's GHC's problem. It's quite common for GHC to produce quadratically-sized code for type-family heavy shenanigans. And because the code produced is quadratic, that means that every core pass, etc., is quadratic, too. There is a fix: #8095. @bgamari was working on this and may have only a little bit further to go. Keeping open as I do think we should add this to our testsuite. |
Just for fun, I decided to try porting
Data.Map
tosingletons
. I know, that's crazy. Here's the code. It takes a while to compile that, but that doesn't bother me. What does bother me is that generating even a relatively small map takes an incredibly long time.I don't really know where things go sideways, but
-ddump-tc-trace
seems to show some truly enormous coercion signatures even when the list is cut from 50 elements down to 5.The text was updated successfully, but these errors were encountered: