Submitter | Gregory Szorc |
---|---|
Date | Sept. 24, 2016, 7:37 p.m. |
Message ID | <db0073124b876cc8b8e1.1474745839@ubuntu-vm-main> |
Download | mbox | patch |
Permalink | /patch/16782/ |
State | Superseded |
Delegated to: | Pierre-Yves David |
Headers | show |
Comments
On 09/24/2016 09:37 PM, Gregory Szorc wrote: > # HG changeset patch > # User Gregory Szorc <gregory.szorc@gmail.com> > # Date 1474745226 25200 > # Sat Sep 24 12:27:06 2016 -0700 > # Node ID db0073124b876cc8b8e1201ba1b867b56c8a0448 > # Parent 712281c3ab4b6e6e8ae109fa0673d4d6321d82fd > changelog: disable delta chains This patch seems overall surprising but great. I've some question/feedback regarding the impact on changegroup generation, see below for details. > […] > Delta chains are also used during changegroup generation. This > operation essentially converts a series of revisions to one large > delta chain. And changegroup generation is smart: if the delta in > the revlog matches what the changegroup is emitting, it will reuse > the delta instead of recalculating it. We can measure the impact > removing changelog delta chains has on changegroup generation via > `hg perfchangegroupchangelog`: But changegroup version 2 and 3 are a bit smarter than just a plain deltra chain as they support general delta. Therefore we can have changegroup emit a non-delta chain for changelog (using 'nullid' as the delta base for all entry). > hg > ! wall 1.589245 comb 1.590000 user 1.590000 sys 0.000000 (best of 7) > ! wall 1.788060 comb 1.790000 user 1.790000 sys 0.000000 (best of 6) > > mozilla-central > ! wall 17.382585 comb 17.380000 user 17.340000 sys 0.040000 (best of 3) > ! wall 20.161357 comb 20.160000 user 20.120000 sys 0.040000 (best of 3) > > mozilla-unified > ! wall 18.722839 comb 18.720000 user 18.680000 sys 0.040000 (best of 3) > ! wall 21.168075 comb 21.170000 user 21.130000 sys 0.040000 (best of 3) > > pypy > ! wall 4.828317 comb 4.830000 user 4.820000 sys 0.010000 (best of 3) > ! wall 5.415455 comb 5.420000 user 5.410000 sys 0.010000 (best of 3) > > The data shows eliminating delta chains makes the changelog part of > changegroup generation slower. This is expected since we now have to > compute deltas for revisions where we could recycle the delta before. > > It is worth putting this regression into context of overall changegroup > times. Here is the rough total CPU time spent in changegroup generation > for various repos while using delta chains on the changelog: > > Repo CPU Time (s) CPU Time w/ compression > hg 4.50 7.05 > mozilla-central 111.1 222.0 > pypy 28.68 75.5 > > Before compression, removing delta chains from the changegroup adds > ~4.4% overhead to hg changegroup generation, 1.3% to mozilla-central, > and 2.0% to pypy. When you factor in zlib compression, these percentages > are roughly divided by 2. Even if the impact is small, it in the range of the performance gain we win on local operation, so still kind of relevant (otherwise that whole change would not be relevant). Can you experiment with a no-delta changelog chain the changegroup and tell us how it looks like ? > While the increased CPU usage for changegroup generation is unfortunate, > I think it is acceptable because the percentage is small, server > operators (those likely impacted most by this) have other mechanisms > to mitigate CPU consumption (namely reducing zlib compression level and > pre-generated clone bundles), and because there is room to optimize this > in the future. For example, we could introduce a new changegroup format > that allowed changelog entries to be represented differently so we don't > have to compute deltas. (So as pointed above, I believe the current format already supports what you are looking for). > Removing delta chains from the changelog also opens the door to future > optimizations. > > I just mentioned the possibility of a new changegroup representation for > changelog data. > > Storing changelog entries as independent entities also enables more > advanced storage options. We could refactor the changelog API to > distinguish between a supported data access API and the internal > mechanism for storing that data (much like the manifest API refactor > currently under way). This would make it easier to swap in alternative > storage backends for the changelog, such as SQLite or some such. This > in turn would make it easier to support features like shallow clone, > where changesets may arrive to local storage out of DAG order. I remember Durham presenting related plan during the latest sprint in Mozilla SF. I'm not too sure what the progress is as there is no wiki page about it but I assume we'll know more about it at the coming sprint. That said, this part of the description seems a bit too disconnect to the actual change. I would advise for starting a mailing list thread about that after that path gets in. > Another possibility is enabling dictionary compression on revlogs. > Currently, each entry is compressed in isolation. Now that we have a > compressed representation of each revision and each revision has similar > structure, we would likely see benefits by using dictionary compression. > We can't do this with zlib. But it does enable easier experimentation > with compression formats that do (fun fact: experimenting with zstd > led me down a path that resulted in this patch). > > There is potentially room to add a revlog flag indicating whether not > to store delta chains. This could potentially lead to more read path > optimizations to skip delta chain computation. But I'm not convinced > it is worthwhile and worth wasting a revlog flag bit on. Same feedback, "interesting but should probably be on the list instead of in that commit message. Cheers,
On Tue, Sep 27, 2016 at 7:52 AM, Pierre-Yves David < pierre-yves.david@ens-lyon.org> wrote: > > > On 09/24/2016 09:37 PM, Gregory Szorc wrote: > >> # HG changeset patch >> # User Gregory Szorc <gregory.szorc@gmail.com> >> # Date 1474745226 25200 >> # Sat Sep 24 12:27:06 2016 -0700 >> # Node ID db0073124b876cc8b8e1201ba1b867b56c8a0448 >> # Parent 712281c3ab4b6e6e8ae109fa0673d4d6321d82fd >> changelog: disable delta chains >> > > This patch seems overall surprising but great. I've some question/feedback > regarding the impact on changegroup generation, see below for details. > > […] >> > > Delta chains are also used during changegroup generation. This >> operation essentially converts a series of revisions to one large >> delta chain. And changegroup generation is smart: if the delta in >> the revlog matches what the changegroup is emitting, it will reuse >> the delta instead of recalculating it. We can measure the impact >> removing changelog delta chains has on changegroup generation via >> `hg perfchangegroupchangelog`: >> > > But changegroup version 2 and 3 are a bit smarter than just a plain deltra > chain as they support general delta. Therefore we can have changegroup emit > a non-delta chain for changelog (using 'nullid' as the delta base for all > entry). Correct - we could do this as a followup. A mode where the server "streams" revlog entries instead of calculating an infinite delta chain could result in significant CPU reductions on the server (at the cost of more bandwidth). > > > hg >> ! wall 1.589245 comb 1.590000 user 1.590000 sys 0.000000 (best of 7) >> ! wall 1.788060 comb 1.790000 user 1.790000 sys 0.000000 (best of 6) >> >> mozilla-central >> ! wall 17.382585 comb 17.380000 user 17.340000 sys 0.040000 (best of 3) >> ! wall 20.161357 comb 20.160000 user 20.120000 sys 0.040000 (best of 3) >> >> mozilla-unified >> ! wall 18.722839 comb 18.720000 user 18.680000 sys 0.040000 (best of 3) >> ! wall 21.168075 comb 21.170000 user 21.130000 sys 0.040000 (best of 3) >> >> pypy >> ! wall 4.828317 comb 4.830000 user 4.820000 sys 0.010000 (best of 3) >> ! wall 5.415455 comb 5.420000 user 5.410000 sys 0.010000 (best of 3) >> >> The data shows eliminating delta chains makes the changelog part of >> changegroup generation slower. This is expected since we now have to >> compute deltas for revisions where we could recycle the delta before. >> >> It is worth putting this regression into context of overall changegroup >> times. Here is the rough total CPU time spent in changegroup generation >> for various repos while using delta chains on the changelog: >> >> Repo CPU Time (s) CPU Time w/ compression >> hg 4.50 7.05 >> mozilla-central 111.1 222.0 >> pypy 28.68 75.5 >> >> Before compression, removing delta chains from the changegroup adds >> ~4.4% overhead to hg changegroup generation, 1.3% to mozilla-central, >> and 2.0% to pypy. When you factor in zlib compression, these percentages >> are roughly divided by 2. >> > > Even if the impact is small, it in the range of the performance gain we > win on local operation, so still kind of relevant (otherwise that whole > change would not be relevant). Can you experiment with a no-delta changelog > chain the changegroup and tell us how it looks like ? > Yes, I can do that. I would prefer it not block this landing as I think the existing trade-off is worthwhile. Furthermore, I've contributed several optimizations to bundle transfer already and it's worth noting that this regression is extremely minor in the larger context of the gains we've already seen and will continue to see. > > While the increased CPU usage for changegroup generation is unfortunate, >> I think it is acceptable because the percentage is small, server >> operators (those likely impacted most by this) have other mechanisms >> to mitigate CPU consumption (namely reducing zlib compression level and >> pre-generated clone bundles), and because there is room to optimize this >> in the future. For example, we could introduce a new changegroup format >> that allowed changelog entries to be represented differently so we don't >> have to compute deltas. >> > > (So as pointed above, I believe the current format already supports what > you are looking for). > > Removing delta chains from the changelog also opens the door to future >> optimizations. >> >> I just mentioned the possibility of a new changegroup representation for >> changelog data. >> >> Storing changelog entries as independent entities also enables more >> advanced storage options. We could refactor the changelog API to >> distinguish between a supported data access API and the internal >> mechanism for storing that data (much like the manifest API refactor >> currently under way). This would make it easier to swap in alternative >> storage backends for the changelog, such as SQLite or some such. This >> in turn would make it easier to support features like shallow clone, >> where changesets may arrive to local storage out of DAG order. >> > > I remember Durham presenting related plan during the latest sprint in > Mozilla SF. I'm not too sure what the progress is as there is no wiki page > about it but I assume we'll know more about it at the coming sprint. > > That said, this part of the description seems a bit too disconnect to the > actual change. I would advise for starting a mailing list thread about that > after that path gets in. > > Another possibility is enabling dictionary compression on revlogs. >> Currently, each entry is compressed in isolation. Now that we have a >> compressed representation of each revision and each revision has similar >> structure, we would likely see benefits by using dictionary compression. >> We can't do this with zlib. But it does enable easier experimentation >> with compression formats that do (fun fact: experimenting with zstd >> led me down a path that resulted in this patch). >> >> There is potentially room to add a revlog flag indicating whether not >> to store delta chains. This could potentially lead to more read path >> optimizations to skip delta chain computation. But I'm not convinced >> it is worthwhile and worth wasting a revlog flag bit on. >> > > Same feedback, "interesting but should probably be on the list instead of > in that commit message. > > Cheers, > > -- > Pierre-Yves David >
Patch
diff --git a/mercurial/changelog.py b/mercurial/changelog.py --- a/mercurial/changelog.py +++ b/mercurial/changelog.py @@ -258,16 +258,22 @@ class changelogrevision(object): class changelog(revlog.revlog): def __init__(self, opener): revlog.revlog.__init__(self, opener, "00changelog.i", checkambig=True) if self._initempty: # changelogs don't benefit from generaldelta self.version &= ~revlog.REVLOGGENERALDELTA self._generaldelta = False + + # Delta chains for changelogs tend to be very small because entries + # tend to be small and don't delta well with each. So disable delta + # chains. + self._storedeltachains = False + self._realopener = opener self._delayed = False self._delaybuf = None self._divert = False self.filteredrevs = frozenset() def tip(self): """filtered version of revlog.tip""" diff --git a/tests/test-acl.t b/tests/test-acl.t --- a/tests/test-acl.t +++ b/tests/test-acl.t @@ -1504,17 +1504,17 @@ No branch acls specified acl: path access granted: "ef1ea85a6374" acl: branch access granted: "f9cafe1212c8" on branch "default" acl: path access granted: "f9cafe1212c8" acl: branch access granted: "911600dab2ae" on branch "default" acl: path access granted: "911600dab2ae" acl: branch access granted: "e8fc755d4d82" on branch "foobar" acl: path access granted: "e8fc755d4d82" updating the branch cache - bundle2-input-part: total payload size 2101 + bundle2-input-part: total payload size 2139 bundle2-input-part: "pushkey" (params: 4 mandatory) supported pushing key for "phases:911600dab2ae7a9baff75958b84fe606851ce955" bundle2-input-part: "pushkey" (params: 4 mandatory) supported pushing key for "phases:e8fc755d4d8217ee5b0c2bb41558c40d43b92c01" bundle2-input-bundle: 4 parts total bundle2-output-bundle: "HG20", 3 parts total bundle2-output-part: "reply:changegroup" (advisory) (params: 0 advisory) empty payload bundle2-output-part: "reply:pushkey" (params: 0 advisory) empty payload @@ -1590,17 +1590,17 @@ Branch acl deny test acl: acl.deny not enabled acl: branch access granted: "ef1ea85a6374" on branch "default" acl: path access granted: "ef1ea85a6374" acl: branch access granted: "f9cafe1212c8" on branch "default" acl: path access granted: "f9cafe1212c8" acl: branch access granted: "911600dab2ae" on branch "default" acl: path access granted: "911600dab2ae" error: pretxnchangegroup.acl hook failed: acl: user "astro" denied on branch "foobar" (changeset "e8fc755d4d82") - bundle2-input-part: total payload size 2101 + bundle2-input-part: total payload size 2139 bundle2-input-bundle: 4 parts total transaction abort! rollback completed abort: acl: user "astro" denied on branch "foobar" (changeset "e8fc755d4d82") no rollback information available 2:fb35475503ef @@ -1658,17 +1658,17 @@ Branch acl empty allow test added 4 changesets with 4 changes to 4 files (+1 heads) calling hook pretxnchangegroup.acl: hgext.acl.hook acl: checking access for user "astro" acl: acl.allow.branches enabled, 0 entries for user astro acl: acl.deny.branches not enabled acl: acl.allow not enabled acl: acl.deny not enabled error: pretxnchangegroup.acl hook failed: acl: user "astro" not allowed on branch "default" (changeset "ef1ea85a6374") - bundle2-input-part: total payload size 2101 + bundle2-input-part: total payload size 2139 bundle2-input-bundle: 4 parts total transaction abort! rollback completed abort: acl: user "astro" not allowed on branch "default" (changeset "ef1ea85a6374") no rollback information available 2:fb35475503ef @@ -1728,17 +1728,17 @@ Branch acl allow other added 4 changesets with 4 changes to 4 files (+1 heads) calling hook pretxnchangegroup.acl: hgext.acl.hook acl: checking access for user "astro" acl: acl.allow.branches enabled, 0 entries for user astro acl: acl.deny.branches not enabled acl: acl.allow not enabled acl: acl.deny not enabled error: pretxnchangegroup.acl hook failed: acl: user "astro" not allowed on branch "default" (changeset "ef1ea85a6374") - bundle2-input-part: total payload size 2101 + bundle2-input-part: total payload size 2139 bundle2-input-bundle: 4 parts total transaction abort! rollback completed abort: acl: user "astro" not allowed on branch "default" (changeset "ef1ea85a6374") no rollback information available 2:fb35475503ef $ do_push george @@ -1800,17 +1800,17 @@ Branch acl allow other acl: path access granted: "ef1ea85a6374" acl: branch access granted: "f9cafe1212c8" on branch "default" acl: path access granted: "f9cafe1212c8" acl: branch access granted: "911600dab2ae" on branch "default" acl: path access granted: "911600dab2ae" acl: branch access granted: "e8fc755d4d82" on branch "foobar" acl: path access granted: "e8fc755d4d82" updating the branch cache - bundle2-input-part: total payload size 2101 + bundle2-input-part: total payload size 2139 bundle2-input-part: "pushkey" (params: 4 mandatory) supported pushing key for "phases:911600dab2ae7a9baff75958b84fe606851ce955" bundle2-input-part: "pushkey" (params: 4 mandatory) supported pushing key for "phases:e8fc755d4d8217ee5b0c2bb41558c40d43b92c01" bundle2-input-bundle: 4 parts total bundle2-output-bundle: "HG20", 3 parts total bundle2-output-part: "reply:changegroup" (advisory) (params: 0 advisory) empty payload bundle2-output-part: "reply:pushkey" (params: 0 advisory) empty payload @@ -1893,17 +1893,17 @@ push foobar into the remote acl: path access granted: "ef1ea85a6374" acl: branch access granted: "f9cafe1212c8" on branch "default" acl: path access granted: "f9cafe1212c8" acl: branch access granted: "911600dab2ae" on branch "default" acl: path access granted: "911600dab2ae" acl: branch access granted: "e8fc755d4d82" on branch "foobar" acl: path access granted: "e8fc755d4d82" updating the branch cache - bundle2-input-part: total payload size 2101 + bundle2-input-part: total payload size 2139 bundle2-input-part: "pushkey" (params: 4 mandatory) supported pushing key for "phases:911600dab2ae7a9baff75958b84fe606851ce955" bundle2-input-part: "pushkey" (params: 4 mandatory) supported pushing key for "phases:e8fc755d4d8217ee5b0c2bb41558c40d43b92c01" bundle2-input-bundle: 4 parts total bundle2-output-bundle: "HG20", 3 parts total bundle2-output-part: "reply:changegroup" (advisory) (params: 0 advisory) empty payload bundle2-output-part: "reply:pushkey" (params: 0 advisory) empty payload @@ -1977,17 +1977,17 @@ Branch acl conflicting deny added 4 changesets with 4 changes to 4 files (+1 heads) calling hook pretxnchangegroup.acl: hgext.acl.hook acl: checking access for user "george" acl: acl.allow.branches not enabled acl: acl.deny.branches enabled, 1 entries for user george acl: acl.allow not enabled acl: acl.deny not enabled error: pretxnchangegroup.acl hook failed: acl: user "george" denied on branch "default" (changeset "ef1ea85a6374") - bundle2-input-part: total payload size 2101 + bundle2-input-part: total payload size 2139 bundle2-input-bundle: 4 parts total transaction abort! rollback completed abort: acl: user "george" denied on branch "default" (changeset "ef1ea85a6374") no rollback information available 2:fb35475503ef User 'astro' must not be denied @@ -2054,17 +2054,17 @@ User 'astro' must not be denied acl: path access granted: "ef1ea85a6374" acl: branch access granted: "f9cafe1212c8" on branch "default" acl: path access granted: "f9cafe1212c8" acl: branch access granted: "911600dab2ae" on branch "default" acl: path access granted: "911600dab2ae" acl: branch access granted: "e8fc755d4d82" on branch "foobar" acl: path access granted: "e8fc755d4d82" updating the branch cache - bundle2-input-part: total payload size 2101 + bundle2-input-part: total payload size 2139 bundle2-input-part: "pushkey" (params: 4 mandatory) supported pushing key for "phases:911600dab2ae7a9baff75958b84fe606851ce955" bundle2-input-part: "pushkey" (params: 4 mandatory) supported pushing key for "phases:e8fc755d4d8217ee5b0c2bb41558c40d43b92c01" bundle2-input-bundle: 4 parts total bundle2-output-bundle: "HG20", 3 parts total bundle2-output-part: "reply:changegroup" (advisory) (params: 0 advisory) empty payload bundle2-output-part: "reply:pushkey" (params: 0 advisory) empty payload @@ -2132,17 +2132,17 @@ Non-astro users must be denied added 4 changesets with 4 changes to 4 files (+1 heads) calling hook pretxnchangegroup.acl: hgext.acl.hook acl: checking access for user "george" acl: acl.allow.branches not enabled acl: acl.deny.branches enabled, 1 entries for user george acl: acl.allow not enabled acl: acl.deny not enabled error: pretxnchangegroup.acl hook failed: acl: user "george" denied on branch "default" (changeset "ef1ea85a6374") - bundle2-input-part: total payload size 2101 + bundle2-input-part: total payload size 2139 bundle2-input-bundle: 4 parts total transaction abort! rollback completed abort: acl: user "george" denied on branch "default" (changeset "ef1ea85a6374") no rollback information available 2:fb35475503ef diff --git a/tests/test-excessive-merge.t b/tests/test-excessive-merge.t --- a/tests/test-excessive-merge.t +++ b/tests/test-excessive-merge.t @@ -64,17 +64,17 @@ summary: test $ hg debugindex --changelog rev offset length ..... linkrev nodeid p1 p2 (re) 0 0 60 ..... 0 5e0375449e74 000000000000 000000000000 (re) 1 60 62 ..... 1 96155394af80 5e0375449e74 000000000000 (re) 2 122 62 ..... 2 92cc4c306b19 5e0375449e74 000000000000 (re) 3 184 69 ..... 3 e16a66a37edd 92cc4c306b19 96155394af80 (re) - 4 253 29 ..... 4 2ee31f665a86 96155394af80 92cc4c306b19 (re) + 4 253 69 ..... 4 2ee31f665a86 96155394af80 92cc4c306b19 (re) revision 1 $ hg manifest --debug 1 79d7492df40aa0fa093ec4209be78043c181f094 644 a 2ed2a3912a0b24502043eae84ee4b279c18b90dd 644 b revision 2 $ hg manifest --debug 2 2ed2a3912a0b24502043eae84ee4b279c18b90dd 644 a diff --git a/tests/test-ssh-bundle1.t b/tests/test-ssh-bundle1.t --- a/tests/test-ssh-bundle1.t +++ b/tests/test-ssh-bundle1.t @@ -55,18 +55,18 @@ non-existent absolute path remote: abort: repository /$TESTTMP/nonexistent not found! abort: no suitable response from remote hg! [255] clone remote via stream $ hg clone -e "python \"$TESTDIR/dummyssh\"" --uncompressed ssh://user@dummy/remote local-stream streaming all changes - 4 files to transfer, 615 bytes of data - transferred 615 bytes in * seconds (*) (glob) + 4 files to transfer, 602 bytes of data + transferred 602 bytes in * seconds (*) (glob) searching for changes no changes found updating to branch default 2 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd local-stream $ hg verify checking changesets checking manifests @@ -77,18 +77,18 @@ clone remote via stream default 0:1160648e36ce $ cd .. clone bookmarks via stream $ hg -R local-stream book mybook $ hg clone -e "python \"$TESTDIR/dummyssh\"" --uncompressed ssh://user@dummy/local-stream stream2 streaming all changes - 4 files to transfer, 615 bytes of data - transferred 615 bytes in * seconds (*) (glob) + 4 files to transfer, 602 bytes of data + transferred 602 bytes in * seconds (*) (glob) searching for changes no changes found updating to branch default 2 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd stream2 $ hg book mybook 0:1160648e36ce $ cd .. diff --git a/tests/test-ssh.t b/tests/test-ssh.t --- a/tests/test-ssh.t +++ b/tests/test-ssh.t @@ -49,18 +49,18 @@ non-existent absolute path remote: abort: repository $TESTTMP/nonexistent not found! abort: no suitable response from remote hg! [255] clone remote via stream $ hg clone -e "python \"$TESTDIR/dummyssh\"" --uncompressed ssh://user@dummy/remote local-stream streaming all changes - 4 files to transfer, 615 bytes of data - transferred 615 bytes in * seconds (*) (glob) + 4 files to transfer, 602 bytes of data + transferred 602 bytes in * seconds (*) (glob) searching for changes no changes found updating to branch default 2 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd local-stream $ hg verify checking changesets checking manifests @@ -71,18 +71,18 @@ clone remote via stream default 0:1160648e36ce $ cd .. clone bookmarks via stream $ hg -R local-stream book mybook $ hg clone -e "python \"$TESTDIR/dummyssh\"" --uncompressed ssh://user@dummy/local-stream stream2 streaming all changes - 4 files to transfer, 615 bytes of data - transferred 615 bytes in * seconds (*) (glob) + 4 files to transfer, 602 bytes of data + transferred 602 bytes in * seconds (*) (glob) searching for changes no changes found updating to branch default 2 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd stream2 $ hg book mybook 0:1160648e36ce $ cd ..