-
Notifications
You must be signed in to change notification settings - Fork 642
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
Let clauses make execution about 300 times slower #2837
Comments
It's probably the fact that let-bound values are excluded from erasure, and thus always evaluated. I'm afraid you're stuck with |
Thanks Matúš, I was not aware of the fact that let-bound values are excluded from In implementing rational numbers, I have in fact moved away from the If this is not a temporary state of affairs, it would be perhaps useful Best, Matúš Tejiščák notifications@github.com wrote:
|
The blame is really on me because it's just feature-incompleteness of erasure analysis. There's no fundamental reason that let-bindings should be excluded from erasure, except for the fact that there has to be a point where you have to stop adding features and actually ship it. By the way, it is not that let-bindings are completely excluded from erasure. In I am not sure what exactly you mean about the warning but if something does not undergo erasure analysis, you can't tell whether it is potentially erasable. Anyway, this ought to work and I definitely don't want to discourage users from using parts of the language for no reason other than incomplete support. In (longer-term) future, let-bound values will undergo erasure, too. |
Matúš Tejiščák notifications@github.com wrote:
Well a factor of about 300 (we can provide examples for which this This is particularly true in libraries which implements numerical types. I have spent a few months (ok, say a few smartman-days or weeks) Maybe you can have a look at lines 266-374 of and then tell me if you think it makes any sense to stick to 'let' |
As it turns out, it is possible to recover the expected run-time behavior by just reimplementing
With
From my perspective the issue is closed. I have learned a useful lesson and, for the time being, I will stay away from I believe that the potential drawbacks of using 'let' clauses should be documented and that developers should be made aware of the essential differences between Thanks to Matus who essentially contributed to solve my problem! I leave it to him or to those who better know, to decide whether to close the issue or to keep it open. If you are interested in using non-negative rational numbers in Idris, please get in touch. |
Sorry, it seems I misunderstood from the title. In any case the problem was solved and so it needs to close. |
This problem is still not solved. The two bugs you linked are related to typechecking. However, the problem in this issue is that runtime is slower. With |
@ziman Yeah, I already apologized for that :). |
I will reopen the issue, as I think I thought you provided an answer, but it was only a workaround. |
The program
executes in about 0.5 seconds. But it takes about 150 seconds for
to execute. Similarly,
runs in about 150 seconds. Here,
normalize
is implemented in terms oflet
expressions as in the second example. Thus, it appears that the execution speed worsens by a factor of about 300 if the same computation is expressed in terms oflet
clauses. The three programs can be downloaded fromhttps://github.com/nicolabotta/SeqDecProbs/tree/master/frameworks/14-
as
NatGCDAlgorithmTest.1.lidr
,NatGCDAlgorithmTest.2.lidr
andFractionTest.lidr
, respectively. The functionnormalize
is implemented inFractionOperations.lidr
. What is going on here?The text was updated successfully, but these errors were encountered: