pharo-project / pharo

Pharo is a dynamic reflective pure object-oriented language supporting live programming inspired by Smalltalk.
http://pharo.org
Other
1.19k stars 353 forks source link

ClyConstantMethodQuery>>#scopedMethods is super slow #15327

Open pavel-krivanek opened 10 months ago

pavel-krivanek commented 10 months ago

Describe the problem The method ClyConstantMethodQuery>>#scopedMethods looks like this:

scopedMethods

    | installedMethods scopedMethods |
    installedMethods := self installedMethods.
    scopedMethods := IdentitySet new.

    scope methodsDo: [ :each |
        (installedMethods includes: each) ifTrue: [
            scopedMethods add: each.
            installedMethods remove: each.
            installedMethods ifEmpty: [ ^scopedMethods ] ]].

    ^scopedMethods

In case of image ClySystemEnvironmentScope it means, that for every single method in the image, it checks if it is included in given methods collection - in my case of size 14.

The results are cached so we do not pay this price all the time but it definitelly does not help in the IDE speed.

One more thing... methodsDo: works on all classes and metaclasses in the given scope - but it does not process traits. Does not feel correct to me.

Ducasse commented 10 months ago

Thanks Pavel. With Carolina we are working on a scope browser (Scope being RBEnvironment). I do not really get here an identiy set is called a scope. Would have been better to improve the RBEnvironment instead of hacking one.

Ducasse commented 10 months ago

@carolahp @tesonep just a little pointer (no need to react).