On 12 May 2022, at 11:27, Andrei Chis <chisvasileandrei@gmail.com> wrote:
Hi,
We were profiling the loading of code that uses many Traits. We saw something like this (this is a tally for `TraitedMetaclass>>#addAndClassifySelector:withMethod:inProtocol:`): <Screenshot 2022-05-11 at 17.17.37.png>
From what we saw in `TraitedMetaclass>>#addAndClassifySelector:withMethod:inProtocol:` a method is first added to `localMethodDict` and then it calls the super method that adds the selector to the `methodDict` of the actual class in `Behaviour>>addSelectorSilently:withMethod: `. Because of this we basically get an overhead as a method is added to two method dictionaries and adding a method to a MethodDictionary is slower, as it does operations like `flushCache` and `cachePragmas`.
Should the `localMethodDict` also be an instance of MethodDictionary or could it be a simple dictionary?
I think it can be normal Dictionary: MethodDictionary we just meed where there VM executes code (for flushCache) and for lookup. The only downside is that it then uses a little bit more memory (MethodDictionary does not use associations), but that should be no problem. Marcus