-
-
Notifications
You must be signed in to change notification settings - Fork 205
Fix quadratic runtimes in Mathics #619
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
Conversation
|
I am trying to do a rebase of this PR, but there are something that I do not completely understand: in Expression, in the PR, leaves are represented by tuples. This originates some errors in operations that try to modify the leaves of an expression. I do not understand the motivation for using tuples instead of lists. Is about safety in the code? or about performance? @poke1024 could you give me a hand with this? (please see the merge at https://github.com/mmatera/Mathics/tree/qtime) |
Rebase of #619. See that for more detail.
|
#936 should be the same thing rebased on current sources. |
This is continuation of #575 and #615. It's my cleaned up proposal for fixing quadratic runtimes in Mathics.
The following plots show the results of the accompanying two commands, run once using
master(yellowish) and once using this PR (blue). Don't ask me where the spurious regular dots come from (garbage collection?).First[Timing[Fold[#1+#2&, Range[#]]]]& /@ Range[750]The changes are twofold:
Structurewas introduced to enable list operations likeMostorTakenot to trigger an evaluation of every leaf again (this used to be Faster Partition[] #615).The quadratic runtimes are only fixed when both measures are applied, which is why I merged everything into this PR now.
All the information regarding cached
Expressioninformation (including what isExpression._sequencesinmaster) is now bundled inExpressionCache, which makes the code much cleaner I think.I experimented with quite a variety of data structures, including
dicts instead ofsets for the symbol caching, but asetand asequenceslist seems to be the best thing to do.