.editorconfig
author Georges Racinet <georges.racinet@octobus.net>
Fri, 23 Apr 2021 18:30:53 +0200
branchstable
changeset 47010 76ae43d5b1db
parent 45392 c25efc468a49
permissions -rw-r--r--
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.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28793
d30fdd6d1bf7 mercurial: add editorconfig
Jun Wu <quark@fb.com>
parents:
diff changeset
     1
# See http://EditorConfig.org for the specification
d30fdd6d1bf7 mercurial: add editorconfig
Jun Wu <quark@fb.com>
parents:
diff changeset
     2
d30fdd6d1bf7 mercurial: add editorconfig
Jun Wu <quark@fb.com>
parents:
diff changeset
     3
root = true
d30fdd6d1bf7 mercurial: add editorconfig
Jun Wu <quark@fb.com>
parents:
diff changeset
     4
d30fdd6d1bf7 mercurial: add editorconfig
Jun Wu <quark@fb.com>
parents:
diff changeset
     5
[*.py]
d30fdd6d1bf7 mercurial: add editorconfig
Jun Wu <quark@fb.com>
parents:
diff changeset
     6
indent_size = 4
d30fdd6d1bf7 mercurial: add editorconfig
Jun Wu <quark@fb.com>
parents:
diff changeset
     7
indent_style = space
d30fdd6d1bf7 mercurial: add editorconfig
Jun Wu <quark@fb.com>
parents:
diff changeset
     8
trim_trailing_whitespace = true
45392
c25efc468a49 mercurial: force LF endings for *.py, *.{c,h} and *.t in .editorconfig
Matt Harbison <matt_harbison@yahoo.com>
parents: 38281
diff changeset
     9
end_of_line = lf
28793
d30fdd6d1bf7 mercurial: add editorconfig
Jun Wu <quark@fb.com>
parents:
diff changeset
    10
d30fdd6d1bf7 mercurial: add editorconfig
Jun Wu <quark@fb.com>
parents:
diff changeset
    11
[*.{c,h}]
d30fdd6d1bf7 mercurial: add editorconfig
Jun Wu <quark@fb.com>
parents:
diff changeset
    12
indent_size = 8
d30fdd6d1bf7 mercurial: add editorconfig
Jun Wu <quark@fb.com>
parents:
diff changeset
    13
indent_style = tab
d30fdd6d1bf7 mercurial: add editorconfig
Jun Wu <quark@fb.com>
parents:
diff changeset
    14
trim_trailing_whitespace = true
45392
c25efc468a49 mercurial: force LF endings for *.py, *.{c,h} and *.t in .editorconfig
Matt Harbison <matt_harbison@yahoo.com>
parents: 38281
diff changeset
    15
end_of_line = lf
38281
1d6066336d7b mercurial: add .t files to .editorconfig
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28793
diff changeset
    16
1d6066336d7b mercurial: add .t files to .editorconfig
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28793
diff changeset
    17
[*.t]
1d6066336d7b mercurial: add .t files to .editorconfig
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28793
diff changeset
    18
indent_size = 2
1d6066336d7b mercurial: add .t files to .editorconfig
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28793
diff changeset
    19
indent_style = space
1d6066336d7b mercurial: add .t files to .editorconfig
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28793
diff changeset
    20
trim_trailing_whitespace = false
45392
c25efc468a49 mercurial: force LF endings for *.py, *.{c,h} and *.t in .editorconfig
Matt Harbison <matt_harbison@yahoo.com>
parents: 38281
diff changeset
    21
end_of_line = lf