Application class>>#isBasedOn: performance improvement

VA Smalltalk is a "100% VisualAge compatible" IDE that includes the original VisualAge technology and the popular VA Assist and WidgetKit add-ons.

Moderators: Eric Clayberg, wembley, tc, Diane Engles, solveig

Application class>>#isBasedOn: performance improvement

Postby g.cotelli » Mon Dec 20, 2010 4:51 am

Hi,

I found that moving classes between applications can be slow when there is a lot of applications and a long dependency chain. I tracked it down to Application>>isBasedOn: that performs always a recursive send.

I have changed:

Code: Select all
isBasedOn: application
      "Return whether application is a prerequisite of the receiver."

   self prerequisites do: [:prereq |
      prereq == application ifTrue: [^true].
      (prereq isBasedOn: application) ifTrue: [^true]].
   ^false


with:

Code: Select all
isBasedOn: application

   ^self isBasedOn: application alreadySeen: IdentitySet new


and:
Code: Select all
isBasedOn: application alreadySeen: anApplicationSet

   (anApplicationSet includes: self)
      ifTrue: [^false]
      ifFalse: [
         "Return whether application is a prerequisite of the receiver."
         self prerequisites do: [:prereq |
            prereq == application ifTrue: [^true].
            (prereq isBasedOn: application alreadySeen: anApplicationSet) ifTrue: [^true].
            anApplicationSet add: prereq].
         ^false]


Would be goog if this change can be included in the base image. Please review it before.

Regards,
Gabriel
g.cotelli
 
Posts: 13
Joined: Wed Feb 24, 2010 9:30 am

Re: Application>>isBasedOn: performance improvement

Postby wembley » Mon Dec 20, 2010 9:02 am

Case 47978 created and fixed. Here is a testcase:

Code: Select all
  | allApplications prereqCount |

  allApplications := Application allSubclasses.
  prereqCount := 0.

  [allApplications do: [ :anApp |
    allApplications do: [ :prereqApp |
      anApp prerequisites ifNotNil: [  "Handle bogus AbtHtmlMigrationAgent"
        (anApp isBasedOn: prereqApp)
          ifTrue: [ prereqCount := prereqCount +1] ] ] ] ]bench: '#isBasedOn: '.
  Transcript cr; show: 'prereqCount: '; show: prereqCount printString

In a fully loaded VA Smalltalk image running on my WinXP Test VMware, the before output is:

#isBasedOn: 13313
prereqCount: 15266

and the after output is:

#isBasedOn: 5532
prereqCount: 15266
John O'Keefe [|], Principal Smalltalk Architect, Instantiations Inc.
wembley
Moderator
 
Posts: 405
Joined: Mon Oct 16, 2006 3:01 am
Location: Durham, NC


Return to VA Smalltalk 7.0, 7.5 & 8.0

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron