dialogs: performance cleanup - perform (expensive) list computation always in background.
authorJan Vrany <jan.vrany@fit.cvut.cz>
Sat, 21 Feb 2015 22:54:44 +0000
changeset 423 60c930c93819
parent 422 cb37723958a4
child 442 bf0dac771a2e
child 444 a47f43af21d6
dialogs: performance cleanup - perform (expensive) list computation always in background. Whne one tries to call (expensive) #upateMatching or #updateMatchingIgnorePattern out of worker thread, raise an assertion error. Avoid calling that method twice during startup. In effect, dialogs come up much faster.
SmallSense__AbstractListDialog.st
SmallSense__AbstractSearchDialog.st
SmallSense__Navigator.st
abbrev.stc
extensions.st
smallsense.rc
stx_goodies_smallsense.st
--- a/SmallSense__AbstractListDialog.st	Sat Feb 21 08:46:46 2015 +0000
+++ b/SmallSense__AbstractListDialog.st	Sat Feb 21 22:54:44 2015 +0000
@@ -506,26 +506,10 @@
 
 !AbstractListDialog methodsFor:'change & update'!
 
-delayedUpdateMatchingObjectPOs: matchingPOsArg
-    | rootPO matchPatternString  |
+enqueueDelayedUpdateMatchingObjectPOs: matchingPOsArg
+    self enqueueMessage: #delayedUpdateMatchingObjectPOs: for: self arguments: (Array with: matchingPOsArg)
 
-    rootPO := self matchingObjectsTree root.
-    rootPO
-        children:matchingPOsArg;
-        expand.
-    matchPatternString := self matchPatternHolder value.
-    matchPatternString isEmptyOrNil ifTrue:[ 
-        ^ self.
-    ].
-    matchingPOsArg size == 1 ifTrue:[
-        matchingObjectsMultiselect ifTrue:[
-            self matchingObjectsSelection: matchingPOsArg
-        ] ifFalse:[
-            self matchingObjectsSelection: matchingPOsArg anElement
-        ]
-    ].
-
-    "Created: / 12-12-2014 / 23:32:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Created: / 21-02-2015 / 08:57:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 update:something with:aParameter from:changedObject
@@ -629,29 +613,6 @@
     "Modified: / 25-11-2014 / 13:23:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-updateMatching
-    | pattern pos |
-
-    self matchPatternHolder value notEmptyOrNil ifTrue:[
-        pattern := StringPattern fromString: self matchPatternHolder value.
-        pos := self matchingObjectPOsForPattern: pattern.
-        self updateMatchingObjectPOs: pos.
-        self updateMatchingLabelToNormal
-    ] ifFalse:[
-        self updateMatchingIgnorePattern
-    ].
-
-    "Created: / 12-12-2014 / 23:38:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 21-02-2015 / 08:24:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-updateMatchingIgnorePattern
-    self updateMatchingObjectPOs: (self matchingObjectPOsForPattern: nil)
-
-    "Created: / 12-12-2014 / 23:39:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 13-12-2014 / 08:34:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
 updateMatchingLabelToNormal
     self matchingObjectsLabelHolder value: (resources string: 'Matching items:').
 
@@ -672,20 +633,68 @@
     "Modified: / 28-04-2014 / 22:29:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-updateMatchingObjectPOs: matchingPOsArg
-    self enqueueMessage: #delayedUpdateMatchingObjectPOs: for: self arguments: (Array with: matchingPOsArg)
-
-    "Created: / 12-12-2014 / 23:32:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
 updateNoResults: root
     | items |
 
     items := (Array with: ((HierarchicalItemWithLabel new parent: root; label:((resources string:'No search results...') asText colorizeAllWith: Color gray)))).
-    self updateMatchingObjectPOs: items.
+    self enqueueDelayedUpdateMatchingObjectPOs: items.
 
     "Created: / 11-03-2013 / 14:33:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 12-12-2014 / 23:32:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 21-02-2015 / 08:58:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!AbstractListDialog methodsFor:'change & update-background'!
