Patchwork annotate: discard refcount of discarded annotation for memory efficiency

login
register
mail settings
Submitter Katsunori FUJIWARA
Date April 18, 2013, 10:53 a.m.
Message ID <62a35a09bae098a022f8.1366282405@juju>
Download mbox | patch
Permalink /patch/1407/
State Accepted, archived
Headers show

Comments

Katsunori FUJIWARA - April 18, 2013, 10:53 a.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1366282204 -32400
# Node ID 62a35a09bae098a022f865d54cfdb04be168626c
# Parent  7d31f2e42a8afb54c8fae87e8e3e29a63578aea4
annotate: discard refcount of discarded annotation for memory efficiency

Before this patch, refcount (managed in "needed") of the annotation
result is kept as 1, even if corresponding annotation result is
discarded from "hist", because it isn't decreased and discarded.

In the history tree including merging revision, the most recent common
ancestor of merged revisions is scanned twice. Refcount of such
ancestor never becomes 0, because refcount is started from 1 at the
second scanning.

This prevents annotation results of merging revision in "hist" from
being discarded, and decreases memory efficiency.

This patch discards refcount of the annotation result, when the
corresponding annotation is discarded from "hist".
Matt Mackall - April 18, 2013, 10:40 p.m.
On Thu, 2013-04-18 at 19:53 +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> # Date 1366282204 -32400
> # Node ID 62a35a09bae098a022f865d54cfdb04be168626c
> # Parent  7d31f2e42a8afb54c8fae87e8e3e29a63578aea4
> annotate: discard refcount of discarded annotation for memory efficiency

Queued for default, thanks.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -713,6 +713,7 @@ 
                         curr = pair(hist[p], curr)
                     if needed[p] == 1:
                         del hist[p]
+                        del needed[p]
                     else:
                         needed[p] -= 1