Skip to content

reorganize Definitions.get_definition - #59

Closed
mmatera wants to merge 323 commits into
masterfrom
definition3
Closed

mmatera wants to merge 323 commits into
masterfrom
definition3

Conversation

@mmatera

@mmatera mmatera commented Nov 8, 2021

Copy link
Copy Markdown
Contributor

In this PR, I have introduced some changes in the Definitions and Definition object to speed up the call to the Definitions.get_definition() and avoid it always that is possible. Most of the time, the definition that we are looking for during the evaluation is in the Definitions.definition_cache dictionary, so we can avoid calling the method (150ns).
This is done in master tens of millions of times, so these 150ns becomes into seconds.

After running the docpipeline in main, all the 12,137,995 of calls to get_definition results in:

cache found: 11953654 (98%)
found: 93313 (0.76%)
key invalid: 43498 (.35%)
not found: 32067 (.26%)
clash: 15463 (0.12%)

where cache found are definitions already in the cache, found are definitions with just one definition (either a builtin definition, or a user definition) key invalid are calls with invalid "name"s (like context names, or empty names)
not found are calls with valid names that were not defined before and clash definitions that require merging a built-in definition with a user definition.

After doing the same in this branch, we have 324155 calls (a 2% regarding the total calls in master) distributed as

not found: 122875 (38%)
cache found: 93142 (28%)
found: 84259 (26%)
key invalid: 13400 (4%)
clash: 10479 (3.2%)

TiagoCavalcante and others added 30 commits August 14, 2021 16:10
Other small changes to wording.
Mark modules that don't get documented.
Add timing decorator that can be used in profiling
* Put builtins in alphabetic order
* Add summary text for some built ins
* No hard line breaks on doc text
* Move non-showing test code in Rationalize out to a pytest
Mostly cosmetic revision of numeric.py
Rationalize result that are an integer stay int
All of this will be important in fixing ReadList
mmatera and others added 27 commits November 19, 2021 20:05
* * unroll any/all calls as loops in Cythonized modules: this avoids the overhead of a function call replacing it by a (C) for loop
* `BaseExpression.get_head`  now avoids to build a symbol and then look for its name. It saves two function calls.
* Now, `SameQ` first checks type, then `id`s and then names in symbols.
* In `mathics.builtin.patterns.PatternTest`, if the condition is one of the most used tests (`NumberQ`, `NumericQ`, `StringQ`, etc) the `match` method is overwritten to specialized versions that avoid function calls.
* in the same aim, `mathics.core.patterns.AtomPattern` now specializes in the comparison depending on the `Atom` type.
Also, we should be thinking about how do things like this in a more
general way.
* Full form of lists should be formated with {...}

* fix tests
* fix Series test

* CHANGES
faster access to Context and ContextPath
@mmatera mmatera closed this Feb 1, 2022
@rocky
rocky deleted the definition3 branch May 28, 2022 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants