Page MenuHomePhabricator

repo: avoid copying/updating a dict on every `repo.__getitem__`
ClosedPublic

Authored by spectral on Tue, Sep 15, 6:48 PM.

Details

Summary

This has some mild performance benefits. I'm looking into a pathological case
where one of our hg log invocations takes several seconds, and according to
hyperfine this reduces the wall time of the entire operation (running in chg)
from:

Time (mean ± σ):      7.390 s ±  0.106 s    [User: 7.058 s, System: 0.271 s]

Range (min … max):    7.300 s …  7.625 s

to:

Time (mean ± σ):      7.046 s ±  0.091 s    [User: 6.714 s, System: 0.279 s]

Range (min … max):    6.916 s …  7.169 s

Note: the log command is slow due to an issue in our custom stuff executing
repo[<arg>] 298,800 times. This performance improvement is likely not
noticeable during normal operation, but I don't feel like it's making the code
more difficult to understand, and every small bit helps.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.