+
+updateMatching
+    | pattern pos |
+
+    self assert: [ Processor activeProcess == matchingObjectsUpdateJob thread ] message: 'This method can be called only from background update job'.
+
+    self matchPatternHolder value notEmptyOrNil ifTrue:[
+        pattern := StringPattern fromString: self matchPatternHolder value.
+        pos := self matchingObjectPOsForPattern: pattern.
+        self enqueueDelayedUpdateMatchingObjectPOs: pos.
+        self updateMatchingLabelToNormal
+    ] ifFalse:[
+        self updateMatchingIgnorePattern
+    ].
+
+    "Created: / 12-12-2014 / 23:38:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 21-02-2015 / 08:57:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+updateMatchingIgnorePattern
+
+    self assert: [ Processor activeProcess == matchingObjectsUpdateJob thread ] message: 'This method can be called only from background update job'.
+
+    self enqueueDelayedUpdateMatchingObjectPOs: (self matchingObjectPOsForPattern: nil)
+
+    "Created: / 12-12-2014 / 23:39:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 21-02-2015 / 08:58:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!AbstractListDialog methodsFor:'change & update-delayed'!
+
+delayedUpdateMatchingObjectPOs: matchingPOsArg
+    | rootPO matchPatternString  |
+
+    rootPO := self matchingObjectsTree root.
+    rootPO
+        children:matchingPOsArg;
+        expand.
+    matchPatternString := self matchPatternHolder value.
+    matchPatternString isEmptyOrNil ifTrue:[ 
+        ^ self.
+    ].
+    matchingPOsArg size == 1 ifTrue:[
+        matchingObjectsMultiselect ifTrue:[
+            self matchingObjectsSelection: matchingPOsArg
+        ] ifFalse:[
+            self matchingObjectsSelection: matchingPOsArg anElement
+        ]
+    ].
+
+    "Created: / 12-12-2014 / 23:32:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !AbstractListDialog methodsFor:'event processing'!
@@ -777,13 +786,13 @@
     matchPatternHolder addDependent:self.
     matchPatternView selectAll.
 
-    self updateMatchingIgnorePattern.
+    matchingObjectsUpdateJob restart:[ self updateMatchingIgnorePattern].
     self updateAcceptEnabled.
     self updateMatchPatternHolderFromSelection.
     super commonPostBuild
 
     "Created: / 25-11-2014 / 13:23:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 12-12-2014 / 23:38:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 21-02-2015 / 17:49:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 commonPreOpen
--- a/SmallSense__AbstractSearchDialog.st	Sat Feb 21 08:46:46 2015 +0000
+++ b/SmallSense__AbstractSearchDialog.st	Sat Feb 21 22:54:44 2015 +0000
@@ -135,16 +135,18 @@
 
     "Created: / 08-12-2014 / 02:36:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 11-01-2015 / 06:18:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
+! !
+
+!AbstractSearchDialog methodsFor:'change & update-background'!
 
 updateMatchingIgnorePattern
 
     "/ Show recent searches rather than all items (there may be a lot...)
-    self updateMatchingObjectPOs: processor recentlySearchedObjectPOs.
+    self enqueueDelayedUpdateMatchingObjectPOs: processor recentlySearchedObjectPOs.
     self updateMatchingLabelToRecentSearches
 
     "Created: / 12-12-2014 / 23:39:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 11-01-2015 / 06:33:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 21-02-2015 / 08:58:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !AbstractSearchDialog methodsFor:'hooks'!
@@ -156,13 +158,13 @@
 "/        matchPatternView selectAll.
 "/    ].
     recentlySearchedObjectPOs notEmptyOrNil ifTrue:[
-        self updateMatchingObjectPOs: recentlySearchedObjectPOs asArray reverse.
+        self enqueueDelayedUpdateMatchingObjectPOs: recentlySearchedObjectPOs asArray reverse.
         self updateMatchingLabelToRecentSearches.
     ].
     super commonPostBuild
 
     "Created: / 25-11-2014 / 13:23:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 13-12-2014 / 08:28:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 21-02-2015 / 08:58:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !AbstractSearchDialog methodsFor:'queries'!
--- a/SmallSense__Navigator.st	Sat Feb 21 08:46:46 2015 +0000
+++ b/SmallSense__Navigator.st	Sat Feb 21 22:54:44 2015 +0000
@@ -92,15 +92,6 @@
     "Created: / 23-01-2015 / 22:21:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-updateMatchingIgnorePattern
-    steps size == 1 ifTrue:[
-        ^ super updateMatchingIgnorePattern 
-    ].
-    self updateMatchingObjectPOs: (self matchingObjectPOsForPattern: nil)
-
-    "Created: / 24-01-2015 / 00:50:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
 updateMextSearchStepVisibility
     "raise an error: this method should be implemented (TODO)"
 
@@ -119,6 +110,18 @@
     "Created: / 23-01-2015 / 22:21:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!Navigator methodsFor:'change & update-background'!
+
+updateMatchingIgnorePattern
+    steps size == 1 ifTrue:[
+        ^ super updateMatchingIgnorePattern 
+    ].
+    self enqueueDelayedUpdateMatchingObjectPOs: (self matchingObjectPOsForPattern: nil)
+
+    "Created: / 24-01-2015 / 00:50:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 21-02-2015 / 08:58:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !Navigator methodsFor:'event processing'!
 
 keyPressCursorRightInMatchingObjectsView
@@ -161,10 +164,10 @@
     processor := aNavigatorStep processor.
     update ifTrue:[ 
         self matchPatternHolder value: nil.
-        self updateMatching
     ].
 
     "Created: / 24-01-2015 / 00:24:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 21-02-2015 / 17:51:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 step
--- a/abbrev.stc	Sat Feb 21 08:46:46 2015 +0000
+++ b/abbrev.stc	Sat Feb 21 22:54:44 2015 +0000
@@ -79,10 +79,11 @@
 SmallSense::PackageSelectDialog SmallSense__PackageSelectDialog stx:goodies/smallsense 'SmallSense-Core-Interface-Search' 1
 SmallSense::ProtocolSelectDialog SmallSense__ProtocolSelectDialog stx:goodies/smallsense 'SmallSense-Core-Interface-Search' 1
 SmallSense::GroovyCompletionEngineSimple SmallSense__GroovyCompletionEngineSimple stx:goodies/smallsense 'SmallSense-Groovy' 2
+SmallSense::AbstractTestCase SmallSense__AbstractTestCase stx:goodies/smallsense 'SmallSense-Tests' 1
+SmallSense::CompletionEngineTests SmallSense__CompletionEngineTests stx:goodies/smallsense 'SmallSense-Tests' 1
 SmallSense::AbstractJavaCompletionEngineTests SmallSense__AbstractJavaCompletionEngineTests stx:goodies/smallsense 'SmallSense-Tests' 1
-SmallSense::AbstractTestCase SmallSense__AbstractTestCase stx:goodies/smallsense 'SmallSense-Tests' 1
 SmallSense::BaseTestClass SmallSense__BaseTestClass stx:goodies/smallsense 'SmallSense-Tests-Obsolete' 1
-SmallSense::CompletionEngineTests SmallSense__CompletionEngineTests stx:goodies/smallsense 'SmallSense-Tests' 1
+SmallSense::TestCase SmallSense__TestCase stx:goodies/smallsense 'SmallSense-Tests-Obsolete' 1
 SmallSense::EditSupportTests SmallSense__EditSupportTests stx:goodies/smallsense 'SmallSense-Tests' 1
 SmallSense::FinderTests SmallSense__FinderTests stx:goodies/smallsense 'SmallSense-Tests-Obsolete' 1
 SmallSense::GroovyCompletionEngineSimpleTests SmallSense__GroovyCompletionEngineSimpleTests stx:goodies/smallsense 'SmallSense-Tests' 1
@@ -93,5 +94,4 @@
 SmallSense::SmalltalkCompletionEngineTests SmallSense__SmalltalkCompletionEngineTests stx:goodies/smallsense 'SmallSense-Tests' 1
 SmallSense::SmalltalkEditSupportTests SmallSense__SmalltalkEditSupportTests stx:goodies/smallsense 'SmallSense-Tests' 1
 SmallSense::SmalltalkParserTests SmallSense__SmalltalkParserTests stx:goodies/smallsense 'SmallSense-Tests-Obsolete' 1
-SmallSense::TestCase SmallSense__TestCase stx:goodies/smallsense 'SmallSense-Tests-Obsolete' 1
 SmallSense::TokenPatternMatcherTests SmallSense__TokenPatternMatcherTests stx:goodies/smallsense 'SmallSense-Tests' 1
--- a/extensions.st	Sat Feb 21 08:46:46 2015 +0000
+++ b/extensions.st	Sat Feb 21 22:54:44 2015 +0000
@@ -90,7 +90,6 @@
     dialog := SmallSense::PackageSelectDialog new.
     dialog title: title.
     dialog filter: [ :pkg | listOfProjects includes: pkg ].
