Title: [283751] trunk/Tools
Revision
283751
Author
[email protected]
Date
2021-10-07 16:00:15 -0700 (Thu, 07 Oct 2021)

Log Message

[webkitscmpy] Share cache between processes
https://bugs.webkit.org/show_bug.cgi?id=231176
<rdar://problem/83841221>

Reviewed by Dewei Zhu.

Generating the identifier cache is more expensive than reading a file with
that cache in it. This is particularly relevant for webservers, which are
likely running multiple processes.

Reviewed by Dewei Zhu.

* Scripts/libraries/webkitscmpy/setup.py: Bump version.
* Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
* Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py:
(Git.Cache.__init__): Move cache loading into "load" function.
(Git.Cache.load): Open cache file.
(Git.Cache.to_hash): If we fail to find a match, attempt to load the file
before populating the file.
(Git.Cache.to_revision): Ditto.
(Git.Cache.to_identifier): Ditto.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (283750 => 283751)


--- trunk/Tools/ChangeLog	2021-10-07 22:55:33 UTC (rev 283750)
+++ trunk/Tools/ChangeLog	2021-10-07 23:00:15 UTC (rev 283751)
@@ -1,5 +1,29 @@
 2021-10-07  Jonathan Bedard  <[email protected]>
 
+        [webkitscmpy] Share cache between processes
+        https://bugs.webkit.org/show_bug.cgi?id=231176
+        <rdar://problem/83841221>
+
+        Reviewed by Dewei Zhu.
+
+        Generating the identifier cache is more expensive than reading a file with
+        that cache in it. This is particularly relevant for webservers, which are
+        likely running multiple processes.
+
+        Reviewed by Dewei Zhu.
+
+        * Scripts/libraries/webkitscmpy/setup.py: Bump version.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
+        * Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py:
+        (Git.Cache.__init__): Move cache loading into "load" function.
+        (Git.Cache.load): Open cache file.
+        (Git.Cache.to_hash): If we fail to find a match, attempt to load the file
+        before populating the file.
+        (Git.Cache.to_revision): Ditto.
+        (Git.Cache.to_identifier): Ditto.
+
+2021-10-07  Jonathan Bedard  <[email protected]>
+
         [contributors.json] Relocation (Part 7)
         https://bugs.webkit.org/show_bug.cgi?id=229690
         <rdar://problem/82552403>

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/setup.py (283750 => 283751)


--- trunk/Tools/Scripts/libraries/webkitscmpy/setup.py	2021-10-07 22:55:33 UTC (rev 283750)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/setup.py	2021-10-07 23:00:15 UTC (rev 283751)
@@ -29,7 +29,7 @@
 
 setup(
     name='webkitscmpy',
-    version='2.2.4',
+    version='2.2.5',
     description='Library designed to interact with git and svn repositories.',
     long_description=readme(),
     classifiers=[

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (283750 => 283751)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py	2021-10-07 22:55:33 UTC (rev 283750)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py	2021-10-07 23:00:15 UTC (rev 283751)
@@ -46,7 +46,7 @@
         "Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
     )
 
-version = Version(2, 2, 4)
+version = Version(2, 2, 5)
 
 AutoInstall.register(Package('fasteners', Version(0, 15, 0)))
 AutoInstall.register(Package('monotonic', Version(1, 5)))

Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py (283750 => 283751)


--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py	2021-10-07 22:55:33 UTC (rev 283750)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py	2021-10-07 23:00:15 UTC (rev 283751)
@@ -49,6 +49,9 @@
             self._last_populated = {}
             self._guranteed_for = guranteed_for
 
+            self.load()
+
+        def load(self):
             if not os.path.exists(self.path):
                 return
 
@@ -204,13 +207,17 @@
             _, b_count, branch = parts
             if b_count < 0:
                 return None
-            if branch not in self._ordered_commits or len(self._ordered_commits[branch]) <= b_count:
-                if populate:
-                    self.populate(branch=branch)
-                    return self.to_hash(identifier=identifier, populate=False)
-                return None
-            return self._ordered_commits[branch][b_count]
+            if branch in self._ordered_commits and len(self._ordered_commits[branch]) > b_count:
+                return self._ordered_commits[branch][b_count]
 
+            self.load()
+            if branch in self._ordered_commits and len(self._ordered_commits[branch]) > b_count:
+                return self._ordered_commits[branch][b_count]
+            if populate:
+                self.populate(branch=branch)
+                return self.to_hash(identifier=identifier, populate=False)
+            return None
+
         def to_revision(self, hash=None, identifier=None, populate=True, branch=None):
             if hash:
                 identifier = self.to_identifier(hash=hash, populate=populate, branch=branch)
@@ -221,18 +228,26 @@
             _, b_count, branch = parts
             if b_count < 0:
                 return None
-            if branch not in self._ordered_revisions or len(self._ordered_revisions[branch]) <= b_count:
-                if populate:
-                    self.populate(branch=branch)
-                    return self.to_revision(identifier=identifier, populate=False)
-                return None
-            return self._ordered_revisions[branch][b_count]
+            if branch in self._ordered_revisions and len(self._ordered_revisions[branch]) > b_count:
+                return self._ordered_revisions[branch][b_count]
 
+            self.load()
+            if branch in self._ordered_revisions and len(self._ordered_revisions[branch]) > b_count:
+                return self._ordered_revisions[branch][b_count]
+            if populate:
+                self.populate(branch=branch)
+                return self.to_revision(identifier=identifier, populate=False)
+            return None
+
         def to_identifier(self, hash=None, revision=None, populate=True, branch=None):
             revision = Commit._parse_revision(revision, do_assert=False)
             if revision:
                 if revision in self._revisions_to_identifiers:
                     return self._revisions_to_identifiers[revision]
+
+                self.load()
+                if revision in self._revisions_to_identifiers:
+                    return self._revisions_to_identifiers[revision]
                 if populate:
                     self.populate(branch=branch)
                     return self.to_identifier(revision=revision, populate=False)
@@ -244,7 +259,11 @@
                     candidate = self._hash_to_identifiers.get(hash)
                 except KeyError:  # Means the hash wasn't specific enough
                     return None
+                if candidate:
+                    return candidate
 
+                self.load()
+                candidate = self._hash_to_identifiers.get(hash)
                 if candidate:
                     return candidate
                 if populate:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to