Nanomath very slow #43
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The recent benchmarking PR shows that nanomath performance is far worse than both pocomath and mathjs 15. After a bit of poking around, the leading suspect is ArrayKeyedMap, which is used in nanomath centrally in the TypeDispatcher, but not in pocomath or mathjs. Let's see what happens if we switch to some other indexing scheme.
OK, well, getting rid of the ArrayKeyedMap did not help. It seems to be the typing a value is now very slow; benchmarking a bunch of typings in nanomath is 25.6 milliseconds vs. in pocomath it is 0.01 milliseconds. Perhaps the issue is the fact that Types are proxied objects for the sake of the function-call syntax?
Hmm, removing the proxy and the derivation from built-in Function improved things, but only by a factor of two: the typing benchmark still takes 12 milliseconds. Trying to figure out what else it could be.
Just whittled away on typing until it got within a factor of two of pocomath, then switched to cbrt and polynomialRoot, where there were two problems:
With these things fixed up, brought nanomath to somewhere between one-third the speed and just slightly slower than pocomath, depending on the particular benchmark and the relative weight in it of resolution (which nanomath is still slow at) and computation (where nanomath is essentially just as fast).