D808: config: use copy-on-write to improve copy performance
quark (Jun Wu)
phabricator at mercurial-scm.org
Mon Sep 25 19:47:42 EDT 2017
quark added inline comments.
INLINE COMMENTS
> mbthomas wrote in util.py:602
> Using a boolean means both sides have to copy when they each write - the original dict becomes frozen and can't be re-used. If we use a count of outstanding copies instead, the last copy can just be used as-is when the count goes to 0.
>
> I don't know how much modification of the original occurs after copy, so maybe this isn't important.
Doing refcount adds 10% overhead for `ui.copy()` benchmark. I guess it's fine. If we really care about it, we can use a native `cow` class.
> mbthomas wrote in util.py:633
> Any way we can check/enforce this? I'm guessing not without impacting perf.
I think we want performance here. If it becomes a concern, we can add extra checks if `devel.something` is set.
Side note: having a native class in inheritance hierarchy is important for CPython performance according to what I learned. I thought `pure_obj.__contains__ = native_obj.__contains__` may have a reasonable perf, but the former is about 4x slower. So `class pure(native)` is preferred for perf (but probably not design pattern's point of view).
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D808
To: quark, #hg-reviewers, mbthomas
Cc: mbthomas, mercurial-devel
More information about the Mercurial-devel
mailing list