Mercurial > public > mercurial-scm > hg
comparison mercurial/revlogutils/rewrite.py @ 52163:7346f93be7a4
revlog: add the glue to use the Rust `InnerRevlog` from Python
The performance of this has been looked at for quite some time, and some
workflows are actually quite a bit faster than with the Python + C code.
However, we are still (up to 20%) slower in some crucial places like cloning
certain repos, log, cat, which makes this an incomplete rewrite. This is
mostly due to the high amount of overhead in Python <-> Rust FFI, especially
around the VFS code. A future patch series will rewrite the VFS code in
pure Rust, which should hopefully get us up to par with current perfomance,
if not better in all important cases.
This is a "save state" of sorts, as this is a ton of code, and I don't want
to pile up even more things in a single review.
Continuing to try to match the current performance will take an extremely
long time, if it's not impossible, without the aforementioned VFS work.
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Wed, 19 Jun 2024 19:10:49 +0200 |
parents | 6223892833db |
children | f066fc0bdc7a |
comparison
equal
deleted
inserted
replaced
52162:13815c9decd4 | 52163:7346f93be7a4 |
---|---|
134 else: | 134 else: |
135 assert not rl._inline | 135 assert not rl._inline |
136 rl.opener.rename(newrl._datafile, rl._datafile) | 136 rl.opener.rename(newrl._datafile, rl._datafile) |
137 | 137 |
138 rl.clearcaches() | 138 rl.clearcaches() |
139 chunk_cache = rl._loadindex() | 139 index, chunk_cache = rl._loadindex() |
140 rl._load_inner(chunk_cache) | 140 rl._load_inner(index, chunk_cache) |
141 | 141 |
142 | 142 |
143 def v2_censor(revlog, tr, censor_nodes, tombstone=b''): | 143 def v2_censor(revlog, tr, censor_nodes, tombstone=b''): |
144 """censors a revision in a "version 2" revlog""" | 144 """censors a revision in a "version 2" revlog""" |
145 assert revlog._format_version != REVLOGV0, revlog._format_version | 145 assert revlog._format_version != REVLOGV0, revlog._format_version |
325 docket.data_end = data_cutoff | 325 docket.data_end = data_cutoff |
326 docket.sidedata_end = sidedata_cutoff | 326 docket.sidedata_end = sidedata_cutoff |
327 | 327 |
328 # reload the revlog internal information | 328 # reload the revlog internal information |
329 revlog.clearcaches() | 329 revlog.clearcaches() |
330 revlog._loadindex(docket=docket) | 330 index, chunk_cache = revlog._loadindex(docket=docket) |
331 revlog._load_inner(index, chunk_cache) | |
331 | 332 |
332 @contextlib.contextmanager | 333 @contextlib.contextmanager |
333 def all_files_opener(): | 334 def all_files_opener(): |
334 # hide opening in an helper function to please check-code, black | 335 # hide opening in an helper function to please check-code, black |
335 # and various python version at the same time | 336 # and various python version at the same time |
567 _write_swapped_parents(repo, rl, rev, offset, fp) | 568 _write_swapped_parents(repo, rl, rev, offset, fp) |
568 ui.write(repaired_msg % (rev, index_file)) | 569 ui.write(repaired_msg % (rev, index_file)) |
569 | 570 |
570 rl.opener.rename(new_file_path, index_file) | 571 rl.opener.rename(new_file_path, index_file) |
571 rl.clearcaches() | 572 rl.clearcaches() |
572 rl._loadindex() | 573 index, chunk_cache = rl._loadindex() |
574 rl._load_inner(index, chunk_cache) | |
573 finally: | 575 finally: |
574 util.tryunlink(new_file_path) | 576 util.tryunlink(new_file_path) |
575 | 577 |
576 | 578 |
577 def _is_revision_affected(fl, filerev, metadata_cache=None): | 579 def _is_revision_affected(fl, filerev, metadata_cache=None): |