( )⚙ D10362 dirstate-tree: Make Rust DirstateMap bindings go through a trait object

This is an archive of the discontinued Mercurial Phabricator instance.

dirstate-tree: Make Rust DirstateMap bindings go through a trait object
ClosedPublic

Authored by SimonSapin on Apr 12 2021, 8:23 AM.

Details

Summary

This changeset starts a series that adds an experiment to make status faster
by changing the dirstate (first only in memory and later also on disk) to
be shaped as a tree matching the directory structure, instead of the current
flat collection of entries. The status algorithm can then traverse this tree
dirstate at the same time as it traverses the filesystem.

We (Octobus) have made prototypes that show promising results but are prone
to bitrot. We would like to start upstreaming some experimental Rust code that
goes in this direction, but to avoid disrupting users it should only be
enabled by some run-time opt-in while keeping the existing dirstate structure
and status algorithm as-is.

The DirstateMap type and status function look like the appropriate
boundary. This adds a new trait that abstracts everything Python bindings need
and makes those bindings go through a dyn trait object. Later we’ll have two
implementations of this trait, and the same bindings can use either.

Diff Detail

Repository
rHG Mercurial
Branch
default
Lint
No Linters Available
Unit
No Unit Test Coverage

Event Timeline

SimonSapin created this revision.Apr 12 2021, 8:23 AM

This introduce an abstraction in order to have a second, opt-in implementation of it where we can experiment without affecting most users. However the abstraction itself may have some cost: this changeset introduces some additional boxing and dynamic dispatch, even in the default case (with Rust enabled).

Fortunately the performance impact turns out to be negligible in this case. Below are the wall clock durations in seconds to run hg status and hg status -mard on various repositories, four times each, with hg changeset d80b2bf99010 (this patch) and 51841b23670b (its parent).

51841b23670b default/ − typing: make minor adjustments to mercurial/util.py to pass pytype checking
d80b2bf99010 default/dirstate-tree − dirstate-tree: Make Rust DirstateMap bindings go through a trait object

hg status

mozilla-clean 51841b23670b 0.565 0.570 0.566 0.568
mozilla-clean d80b2bf99010 0.568 0.568 0.566 0.567
mozilla-dirty 51841b23670b 0.655 0.649 0.654 0.653
mozilla-dirty d80b2bf99010 0.653 0.652 0.653 0.659
mozilla-ignored 51841b23670b 0.567 0.563 0.569 0.564
mozilla-ignored d80b2bf99010 0.567 0.567 0.568 0.570
mozilla-unknowns 51841b23670b 0.687 0.654 0.652 0.654
mozilla-unknowns d80b2bf99010 0.655 0.653 0.652 0.670
netbeans-clean 51841b23670b 0.342 0.342 0.342 0.346
netbeans-clean d80b2bf99010 0.344 0.343 0.341 0.342
netbeans-dirty 51841b23670b 0.671 0.395 0.396 0.396
netbeans-dirty d80b2bf99010 0.395 0.395 0.395 0.394
netbeans-ignored 51841b23670b 0.393 0.351 0.350 0.350
netbeans-ignored d80b2bf99010 0.349 0.349 0.348 0.348
netbeans-unknowns 51841b23670b 0.388 0.387 0.386 0.387
netbeans-unknowns d80b2bf99010 0.389 0.388 0.386 0.388

hg status -mard

mozilla-clean 51841b23670b 0.322 0.322 0.321 0.320
mozilla-clean d80b2bf99010 0.322 0.320 0.321 0.322
mozilla-dirty 51841b23670b 0.321 0.322 0.322 0.323
mozilla-dirty d80b2bf99010 0.322 0.322 0.327 0.322
mozilla-ignored 51841b23670b 0.321 0.320 0.320 0.322
mozilla-ignored d80b2bf99010 0.320 0.322 0.322 0.324
mozilla-unknowns 51841b23670b 0.322 0.323 0.323 0.324
mozilla-unknowns d80b2bf99010 0.324 0.324 0.324 0.323
netbeans-clean 51841b23670b 0.216 0.217 0.218 0.217
netbeans-clean d80b2bf99010 0.216 0.217 0.217 0.218
netbeans-dirty 51841b23670b 0.216 0.217 0.216 0.218
netbeans-dirty d80b2bf99010 0.216 0.216 0.217 0.218
netbeans-ignored 51841b23670b 0.217 0.216 0.216 0.216
netbeans-ignored d80b2bf99010 0.216 0.216 0.215 0.216
netbeans-unknowns 51841b23670b 0.215 0.215 0.216 0.215
netbeans-unknowns d80b2bf99010 0.215 0.216 0.215 0.216
Alphare accepted this revision.Apr 19 2021, 10:56 AM
Alphare added a subscriber: Alphare.

(I should put "wrote get_non_normal_other_parent_entries_panic" on my resume.)

baymax updated this revision to Diff 27046.Apr 19 2021, 11:02 AM

✅ refresh by Heptapod after a successful CI run (🐙 💚)

Alphare accepted this revision.Apr 20 2021, 10:23 AM
This revision was not accepted when it landed; it landed in state Needs Review.
This revision was automatically updated to reflect the committed changes.