-
Notifications
You must be signed in to change notification settings - Fork 30
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
Performance issues #3
Comments
Storing a vector of Term would store duplicated instances of the |
I think that the fact that iterating over a polynomials gives it terms is rather user friendly it might be ok if it is the the most efficient way to iterate over the term if this spares the copying of the |
I have replaced the |
Great! I may look into this more in the future, but for now I'll close the issue. |
What is the performance now ? I get the following for
and the following for this package
The performance difference seems to be due to the comparison
I find it rather dangerous to pass values for the variables without providing the variable order that is meant like Indeed comparison between int is much faster than between symbols:
The
|
One cause of the performace issue is the inefficiency of
which is slower than doing
|
More details, on Julia v0.5, if I define:
Then for bitstype, I get:
And for non-bitstype I get
We see that there is some GC time because of the |
I've started looking into what it will take to make MultivariatePolynomials fast as a general-purpose polynomial tool. Specifically, I'm trying to focus on variable substitution for now. Currently, it's pretty slow:
calling
p(vals, vars)
takes around 3 microseconds.I've gotten that down to about 270 nanoseconds in #2, but doing any better will require some internal changes (by comparison, MultiPoly takes about 70 nanoseconds on the same test).
I think the fundamental problem is that we evaluate polynomials by iterating over the
Term
s in the polynomial. But that iteration requires constructing a newTerm
type for each element, which in turn has to allocate newVector
s of monomials and powers. That gets expensive and slow. Ideally, we should be able to evaluate a polynomial with zero allocations at all.One way we could possibly achieve this is by changing the polynomial types to just store a vector of
Term
s, rather than constructing a newTerm
when we iterate. Is there a reason that wasn't done already? Does it make some other part of the code more difficult?The text was updated successfully, but these errors were encountered: