Oops, fixed performance problem caused by excessive cache flushing
authorJan Vrany <jan.vrany@fit.cvut.cz>
Sun, 11 Oct 2015 07:34:18 +0100
changeset 577 cd420edfbd1d
parent 576 e1e0ef5ceb6f
child 578 4563193ab4f5
Oops, fixed performance problem caused by excessive cache flushing Flush branch/bookmarks/head cache only after execution of command that actually may change. This should speed up repository browser a lot.
mercurial/HGCommand.st
mercurial/HGRepository.st
--- a/mercurial/HGCommand.st	Mon Sep 14 06:04:42 2015 +0100
+++ b/mercurial/HGCommand.st	Sun Oct 11 07:34:18 2015 +0100
@@ -1169,6 +1169,18 @@
     "Modified: / 08-03-2013 / 22:32:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!HGCommand methodsFor:'queries'!
+
+modifiesRepository
+    "Return true if this command may modify the repository,
+     such as by adding/removing changesets, changing bookmarks,
+     heads and so on, False otherwise."
+
+    ^ self subclassResponsibility
+
+    "Created: / 11-10-2015 / 07:27:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !HGCommand::add methodsFor:'accessing'!
 
 paths
@@ -1201,6 +1213,18 @@
     "Modified: / 15-11-2012 / 00:38:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!HGCommand::add methodsFor:'queries'!
+
+modifiesRepository
+    "Return true if this command may modify the repository,
+     such as by adding/removing changesets, changing bookmarks,
+     heads and so on, False otherwise."
+
+    ^ false
+
+    "Modified (format): / 11-10-2015 / 07:28:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !HGCommand::bookmark methodsFor:'accessing'!
 
 name
@@ -1249,6 +1273,18 @@
     "Created: / 20-03-2014 / 17:27:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!HGCommand::bookmark methodsFor:'queries'!
+
+modifiesRepository
+    "Return true if this command may modify the repository,
+     such as by adding/removing changesets, changing bookmarks,
+     heads and so on, False otherwise."
+
+    ^ true
+
+    "Modified: / 11-10-2015 / 07:28:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !HGCommand::bookmark_delete methodsFor:'accessing'!
 
 name
@@ -1298,6 +1334,18 @@
     "Created: / 20-03-2014 / 17:27:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!HGCommand::bookmark_delete methodsFor:'queries'!
+
+modifiesRepository
+    "Return true if this command may modify the repository,
+     such as by adding/removing changesets, changing bookmarks,
+     heads and so on, False otherwise."
+
+    ^ true
+
+    "Modified: / 11-10-2015 / 07:29:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !HGCommand::branches methodsFor:'accessing'!
 
 active
@@ -1346,6 +1394,18 @@
     "Created: / 27-11-2012 / 19:55:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!HGCommand::branches methodsFor:'queries'!
+
+modifiesRepository
+    "Return true if this command may modify the repository,
+     such as by adding/removing changesets, changing bookmarks,
+     heads and so on, False otherwise."
+
+    ^ false
+
+    "Modified: / 11-10-2015 / 07:29:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !HGCommand::cat methodsFor:'accessing'!
 
 destination
@@ -1472,6 +1532,18 @@
     "Modified: / 06-07-2014 / 16:53:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!HGCommand::cat methodsFor:'queries'!
+
+modifiesRepository
+    "Return true if this command may modify the repository,
+     such as by adding/removing changesets, changing bookmarks,
+     heads and so on, False otherwise."
+
+    ^ false
+
+    "Modified: / 11-10-2015 / 07:29:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !HGCommand::clone methodsFor:'accessing'!
 
 path
@@ -1511,6 +1583,18 @@
     "Modified: / 14-11-2012 / 22:42:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!HGCommand::clone methodsFor:'queries'!
+
+modifiesRepository
+    "Return true if this command may modify the repository,
+     such as by adding/removing changesets, changing bookmarks,
+     heads and so on, False otherwise."
+
+    ^ false
+
+    "Modified: / 11-10-2015 / 07:29:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !HGCommand::commit methodsFor:'accessing'!
 
 amend
@@ -1620,6 +1704,18 @@
     "Created: / 15-11-2012 / 17:06:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!HGCommand::commit methodsFor:'queries'!
+
+modifiesRepository
+    "Return true if this command may modify the repository,
+     such as by adding/removing changesets, changing bookmarks,
+     heads and so on, False otherwise."
+
+    ^ true
+
+    "Modified: / 11-10-2015 / 07:29:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !HGCommand::heads methodsFor:'private'!
 
 argumentsCommandOn:stream
@@ -1655,6 +1751,47 @@
     "Modified: / 08-03-2013 / 19:35:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!HGCommand::heads methodsFor:'queries'!
+
+modifiesRepository
+    "Return true if this command may modify the repository,
+     such as by adding/removing changesets, changing bookmarks,
+     heads and so on, False otherwise."
+
+    ^ false
+
+    "Modified: / 11-10-2015 / 07:29:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!HGCommand::help methodsFor:'private'!
+
+argumentsCommandOn:stream
+    "Called to get command specific options"
+
+    ^ self shouldNotImplement
+
+    "Modified: / 11-10-2015 / 07:31:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+parseOutput:stream
+    "Parses output of 'hg' command, i.e. commit, log, update, checkout,
+     etc."
+
+    ^ self shouldImplement
+! !
+
+!HGCommand::help methodsFor:'queries'!
+
+modifiesRepository
+    "Return true if this command may modify the repository,
+     such as by adding/removing changesets, changing bookmarks,
+     heads and so on, False otherwise."
+
+    ^ false
+
+    "Modified: / 11-10-2015 / 07:30:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !HGCommand::init methodsFor:'accessing'!
 
 path
@@ -1682,6 +1819,18 @@
     "Created: / 13-02-2014 / 12:36:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!HGCommand::init methodsFor:'queries'!
+
+modifiesRepository
+    "Return true if this command may modify the repository,
+     such as by adding/removing changesets, changing bookmarks,
+     heads and so on, False otherwise."
+
+    ^ true
+
+    "Modified: / 11-10-2015 / 07:30:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !HGCommand::locate methodsFor:'accessing'!
 
 revision
@@ -1714,6 +1863,18 @@
     "Modified: / 16-11-2012 / 22:33:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!HGCommand::locate methodsFor:'queries'!
+
+modifiesRepository
+    "Return true if this command may modify the repository,
+     such as by adding/removing changesets, changing bookmarks,
+     heads and so on, False otherwise."
+
+    ^ false
+
+    "Modified: / 11-10-2015 / 07:30:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !HGCommand::log methodsFor:'accessing'!
 
 childrenOnly
@@ -1844,6 +2005,18 @@
     "Modified: / 08-02-2014 / 22:12:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!HGCommand::log methodsFor:'queries'!
+
+modifiesRepository
+    "Return true if this command may modify the repository,
+     such as by adding/removing changesets, changing bookmarks,
+     heads and so on, False otherwise."
+
+    ^ false
+
+    "Modified: / 11-10-2015 / 07:30:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !HGCommand::merge methodsFor:'accessing'!
 
 revision
@@ -1898,6 +2071,18 @@
     "Created: / 14-01-2013 / 16:05:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!HGCommand::merge methodsFor:'queries'!
+
+modifiesRepository
+    "Return true if this command may modify the repository,
+     such as by adding/removing changesets, changing bookmarks,
+     heads and so on, False otherwise."
+
+    ^ false
+
+    "Modified: / 11-10-2015 / 07:30:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !HGCommand::mv methodsFor:'accessing'!
 
 destination
@@ -1944,6 +2129,18 @@
     "Modified: / 15-11-2012 / 00:38:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!HGCommand::mv methodsFor:'queries'!
+
+modifiesRepository
+    "Return true if this command may modify the repository,
+     such as by adding/removing changesets, changing bookmarks,
+     heads and so on, False otherwise."
+
+    ^ false
+
+    "Modified: / 11-10-2015 / 07:30:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !HGCommand::pull methodsFor:'accessing'!
 
 url
@@ -1994,6 +2191,18 @@
     "Created: / 15-11-2012 / 17:06:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!HGCommand::pull methodsFor:'queries'!
+
+modifiesRepository
+    "Return true if this command may modify the repository,
+     such as by adding/removing changesets, changing bookmarks,
+     heads and so on, False otherwise."
+
+    ^ true
+
+    "Modified: / 11-10-2015 / 07:30:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !HGCommand::push methodsFor:'accessing'!
 
 force
@@ -2059,6 +2268,18 @@
     "Created: / 15-11-2012 / 17:06:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!HGCommand::push methodsFor:'queries'!
+
+modifiesRepository
+    "Return true if this command may modify the repository,
+     such as by adding/removing changesets, changing bookmarks,
+     heads and so on, False otherwise."
+
+    ^ false
+
+    "Modified: / 11-10-2015 / 07:30:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !HGCommand::remove methodsFor:'accessing'!
 
 force
@@ -2104,6 +2325,18 @@
     "Modified: / 15-11-2012 / 00:38:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!HGCommand::remove methodsFor:'queries'!
+
+modifiesRepository
+    "Return true if this command may modify the repository,
+     such as by adding/removing changesets, changing bookmarks,
+     heads and so on, False otherwise."
+
+    ^ false
+
+    "Modified: / 11-10-2015 / 07:30:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !HGCommand::resolve class methodsFor:'initialization'!
 
 initialize
@@ -2193,6 +2426,18 @@
     "Created: / 14-01-2013 / 19:27:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!HGCommand::resolve methodsFor:'queries'!
+
+modifiesRepository
+    "Return true if this command may modify the repository,
+     such as by adding/removing changesets, changing bookmarks,
+     heads and so on, False otherwise."
+
+    ^false
+
+    "Modified: / 11-10-2015 / 07:30:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !HGCommand::resolve__list methodsFor:'private'!
 
 argumentsCommandOn:stream
@@ -2218,6 +2463,18 @@
     "Modified: / 14-01-2013 / 16:43:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!HGCommand::resolve__list methodsFor:'queries'!
+
+modifiesRepository
+    "Return true if this command may modify the repository,
+     such as by adding/removing changesets, changing bookmarks,
+     heads and so on, False otherwise."
+
+    ^ false
+
+    "Modified: / 11-10-2015 / 07:30:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !HGCommand::share methodsFor:'accessing'!
 
 destination
@@ -2274,6 +2531,18 @@
     "Modified: / 14-11-2012 / 22:42:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!HGCommand::share methodsFor:'queries'!
+
+modifiesRepository
+    "Return true if this command may modify the repository,
+     such as by adding/removing changesets, changing bookmarks,
+     heads and so on, False otherwise."
+
+    ^ false
+
+    "Modified: / 11-10-2015 / 07:30:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !HGCommand::showconfig methodsFor:'accessing'!
 
 argumentsCommandOn:stream
@@ -2295,6 +2564,18 @@
     "Created: / 06-12-2012 / 21:45:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!HGCommand::showconfig methodsFor:'queries'!
+
+modifiesRepository
+    "Return true if this command may modify the repository,
+     such as by adding/removing changesets, changing bookmarks,
+     heads and so on, False otherwise."
+
+    ^ false
+
+    "Modified: / 11-10-2015 / 07:31:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !HGCommand::status methodsFor:'accessing'!
 
 path
@@ -2322,6 +2603,18 @@
     "Modified: / 23-10-2012 / 11:07:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!HGCommand::status methodsFor:'queries'!
+
+modifiesRepository
+    "Return true if this command may modify the repository,
+     such as by adding/removing changesets, changing bookmarks,
+     heads and so on, False otherwise."
+
+    ^ false
+
+    "Modified: / 11-10-2015 / 07:31:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !HGCommand::update methodsFor:'accessing'!
 
 revision
@@ -2353,6 +2646,18 @@
     "Modified: / 14-01-2013 / 16:00:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!HGCommand::update methodsFor:'queries'!
+
+modifiesRepository
+    "Return true if this command may modify the repository,
+     such as by adding/removing changesets, changing bookmarks,
+     heads and so on, False otherwise."
+
+    ^ false
+
+    "Modified: / 11-10-2015 / 07:31:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !HGCommand::version methodsFor:'accessing'!
 
 arguments:something
@@ -2384,6 +2689,14 @@
     "Modified: / 18-07-2014 / 11:18:36 / jv"
 !
 
+argumentsCommandOn:stream
+    "Called to get command specific options"
+
+    ^ self shouldNotImplement
+
+    "Modified: / 11-10-2015 / 07:31:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 parseOutput:stream
     "Parses output of 'hg' command, i.e. commit, log, update, checkout,
      etc."
@@ -2393,6 +2706,18 @@
     "Created: / 19-11-2012 / 20:02:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!HGCommand::version methodsFor:'queries'!
+
+modifiesRepository
+    "Return true if this command may modify the repository,
+     such as by adding/removing changesets, changing bookmarks,
+     heads and so on, False otherwise."
+
+    ^ false
+
+    "Modified: / 11-10-2015 / 07:31:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !HGCommand class methodsFor:'documentation'!
 
 version
--- a/mercurial/HGRepository.st	Mon Sep 14 06:04:42 2015 +0100
+++ b/mercurial/HGRepository.st	Sun Oct 11 07:34:18 2015 +0100
@@ -692,14 +692,16 @@
     "/ Flush caches. Theoretically this is not needed but file modification
     "/ detection in HGCachedFileData is not accurate. Here we know something
     "/ changed so better flush caches to avoid false hits.
-    bookmark notNil ifTrue:[ bookmark flush ].
-    bookmarks notNil ifTrue:[ bookmarks flush ].
-    branches notNil ifTrue:[ branches flush ].
-    heads notNil ifTrue:[ heads flush ].
+    anHGCommand modifiesRepository ifTrue:[
+        bookmark notNil ifTrue:[ bookmark flush ].
+        bookmarks notNil ifTrue:[ bookmarks flush ].
+        branches notNil ifTrue:[ branches flush ].
+        heads notNil ifTrue:[ heads flush ].
+    ].
     ^ value.
 
     "Created: / 03-03-2013 / 22:52:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 21-03-2014 / 21:52:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 11-10-2015 / 07:32:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 log: revset limit: limit