Sat, 24 Apr 2021 16:30:05 +0200 repoview: separate concerns in _filteredrepotypes comment stable
Georges Racinet <georges.racinet@octobus.net> [Sat, 24 Apr 2021 16:30:05 +0200] rev 47011
repoview: separate concerns in _filteredrepotypes comment The cited issue in Python bugtracker is closed, but hasn't been fixed. We've been able to use the attached example and reproduce it with Python 3.9. The point where it turns from needless stress on the GC to the an actual leak is when one factors in the fact that the GC was before Python 3.4 unable to collect some types (see PEP 442). Note that even with Python 2.7, the simple example of cycles due to __mro__ are collectable. This was seen again with the example attached on the CPython issue.
Fri, 23 Apr 2021 18:30:53 +0200 repoview: fix memory leak of filtered repo classes stable
Georges Racinet <georges.racinet@octobus.net> [Fri, 23 Apr 2021 18:30:53 +0200] rev 47010
repoview: fix memory leak of filtered repo classes The leak occurs in long-running server processes with extensions, and is measured at 110kB per request. Before this change, the contents of the `_filteredrepotypes` cache are not properly garbage collected, despite it begin a `WeakKeyDictionary`. Extensions have a tendency to generate a new repository class for each `localrepo` instantiation. Server processes based on `hgwebdir_mod` will instantiate a new `localrepo` for each HTTP request that involves a repository. As a result, with a testing process that repeatedly opens a repository with several extensions activated (`topic` notably among them), we see a steady increase in resident memory of 110kB per repository instantiation before this change. This is also true, if we call `gc.collect()` at each instantiation, like `hgwebdir_mod` does, or not. The cause of the leak is that the *values* aren't weak references. This change uses `weakref.ref` for the values, and this makes in our measurements the resident size increase drop to 5kB per repository instantiation, with no explicit call of `gc.collect()` at all. There is currently no reason to believe that this remaining leak of 5kB is related to or even due to Mercurial core. We've also seen evidence that `ui.ui` instances weren't properly garbage collected before the change (with the change, they are). This could explain why the figures are relatively high. In theory, the collection of weak references could lead to much more misses in the cache, so we measured the impact on the original case that was motivation for introducing that cache in 7e89bd0cfb86 (see also issue5043): `hg convert` of the mozilla-central repository. The bad news here is that there is a major memory leak there, both with and without the present changeset. There were no more cache misses, and we could see no more memory leak with this change: the resident size after importing roughly 100000 changesets was at 12.4GB before, and 12.5GB after. The small increase is mentioned for completeness only, and we believe that it should be ignored, at least as long as the main leak isn't fixed. At less than 1% of the main leak, even finding out whether it is merely noise would be wasteful. Original context where this was spotted and first mitigated: https://foss.heptapod.net/heptapod/heptapod/-/issues/466 The leak reduction was also obtained in Heptapod inner HTTP server, which amounts to the same as `hgwebdir_mod` for these questions. The measurements done with Python 3.9, similar figures seen with 3.8. More work on our side would be needed to give measurements with 2.7, because of testing server process does not support it.
Sat, 24 Apr 2021 15:46:39 +0200 repoview: style change in newtype() cache handling stable
Georges Racinet <georges.racinet@octobus.net> [Sat, 24 Apr 2021 15:46:39 +0200] rev 47009
repoview: style change in newtype() cache handling This way of writing it does not change the logic at all, but is more fit for the change we want to make in the next changeset. If anything, that's one dict lookup less in the hot path, but that should be non measurable.
Thu, 22 Apr 2021 02:57:30 +0200 tests: don't hard-code /bin/bash stable
Joerg Sonnenberger <joerg@bec.de> [Thu, 22 Apr 2021 02:57:30 +0200] rev 47008
tests: don't hard-code /bin/bash From Thomas Klausner in pkgsrc. Differential Revision: https://phab.mercurial-scm.org/D10507
Wed, 21 Apr 2021 17:59:14 +0200 lint: fix failing code check stable
Raphaël Gomès <rgomes@octobus.net> [Wed, 21 Apr 2021 17:59:14 +0200] rev 47007
lint: fix failing code check 8d2b62d716b0 introduced code that `test-check-code.t` wasn't happy about, this fixes it. Differential Revision: https://phab.mercurial-scm.org/D10506
Wed, 14 Apr 2021 09:49:36 -0400 typing: enable pytype processing on mercurial/upgrade_utils/actions.py stable
Matt Harbison <matt_harbison@yahoo.com> [Wed, 14 Apr 2021 09:49:36 -0400] rev 47006
typing: enable pytype processing on mercurial/upgrade_utils/actions.py This was the suggested workaround for the pytype bug that caused this file to be processed forever. Differential Revision: https://phab.mercurial-scm.org/D10460
Sun, 18 Apr 2021 00:56:09 -0400 incoming: use bytes for an error message stable
Matt Harbison <matt_harbison@yahoo.com> [Sun, 18 Apr 2021 00:56:09 -0400] rev 47005
incoming: use bytes for an error message Caught by pytype. Differential Revision: https://phab.mercurial-scm.org/D10461
(0) -30000 -10000 -3000 -1000 -300 -100 -30 -10 -7 +7 +10 +30 +100 +300 +1000 +3000 tip