Is this 30% slowdown in Mathematica 10 due to DownValues lookup time?

I realize this answer comes about three years too late, but having come accross the question, here's an answer.

The general slowdown that was fixed in 10.1, and that hit Linux particularly hard, was due to a change a compilation settings to enable the kernel to be loaded as a library and not just run as a program. This had implications for function calls across different compilation units that wasn't fully understood, and the 10.0 version had significant overhead as a result. This was fixed by additional tweaks so that functions between different compilation units could be called with minimal overhead.

I'm not aware of any other big slowdown in 10.0, or indeed in any release since (obviously certain specific functions had bugs that caused them to be slow). As always, performance can vary as we updated external libariries, compilers, etc. If you have a reproducible slowdown, your best recourse is to contact support with your example so we can evaluate it.

Update: additional symbols causing slowdown?

Since I was asked to comment on the addition of symbols as a possible slowdown, the short answer is that it is theoretically possible, but it is unlikely to be the cause of any general slowdown in the product.

Adding DownValues to a symbol can't slowdown the evaluation of other symbols. It will only affect the evaluation of that symbol.

Adding UpValues is a potential source of slowdown, since anywhere the symbol to which the UpValue is attached you need to determine if the UpValue fires. However, there are a number of optimizations in place to ensure that cost of the scan is negligible, and the UpValue pattern only needs to be tested if both symbols are present.

Having a huge number of symbols (say, hundreds of thousands) spread across of a large number (say, tens of thousands) of contexts can cause a measurable slowdown in symbol lookup. However, we're not close to that. Even in 11.3, I see 546 contexts at startup, growing to a little over 1000 as I use different functions. For comparison, V9 had 361 contexts at startup. It's definitely grown, but not by a scale that's worrisome.

What is true is that as we have more symbols spread across more packages, then there are potentially slow initial evaluations as the packages get loaded. But that would be a one-time cost per package.


This specific slowdown is solved in Mathematica 10.1. Probably it was not just DownValues but something else. Anyway. Other slowdown's are still there, unfortunately, but they are harder to pin down. So at least this artificial example is solved.