comparison mercurial/revlogutils/nodemap.py @ 44865:6493f0a567c2

nodemap: add a new mode option, with an optional "warn" value When "warn" is set, user will get notified when the slow code, used for compatibility is used. This can help people to detect situation were using that feature will give them a slowdown instead of a speedup. Differential Revision: https://phab.mercurial-scm.org/D8414
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 14 Apr 2020 02:45:05 +0200
parents b4537125eb3c
children 6b01799e9db0
comparison
equal deleted inserted replaced
44864:97ebdb192b00 44865:6493f0a567c2
10 10
11 import errno 11 import errno
12 import os 12 import os
13 import re 13 import re
14 import struct 14 import struct
15
16 from ..i18n import _
15 17
16 from .. import ( 18 from .. import (
17 error, 19 error,
18 node as nodemod, 20 node as nodemod,
19 util, 21 util,
103 pass 105 pass
104 106
105 def addabort(self, *args, **kwargs): 107 def addabort(self, *args, **kwargs):
106 pass 108 pass
107 109
110 def _report(self, *args):
111 pass
112
108 113
109 def update_persistent_nodemap(revlog): 114 def update_persistent_nodemap(revlog):
110 """update the persistent nodemap right now 115 """update the persistent nodemap right now
111 116
112 To be used for updating the nodemap on disk outside of a normal transaction 117 To be used for updating the nodemap on disk outside of a normal transaction
136 141
137 can_incremental = util.safehasattr(revlog.index, "nodemap_data_incremental") 142 can_incremental = util.safehasattr(revlog.index, "nodemap_data_incremental")
138 ondisk_docket = revlog._nodemap_docket 143 ondisk_docket = revlog._nodemap_docket
139 feed_data = util.safehasattr(revlog.index, "update_nodemap_data") 144 feed_data = util.safehasattr(revlog.index, "update_nodemap_data")
140 use_mmap = revlog.opener.options.get(b"exp-persistent-nodemap.mmap") 145 use_mmap = revlog.opener.options.get(b"exp-persistent-nodemap.mmap")
146 mode = revlog.opener.options.get(b"exp-persistent-nodemap.mode")
147 if not can_incremental:
148 msg = _(b"persistent nodemap in strict mode without efficient method")
149 if mode == b'warn':
150 tr._report(b"%s\n" % msg)
141 151
142 data = None 152 data = None
143 # first attemp an incremental update of the data 153 # first attemp an incremental update of the data
144 if can_incremental and ondisk_docket is not None: 154 if can_incremental and ondisk_docket is not None:
145 target_docket = revlog._nodemap_docket.copy() 155 target_docket = revlog._nodemap_docket.copy()