mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 08:47:12 +03:00
bb461d2240
Summary: If there are too many heads, the current `descendants` algorithm would visit all "old" heads. For example, with this graph: head9999 (N9999) / Z (master) : : (many heads) :/ : head2 (N2) :/ C head1 (N1) |/ B head0 (N0) |/ A `A::head9999` or `Z::head9999` will visit N0, N1, ..., N9999, because `descendands_up_to` is provided with `max_id = N9999` and Z as a vertex in the master group, is before N0 in non-master. The current algorithm also means `descendands_up_to` gets linearly slower as the user uses the repo more, which is quite undesirable. This diff changes `descendands_up_to` to take an `ancestors` set, which is `::head9999` in this case, and iterate non-master flat segments in it. So it will skip N0 to N9998 directly by finding the N9999 flat segment and only use it. The number of heads will have a smaller impact on performance. Another slowness is `draft::draft_heads`, if there are too many `draft_heads`, the internal calculation of `::draft_heads` can be slow. Optimize it by limiting `draft_heads` to `draft:`. Practically this affects `y::` revset as `y::` is translated to `y::visible_heads` and `visible_heads` can be large. `cargo bench --bench dag_ops -- '::-master'` shows significant difference: Before: range (master::draft) 18.112 s range (recent_draft::drafts) 2.594 s After: range (master::draft) 72.542 ms range (recent_draft::drafts) 14.932 ms In my fbsource checkout there were 20k+ heads. The improvement of `master::recent_draft` (`x::y`) is pretty visible, and `y::` is also improved: % lhg debugbenchmarkrevsets -m -x 'p1(min(7e8c86ae % master))' -Y 'draft() & 7e8c86ae' -e 'x::y' -e 'y::' --no-default # x: 168f5228e570fb6b2ff7f851bd82413102748d84 (p1(min(7e8c86ae % master))) # y: 7e8c86aec68ebc6e0b8254afcb381315991fd21c (draft() & 7e8c86ae) # before | revset \ backend | segments | revlog | revlog-cpy | |------------------|----------|--------|------------| | x::y | 17ms | 0.1ms | 0.5ms | | y:: | 3.3ms | 0.7ms | 1.3ms | # after | revset \ backend | segments | revlog | revlog-cpy | |------------------|----------|--------|------------| | x::y | 0.2ms | 0.1ms | 0.6ms | | y:: | 1.0ms | 0.7ms | 1.3ms | Reviewed By: sfilipco Differential Revision: D23214387 fbshipit-source-id: 4d11db84cd28f4e04e8b991cbc650c9d5781fd27 |
||
---|---|---|
.. | ||
contrib | ||
distutils_rust | ||
doc | ||
edenscm | ||
edenscmnative | ||
exec | ||
hgcache_size_logger | ||
i18n | ||
lib | ||
newdoc | ||
pystubs | ||
slides | ||
tests | ||
.editorconfig | ||
.flake8 | ||
.gitignore | ||
COPYING | ||
gen_version.py | ||
hgeditor | ||
Makefile | ||
README.rst | ||
setup3.py | ||
setup.py |
Mercurial ========= Mercurial is a fast, easy to use, distributed revision control tool for software developers. Basic install:: $ make # see install targets $ make install # do a system-wide install $ hg debuginstall # sanity-check setup $ hg # see help Running without installing:: $ make local # build for inplace usage $ ./hg --version # should show the latest version See https://mercurial-scm.org/ for detailed installation instructions, platform-specific notes, and Mercurial user information.