-
Notifications
You must be signed in to change notification settings - Fork 641
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
List construction works very slow in REPL if I don't explicitly define its type as the (List Int)
#4290
Comments
Possibly related to #3976 (unfortunately closed AFAICS) and #3516. I see you found the REPL code! It looks to me that the evaluation of the term happens happens where When we spoke on the Idris Slack channel, I'm pretty sure I was misguided to suggest that it might be a problem of not having the Hopefully one of the other @idris-lang/contributors will be able to give you more guidance about how the evaluator works and why it might be slow in this case. Otherwise, dig into |
I recalled that Agda has a mechanism to optimise datatypes that are like data ℕ : Set where
zero : ℕ
suc : (n : ℕ) → ℕ
{-# BUILTIN NATURAL ℕ #-} See
Integers have a similar "builtin" mechanism in Agda. I'm not sure if Idris has a similar mechanism. If not, perhaps that's what's required to resolve these performance issues? |
The compiler special-cases AFAIK, the Agda builtin mainly means that you can write Either way, if you want big numbers at runtime, you likely need Perhaps one day we'll have a more principled optimisation that will allow using big |
Hi @ziman, thanks for stopping by!
That's sad. We should use a similar optimisation for REPL evaluation.
No, the use of NATURAL in Agda has 4 effects:
See http://agda.readthedocs.io/en/v2.5.3/language/built-ins.html#natural-numbers So, for Idris, we'd want to add (2) as (1) and (3) seem already taken care of. Not sure about (4), it looks like a complication 😄.
I'm not entirely following but I think we want Haskell
@sergey-kintsel seems keen to solve this. I'm happy to help. Rather than "one day", with a little direction, we could hope for "one day next week" 😉! Could you point to the optimisation that the compiler does to replace uses of |
Ah, thank you for the clarification wrt. Agda.
In my personal opinion (which may be a bit radical), sometimes Either way, the translation currently happens in We've been talking about generalising this for a very long time but I can't find anything written up online. You could extend this idea of big ints to I have some notes and even syntax ideas but they are far from anything complete. For example, changing the representation changes the complexity of operations (e.g. |
Another cool optimization would be to substitute |
I was looking DataOpts.hs though and found this: (Var n, args) <- raw_unapply t -- MAGIC HERE that's an amazing code comment 😂 |
looks like I am not the person to solve this. I have no idea how it works internally tbh 😅 |
Idris version: 1.2.0
OSs: macOS & Ubuntu
Steps to Reproduce
Open REPL
type
[1..1000]
and hit Enter.It takes very long and consumes 100% of 1 CPU core
Expected Behavior
It should be as fast as a bullet
Important notes:
the (List Nat/Integer) [1..1000]
it works slowthe (List Int) [1..1000]
in REPL, it works not so slow (I am able to wait for results)it works fast.
I tried to investigate the problem myself, but I got only to this point: https://github.com/idris-lang/Idris-dev/blob/master/src/Idris/REPL.hs#L859.
The text was updated successfully, but these errors were encountered: