Bug 5964 - Performance regression on pushing in 4.7
Summary: Performance regression on pushing in 4.7
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: unspecified
Hardware: PC Linux
: wish bug
Assignee: Bugzilla
URL:
Keywords: performance, perfregression
Depends on:
Blocks:
 
Reported: 2018-08-17 07:44 UTC by Boris Feld
Modified: 2018-08-27 00:00 UTC (History)
2 users (show)

See Also:
Python Version: ---


Attachments
Profile before the regression (10.81 KB, text/plain)
2018-08-17 08:20 UTC, Boris Feld
Details
Profile after the regression (4.18 KB, text/plain)
2018-08-17 08:20 UTC, Boris Feld
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Boris Feld 2018-08-17 07:44 UTC
We identified a performance regression in 4.7 concerning the push command.

Here is a reproduction script and output when trying to push the pypy repository to a copy of it locally:

    $ hg --version; and python -m perf command bash -c "HGRCPATH= /home/lothiraldan/.virtualenvs/mercurial/bin/hg push -R pypy-2017 pypy-2017-copy/ || exit 0"
    Mercurial Distributed SCM (version 4.6.2)
    (see https://mercurial-scm.org for more information)

    Copyright (C) 2005-2018 Matt Mackall and others
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    .....................
    command: Mean +- std dev: 248 ms +- 7 ms
    $ hg --version; and python -m perf command bash -c "HGRCPATH= /home/lothiraldan/.virtualenvs/mercurial/bin/hg push -R pypy-2017 pypy-2017-copy/ || exit 0"
    Mercurial Distributed SCM (version 4.7)
    (see https://mercurial-scm.org for more information)

    Copyright (C) 2005-2018 Matt Mackall and others
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    .....................
    command: Mean +- std dev: 1.79 sec +- 0.01 sec
    $ hg --version; and python -m perf command bash -c "HGRCPATH= /home/lothiraldan/.virtualenvs/mercurial/bin/hg push -R pypy-2017 pypy-2017-copy/ || exit 0"
    Mercurial Distributed SCM (version 4.7+370-06baaf43c959)
    (see https://mercurial-scm.org for more information)

    Copyright (C) 2005-2018 Matt Mackall and others
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    .....................
    command: Mean +- std dev: 1.79 sec +- 0.03 sec

Our performance suite initially identified the regression: http://perf.octobus.net/#regressions?sort=3&dir=desc&branch=stable

We are working on pinpointing the issue and will update the issue with more information as soon as we have them.
Comment 1 Boris Feld 2018-08-17 08:15 UTC
The changeset that seems to have introduced the regression is: https://www.mercurial-scm.org/repo/hg/rev/88efb7d6bcb6

I've validated locally:

    $ hg --version; and python -m perf command bash -c "HGRCPATH= /home/lothiraldan/.virtualenvs/mercurial/bin/hg push -R pypy-2017 pypy-2017-copy/ || exit 0"
    Mercurial Distributed SCM (version 4.6.2+802-88efb7d6bcb6)
    (see https://mercurial-scm.org for more information)

    Copyright (C) 2005-2018 Matt Mackall and others
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    .....................
    command: Mean +- std dev: 1.74 sec +- 0.01 sec
    $ hg --version; and python -m perf command bash -c "HGRCPATH= /home/lothiraldan/.virtualenvs/mercurial/bin/hg push -R pypy-2017 pypy-2017-copy/ || exit 0"
    Mercurial Distributed SCM (version 4.6.2+801-8eeed92475d5)
    (see https://mercurial-scm.org for more information)

    Copyright (C) 2005-2018 Matt Mackall and others
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    .....................
    command: Mean +- std dev: 247 ms +- 5 ms

I'm working on having profile output for these two changesets.
Comment 2 Boris Feld 2018-08-17 08:20 UTC
Created attachment 2015 [details]
Profile before the regression
Comment 3 Boris Feld 2018-08-17 08:20 UTC
Created attachment 2016 [details]
Profile after the regression
Comment 4 Pulkit Goyal 2018-08-17 08:35 UTC
I timed `hg push` on our internal repo with no outgoing changes, and 4.7 is definitely very slow in comparison to 4.6.2. I can confirm the regression is there.
Comment 5 HG Bot 2018-08-17 21:40 UTC
Fixed by https://mercurial-scm.org/repo/hg/rev/c89e2fb207a1
Boris Feld <boris.feld@octobus.net>
remotephase: fast path newheads computation in simple case (issue5964)

Changeset 88efb7d6bcb6 fixed the logic of `phases.newheads` but greatly
regressed its performance (up to many order of magnitude). The first step to
fix the regression is to exit early when there is no work to do. If there are
no heads to filter or not roots to filter them, we don't have to do any work.

This fixes the regression when talking to an all public changeset. The
performance is even better than before.

pypy, compared to an all public repo
------------------------------------

8eeed92475d5: 0.005758 seconds
88efb7d6bcb6: 0.602517 seconds (x104)
this code:    0.001508 seconds (-74% from base)

mercurial compared to an all public repo
----------------------------------------

8eeed92475d5: 0.000577 seconds
88efb7d6bcb6: 0.185316 seconds (x321)
this code:    0.000150 seconds (-74% from base)

The performance of newheads, when actual computations are required, is fixed
in the next changeset.

(please test the fix)
Comment 6 HG Bot 2018-08-19 21:46 UTC
Fixed by https://mercurial-scm.org/repo/hg/rev/f736fdbe546a
Boris Feld <boris.feld@octobus.net>
remotephase: avoid full changelog iteration (issue5964)

Changeset 88efb7d6bcb6 introduced a performance regression by triggering a
full ancestors walk.

This changeset reworks this logic so that we no longer walk down the full
changelog. The motivation for 88efb7d6bcb6, issue5939, is still fixed.

mercurial compared to a draft repository
----------------------------------------

8eeed92475d5: 0.012637 seconds
88efb7d6bcb6: 0.202699 seconds (x16)
46da52f4b820: 0.215551 seconds (+6%)
this code:    0.008397 seconds (-33% from base)

The payload size reduction we see in `test-bookmarks-pushpull.t` comes from a
more aggressive filter of nullid and is harmless.

(please test the fix)
Comment 7 Bugzilla 2018-08-27 00:00 UTC
Bug was set to TESTING for 7 days, resolving