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
Optimize Psi2() #21388
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Changed branch from u/embray/psi2 to u/jdemeyer/psi2 |
comment:5
In fact, we don't need the variable Hang on... New commits:
|
comment:6
Is the idea that you would just take the multiplication by |
Branch pushed to git repo; I updated commit sha1. New commits:
|
This comment has been minimized.
This comment has been minimized.
Changed author from Erik Bray to Erik Bray, Jeroen Demeyer |
comment:9
This also happens to speed up the function by a factor of 10. Please review... |
comment:10
Some of this makes sense to me (I was already irked by the use of That said it's no surprise to me that more could be done with this than what I did. |
comment:11
Replying to @embray:
|
comment:12
Thanks, that all makes sense. In particular I didn't realize what lift() did. |
comment:14
Reviewer name.. |
Reviewer: Jeroen Demeyer, Erik Bray |
Changed branch from u/jdemeyer/psi2 to |
We greatly optimize the
Psi2()
function.Before:
After:
(note the use of
Psi2.f()
to bypass caching)This also provides a workaround to a test that caused the Python interpreter to segfault on Windows. The specific call that caused the segfault is:
Psi2(71)
But in brief, the crash occurs because we have (in the original code) a large element of
Univariate Quotient Polynomial Ring in v over Multivariate Polynomial Ring in x, u over Rational Field with modulus v^2 - u^4 + 10*u^3 + 3*u^2 - 4*u + 8
. This is then being cast simply to a multivariate rational polynomial over x, u, v. Because there is no direct coercion between these types this involveseval()
-ing the polynomial as a Python expression.The problem is that this expression can become too large for the stack--specifically in Python's symbol visibility analysis, a step it performs just before compiling an expression to bytecode. The implementation of that recurses into binary expressions, leading to a stack overflow for such a large expression. This issue has come up once before in #16014 where it was worked around by a rewrite of the code. This particular test worked on Linux where the default stack size is 8MB, but it crashed on Windows where the typical stack is just 1MB.
The optimization gives smaller expressions to eval.
A more general fix to this problem would be nice though--I'm writing up some thoughts I have on it in a separate post.
Component: elliptic curves
Author: Erik Bray, Jeroen Demeyer
Branch/Commit:
bdce5dc
Reviewer: Jeroen Demeyer, Erik Bray
Issue created by migration from https://trac.sagemath.org/ticket/21388
The text was updated successfully, but these errors were encountered: