Skip to content
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

Basic calculator list slowness #1568

Open
rocky opened this issue Aug 29, 2021 · 1 comment
Open

Basic calculator list slowness #1568

rocky opened this issue Aug 29, 2021 · 1 comment

Comments

@rocky
Copy link
Member

rocky commented Aug 29, 2021

Wny are we so slow on:

  • a + b + 4.5 + a
  • a * b * 4.5 * a
  • a / b / 4.5
  • a ^ b ^ 4.5 ^ a

?

python ./mathics_benchmark/bench.py  -v ./benchmarks/calculator-fns.yaml
Mathics git repo /src/external-vcs/github/Mathics3/mathics-benchmark/Mathics at 58dc69
500 iterations of Plus...
  0.104490 secs for: 1 + 2                                   
  0.113165 secs for: 1 + 2 + 3                               
  0.258577 secs for: 1 + 2 + b                               
  0.176744 secs for: a + b + 3                               
  0.102528 secs for: 1234567890 + 2345678901                 
  17.513644 secs for: a + b + 4.5 + a                         

500 iterations of Times...
  0.104240 secs for: 1 * 2                                   
  0.114249 secs for: 1 * 2 * 3                               
  0.255315 secs for: 1 * 2 * b                               
  0.168563 secs for: a * b * 3                               
  0.104529 secs for: 1234567890 * 2345678901                 
  17.170605 secs for: a * b * 4.5 * a                         

500 iterations of Divide...
  0.270426 secs for: 1 / 2                                   
  0.440225 secs for: 1 / 2 / 3                               
  0.861948 secs for: 1 / 2 / b                               
  0.583282 secs for: a / b / 3                               
  0.277900 secs for: 1234567890 / 2345678901                 
  11.588511 secs for: a / b / 4.5                             

500 iterations of Power...
  0.115591 secs for: 1 ^ 2                                   
  0.232032 secs for: 1 ^ 2 ^ 3                               
  0.329244 secs for: 1 ^ 2 ^ b                               
  0.613662 secs for: a ^ b ^ 3                               
  0.145898 secs for: 12345 ^ 23456                           
  8.794525 secs for: a ^ b ^ 4.5 ^ a                         

500 iterations of Sqrt...
  0.536396 secs for: Sqrt[2]                                 
  0.586085 secs for: Sqrt[Sqrt[2], 3]                        
  0.587919 secs for: Sqrt[Sqrt[2], b]                        
  0.633341 secs for: Sqrt[Sqrt[Sqrt[2], b], 3]               
  0.939225 secs for: Sqrt[1234567890]         
@rocky
Copy link
Member Author

rocky commented Aug 30, 2021

Looks like the root cause again is the slowness in pattern matching, method look ups.

Download the zip file and unzip it.
adds.zip

Give the .prof file as an argument to snakeviz, e.g. snakeviz cslow-add.prof. The corresponding Python file e.g. cslow-add.py will recreate the corresponding .prof file.

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

No branches or pull requests

1 participant