Patchwork [06,of,14] sparse-revlog: stop using a heap to track selected gap

login
register
mail settings
Submitter Boris Feld
Date Nov. 12, 2018, 9:55 a.m.
Message ID <ddafb271512fc26de60d.1542016541@localhost.localdomain>
Download mbox | patch
Permalink /patch/36514/
State Accepted
Headers show

Comments

Boris Feld - Nov. 12, 2018, 9:55 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1541689636 -3600
#      Thu Nov 08 16:07:16 2018 +0100
# Node ID ddafb271512fc26de60da5dceffc1509bb023d66
# Parent  8ebe5520cc4ae87f6fccba20897d292489a651db
# EXP-Topic sparse-perf
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r ddafb271512f
sparse-revlog: stop using a heap to track selected gap

Same logic as for 'gapsheap', we don't actually need a heap.
Yuya Nishihara - Nov. 13, 2018, 12:28 p.m.
On Mon, 12 Nov 2018 10:55:41 +0100, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1541689636 -3600
> #      Thu Nov 08 16:07:16 2018 +0100
> # Node ID ddafb271512fc26de60da5dceffc1509bb023d66
> # Parent  8ebe5520cc4ae87f6fccba20897d292489a651db
> # EXP-Topic sparse-perf
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r ddafb271512f
> sparse-revlog: stop using a heap to track selected gap

Queued up to this patch, thanks.

Patch

diff --git a/mercurial/revlogutils/deltas.py b/mercurial/revlogutils/deltas.py
--- a/mercurial/revlogutils/deltas.py
+++ b/mercurial/revlogutils/deltas.py
@@ -10,7 +10,6 @@ 
 from __future__ import absolute_import
 
 import collections
-import heapq
 import struct
 
 # import stuff from node for others to import from revlog
@@ -296,12 +295,11 @@  def _slicechunktodensity(revlog, revs, t
     gaps.sort()
 
     # Collect the indices of the largest holes until the density is acceptable
-    indicesheap = []
-    heapq.heapify(indicesheap)
+    selected = []
     while gaps and density < targetdensity:
         gapsize, gapidx = gaps.pop()
 
-        heapq.heappush(indicesheap, gapidx)
+        selected.append(gapidx)
 
         # the gap sizes are stored as negatives to be sorted decreasingly
         # by the heap
@@ -310,11 +308,11 @@  def _slicechunktodensity(revlog, revs, t
             density = chainpayload / float(readdata)
         else:
             density = 1.0
+    selected.sort()
 
     # Cut the revs at collected indices
     previdx = 0
-    while indicesheap:
-        idx = heapq.heappop(indicesheap)
+    for idx in selected:
 
         chunk = _trimchunk(revlog, revs, previdx, idx)
         if chunk: