You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Pharo, marking methods as deprecated using self deprecated: aMessage significantly slows down method execution.
Let's look some quick benchmarks.
First Fibonacci. The implementation is exactly the same (recursive implementation) the only difference is that the second one adds the self deprecated: 'deprecated' message.
[AClassnewfib:8] bench. "28,388,133 iterations in 5 seconds 3 milliseconds. 5674222.067 per second".
[AClassnewfib:8] bench "18,406 iterations in 5 seconds 2 milliseconds. 3679.728 per second".
5674222.067/3679.728 . "1542.02 times slower"
As we can see from this quick bench, the implementation with self deprecated: is about 1542 (!!) times slower.
Now let's look at a non-recursive method. It's the default factorial implementation from Pharo and as before I just added the self deprecated: 'deprecated'. In this case it's 455 times slower.
[ 8 factorial ] bench "262,071,039 iterations in 5 seconds 3 milliseconds. 52382778.133 per second".
[ 8 factorial ] bench "575,428 iterations in 5 seconds 1 millisecond. 115062.587 per second".
52382778.133/115062.587"455.25 times slower"
Why?
The slowdown occurs due to the following reasons in the deprecated: method:
deprecated: anExplanationString
"Warn that the sending method has been deprecated."Deprecationnewcontext: thisContext sender;
explanation: anExplanationString;
signal
Context Reification:
Each call to the deprecated method creates a new context with thisContext sender
The method raises an exception to check if it needs to transform. If the transformation is not needed, it triggers the default action, which adds further overhead.
The default action checks system settings to determine if a warning should be raised. If deprecations are turned off (which many users do), this processing still occurs without any benefit, leading to wasted resources.
TLDR
So, in summary, if the user turned off the deprecations from the system settings (like most of the people do), all of this work is done for free. There is the hidden exception raised and the context reification that will pass completely unnoticed; killing performance.
The text was updated successfully, but these errors were encountered:
In Pharo, marking methods as deprecated using
self deprecated: aMessage
significantly slows down method execution.Let's look some quick benchmarks.
First Fibonacci. The implementation is exactly the same (recursive implementation) the only difference is that the second one adds the
self deprecated: 'deprecated'
message.As we can see from this quick bench, the implementation with
self deprecated:
is about 1542 (!!) times slower.Now let's look at a non-recursive method. It's the default factorial implementation from Pharo and as before I just added the
self deprecated: 'deprecated'
. In this case it's 455 times slower.Why?
The slowdown occurs due to the following reasons in the deprecated: method:
Context Reification:
Each call to the deprecated method creates a new context with
thisContext sender
Exception Handling:
The method raises an exception to check if it needs to transform. If the transformation is not needed, it triggers the default action, which adds further overhead.
The default action checks system settings to determine if a warning should be raised. If deprecations are turned off (which many users do), this processing still occurs without any benefit, leading to wasted resources.
TLDR
So, in summary, if the user turned off the deprecations from the system settings (like most of the people do), all of this work is done for free. There is the hidden exception raised and the context reification that will pass completely unnoticed; killing performance.
The text was updated successfully, but these errors were encountered: