load_repo: avoid useless ui object copy
Found out while investigating heptapod#466 that actually the machinery behind `hg.repository` actually performs a copy on its own. Our copy was adding pressure on the Python memory system. This does not cure the memory leak, but it saves about 2MB of leak over 1000 requests, even though it doesn't change the fact that none of these ui instances are actually collected (seen through instrumentation not part of this changeset). From `localrepo.py` in Mercurial 5.6.1: ``` def makelocalrepository(baseui, path, intents=None): """Long docstring not cited here.""" ui = baseui.copy() # Prevent copying repo configuration. ui.copy = baseui.copy (...) ``` Note that this last line actually prevents `baseui` ( would be the copy we were creating) to be freed immediately. makelocalrepository in turn is called via this backtrace: ``` venv/lib64/python3.9/site-packages/mercurial/hg.py(221)repository() -> peer = _peerorrepo( venv/lib64/python3.9/site-packages/mercurial/hg.py(188)_peerorrepo() -> obj = _peerlookup(path).instance( venv/lib64/python3.9/site-packages/mercurial/localrepo.py(3214)instance() -> return makelocalrepository(ui, localpath, intents=intents) > venv/lib64/python3.9/site-packages/mercurial/localrepo.py(517)makelocalrepository() -> ui = baseui.copy() ```
parent
09d6901c
No related branches found
No related tags found
Please register or sign in to comment