Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While running discourse benchmark under linux perf, I noticed one of the most frequent operations that ruby does is the method lookup.
That was kind of known, but something didn't smell right. I pushed 3ffd98c and ran the benchmark again, to get this output:
So 65,039,079 out of 94,613,117 inline cache mishits are spurious; they resulted in method lookups that end up exactly the same method entry the cache already stored. This is not a buggy behaviour and your program works as expected (apart from unnecessarily consuming our precious environmental resources to generate electricity for the computation). However there definitely is a room of improvements.
Let's use the cache more efficiently. We are facing the fact that several classes share the identical method entry for a method name; possibly due to inheritance, inclusions, and so on. We can use this. A call cache is valid for multiple classes. So in order to express the info, this changeset expands
struct rb_call_cache
from 44-ish bytes to cache line width. The space we add is used for second and later class serials.By this changeset the debug counter output for the same benchmark is now like this:
The
mc_miss_spurious
counter dropped down to 23,344,738.