-
-
Notifications
You must be signed in to change notification settings - Fork 205
Roughly constant time expression timestamp checks #575
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'm wondering, if the expression changes will the list of cached symbols be invalid? e.g. I'm imagining the sequence of tree transformations |
|
After reading your comment, I looked into the implications of this change again, and I need to say I underestimated the side effects some current code might have. I had assumed that usually all new So, to fix this (and also to some cases of #577 that I didn't see before due to a lack of proper analysis), I suggest we make With the latest commits, I introduced the following changes:
All these changes enforce and check stuff at runtime. So, trying to set some Even though there is a certain overhead with the new property based encapsulation of bench_before.txt EDIT This also gives us the necessary foothold to implement packed arrays later on (#561). |
|
The benefit of this PR can be seen when doing a basic With this PR: Without this PR: With this PR, Mathics is linear: Without this PR, Mathics is quadratic: |
|
continued in #619 |


Currently,
Definitions.last_changeddoes a full tree traversal each time the expression timestamp is checked. This is bad if the expression is huge and deep, as caching speed is dependent on the expression size.This PR introduces a set of symbols that can be efficiently checked without the need for a full tree traversal; usually the number of symbols even in a big nested list is small and thus can be regarded a small constant.
The main target for this PR is faster operations with big lists, e.g. using
list = Nest[Partition[#, 2]&, Range[2 ^ 14], 14]:without this PR:
In[2]:= Timing[Length[list]] Out[2]= {0.334763, 1}with this PR:
In[2]:= Timing[Length[list]] Out[2]= {0.209859, 1}The remaining runtime stems not from
Definitions.last_changedbut from other effects that are targeted in a separate PR.Apart from this targeted effect, this PR seems to improve the overall benchmarks (see attached files).
opt5-before.txt
opt5-after.txt