-    dialog updateMatching.
     (initialTextOrNil notNil and:[initialTextOrNil ~~ PackageId noProjectID]) ifTrue:[
         initialTextOrNil isEmpty ifTrue:[
             suggestions size == 1 ifTrue:[
@@ -105,7 +104,8 @@
     ^ dialog open.
 
     "Created: / 25-11-2014 / 13:20:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 13-12-2014 / 08:49:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 21-02-2015 / 08:59:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (comment): / 21-02-2015 / 17:53:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !EditTextView methodsFor:'accessing-behavior'!
@@ -448,26 +448,6 @@
     "Created: / 15-10-2014 / 09:34:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
-!RBProgramNode methodsFor:'inspecting'!
-
-inspector2TabRBParseTreeInspector
-    <inspector2Tab>
-
-    ^ (self newInspector2Tab)
-        label:'Parse Tree (RB)';
-        priority:35;
-        application:
-                [
-                    | src |
-
-                    src := self source.
-                    SmallSense::ParseTreeInspector new node:self source:src.
-                ];
-        yourself
-
-    "Created: / 19-02-2015 / 15:22:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-
 !RBProgramNode methodsFor:'accessing'!
 
 startPosition
@@ -828,7 +808,6 @@
     ].
     dialog := SmallSense::ProtocolSelectDialog new.   
     dialog title: (resources string: question).
-    dialog updateMatching.
     dialog addButtonCancel.   
     dialog addButtonAcceptWithLabel: (resources string: okLabel).  
     initialText notNil ifTrue:[ 
@@ -841,7 +820,7 @@
     "
 
     "Created: / 09-01-2015 / 10:44:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 29-01-2015 / 07:10:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (comment): / 21-02-2015 / 17:52:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !Tools::NewSystemBrowser class methodsFor:'utilities'!
--- a/smallsense.rc	Sat Feb 21 08:46:46 2015 +0000
+++ b/smallsense.rc	Sat Feb 21 22:54:44 2015 +0000
@@ -25,7 +25,7 @@
       VALUE "LegalCopyright", "Copyright Jan Vrany 2013-2014\0"
       VALUE "ProductName", "SmallSense\0"
       VALUE "ProductVersion", "6.2.5.0\0"
-      VALUE "ProductDate", "Thu, 19 Feb 2015 16:41:56 GMT\0"
+      VALUE "ProductDate", "Sat, 21 Feb 2015 22:50:34 GMT\0"
     END
 
   END
--- a/stx_goodies_smallsense.st	Sat Feb 21 08:46:46 2015 +0000
+++ b/stx_goodies_smallsense.st	Sat Feb 21 22:54:44 2015 +0000
@@ -226,10 +226,11 @@
         #'SmallSense::PackageSelectDialog'
         #'SmallSense::ProtocolSelectDialog'
         #'SmallSense::GroovyCompletionEngineSimple'
-        (#'SmallSense::AbstractJavaCompletionEngineTests' autoload)
         (#'SmallSense::AbstractTestCase' autoload)
+        (#'SmallSense::CompletionEngineTests' autoload)
+        (#'SmallSense::AbstractJavaCompletionEngineTests' autoload)   
         (#'SmallSense::BaseTestClass' autoload)
-        (#'SmallSense::CompletionEngineTests' autoload)
+        (#'SmallSense::TestCase' autoload)
         (#'SmallSense::EditSupportTests' autoload)
         (#'SmallSense::FinderTests' autoload)
         (#'SmallSense::GroovyCompletionEngineSimpleTests' autoload)
@@ -240,9 +241,10 @@
         (#'SmallSense::SmalltalkCompletionEngineTests' autoload)
         (#'SmallSense::SmalltalkEditSupportTests' autoload)
         (#'SmallSense::SmalltalkParserTests' autoload)
-        (#'SmallSense::TestCase' autoload)
         (#'SmallSense::TokenPatternMatcherTests' autoload)
     )
+
+    "Modified: / 21-02-2015 / 22:50:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 extensionMethodNames
@@ -320,7 +322,6 @@
         #'Tools::Inspector2' processShortcut:
         WorkspaceApplication processShortcut:
         #'Tools::NewSystemBrowser' processShortcut:
-        RBProgramNode inspector2TabRBParseTreeInspector
     )
 ! !