Commit Graph

23782 Commits

Author SHA1 Message Date
Pierre-Yves David
2ee7c25abf setdiscovery: drop '_setupsample' usage in '_takequicksample'
For '_takefullsample' we can just retrieve the list of head directly and
ignore the rest of the complex return values. This was the last call to the
infamous '_updatesample' function.
2015-01-06 17:07:44 -08:00
Pierre-Yves David
c05e3eea5d setdiscovery: drop the 'always' argument to '_updatesample'
This argument exists because of the complex code flow in '_takequicksample'. It
first gets the list of heads and then calls '_updatesample' on an empty initial
sample and a size limit matching the differences between the number of heads and
the target sample size. Finally the heads and the sample from '_updatesample'
were added. To ensure this addition result had the exact target length, the code
had to ensure no elements from the heads were added to the '_updatesample'
content and therefore was passing this "always included set of heads".

Instead we can just update the initial heads sample directly and use the final
target size as target size for the update.

This removes the need for this 'always' parameter to the '_updatesample' function

The test are affected because different set building order results in different
random sampling.
2015-01-07 10:32:17 -08:00
Pierre-Yves David
6ff053fa11 setdiscovery: always add exponential sample to the heads
As explained in a previous changeset, prioritizing heads too much behaves
pathologically when there are more heads than the sample size. To counter this,
we always inject exponential samples before reducing to the sample size limit.

This already show some benefit in the test themselves, but on a real-world example
this moves my discovery for push to pathologically headed repo from 45 rounds to
17 of them.

We should maybe ensure that at least 25% of the result sample is heads, but I
think the random sampling will be fine in practice.
2015-01-07 17:28:51 -08:00
Pierre-Yves David
60a9cd0334 setdiscovery: directly run '_updatesample'
The heads and exponential sample are going to end up in the same set
before any extra processing happens. We simplify the code by directly
updating a set with heads.

Changes in the order the set is built lead to small changes in the random
sampling output. But after double checking, I can confirm the input data to
the random sampling is consistent.
2015-01-07 17:23:21 -08:00
Pierre-Yves David
252ba1a3c3 setdiscovery: stop using '_setupsample' in '_takefullsample'
Very few of the return values of '_setupsample' remain in use, so we
directly retrieve the value we care about and drop the '_setupsample'
call.
2015-01-07 17:17:56 -08:00
Pierre-Yves David
e3605ecf1f setdiscovery: randomly pick between heads and sample when taking full sample
Before this changeset, the discovery protocol was too heads-centric. Heads of the
undiscovered set were always sent for discovery and any room remaining in the
sample were filled with exponential samples (and random ones if any room
remained).

This behaved extremely poorly when the number of heads exceeded the sample size,
because we keep just asking about the existence of heads, then their direct parent
and so on. As a result, the 'O(log(len(repo)))' discovery turns into a
'O(len(repo))' one. As a solution we take a random sample of the heads plus
exponential samples. This way we ensure some exponential sampling is achieved,
bringing back some logarithmic convergence of the discovery again.

This patch only applies this principle in one place. More places will be updated
in future patches.

One test is impacted because the random sample happen to be different. By
chance, it helps a bit in this case.
2015-01-07 12:09:51 -08:00
Pierre-Yves David
6141054495 setdiscovery: document the '_updatesample' function
This function is central in the sample building process, having it documented
help code readability a lot.
2015-01-06 17:02:32 -08:00
Pierre-Yves David
2fde36047b setdiscovery: avoid calling any sample building if the undecided set is small
If the length of undecided is smaller than the sample size, we can just request
information for all of them.

This conditional was previously handled by '_setupsample'. But '_setupsample' is
in my opinion a problematic function with blurry semantics. Having this
conditional explicitly earlier makes the code more explicit and moves us closer
to removing this '_setupsample' function.
2015-01-06 16:40:33 -08:00
Pierre-Yves David
ef881538c4 setdiscovery: delay sample building calls to gather them in a single place
Some of the logic around sample building is duplicated in the sample builders,
it would clean up thing to extract it in the top function, but this requires
all codes to be in the same place.

This changeset mostly exists to make the next one more clear.
2015-01-07 09:30:06 -08:00
Pierre-Yves David
ebee9c1c62 setdiscovery: drop unused 'initial' argument for '_takequicksample'
There is a single call site, and it is always using 'initial=True'. So we just drop
the argument and the associated condition.
2015-01-06 16:32:23 -08:00
Matt Mackall
efd707b6d7 readmarkers: add a SHA256 fixme note 2015-01-11 16:46:13 -06:00
Matt Mackall
1b1c572cac readmarkers: fast-path single successors and parents
This gives about a 5% performance bump.
2015-01-11 16:37:57 -06:00
Matt Mackall
aaefce821d readmarkers: promote global constants to locals for performance 2015-01-11 15:35:09 -06:00
Matt Mackall
5a2d46743d readmarkers: drop a temporary 2015-01-11 14:52:57 -06:00
Matt Mackall
f70b8899f1 readmarkers: read node reading into node length conditional
This removes some conditional assignments
2015-01-11 14:51:49 -06:00
Matt Mackall
fd24385ccc readmarkers: drop a temporary
Two other temporaries are renamed to fit line-length.
2015-01-11 14:46:55 -06:00
Matt Mackall
54920da7a8 readmarkers: hoist subtraction out of loop comparison 2015-01-11 14:44:57 -06:00
Matt Mackall
ccb9e25cca readmarkers: streamline offset tracking
This minimizes the number of assignments and operations needed to use offsets.
2015-01-11 14:43:31 -06:00
Matt Mackall
4cb9887cb8 readmarkers: use unpacker for fixed header 2015-01-11 14:37:50 -06:00
Matt Mackall
66bb59fd8e readmarkers: drop metadata temporary 2015-01-11 14:35:03 -06:00
Matt Mackall
eeecc7d717 readmarkers: drop date temporary 2015-01-11 14:33:49 -06:00
Matt Mackall
46c0e8872c readmarkers: drop another conditional 2015-01-11 14:32:56 -06:00
Matt Mackall
b42ed84f7a readmarkers: drop a conditional 2015-01-10 21:28:15 -06:00
Matt Mackall
aebd9ab379 readmarkers: add some whitespace 2015-01-10 21:27:29 -06:00
Matt Mackall
00030ac687 readmarkers: combine parent conditionals 2015-01-10 21:25:07 -06:00
Matt Mackall
57b821b575 readmarkers: drop temporary substring assignments
Assignments are expensive in inner loops
2015-01-10 21:24:45 -06:00
Matt Mackall
2537cb8fbf util: introduce unpacker
This allows taking advantage of Python 2.5+'s struct.Struct, which
provides a slightly faster unpack due to reusing formats. Sadly,
.unpack_from is significantly slower.
2015-01-10 21:18:31 -06:00
Matt Mackall
465be7563f perf: add a configurable sleep on startup
This is intended to counteract power management by giving a consistent
idle period before test runs.
2015-01-10 21:13:10 -06:00
Mads Kiilerich
61a36ea4fe revset: use localrepo revbranchcache for branch name filtering
Branch name filtering in revsets was expensive. For every rev it created a
changectx and called .branch() which retrieved the branch name from the
changelog.

Instead, use the revbranchcache.

The revbranchcache is used read-only. The revset implementation with generators
and callbacks makes it hard to figure out when we are done using/updating the
cache and could write it back. It would also be 'tricky' to lock the repo for
writing from within a revset execution. Finally, the branchmap update will
usually make sure that the cache is updated before any revset can be run.
The revbranchcache is used without any locking but is short-lived and used in a
tight loop where we can assume that the changelog doesn't change ... or where
it not is relevant to us if it does.

perfrevset 'branch(mobile)' on mozilla-central.
Before:
! wall 10.989637 comb 10.970000 user 10.940000 sys 0.030000 (best of 3)
After, no cache:
! wall 7.368656 comb 7.370000 user 7.360000 sys 0.010000 (best of 3)
After, with cache:
! wall 0.528098 comb 0.530000 user 0.530000 sys 0.000000 (best of 18)

The performance improvement even without cache come from being based on
branchinfo on the changelog instead of using ctx.branch().

Some tests are added to verify that the revbranchcache works and keep an eye on
when the cache files actually are updated.
2015-01-08 00:01:03 +01:00
Mads Kiilerich
835157e77d branchmap: use revbranchcache when updating branch map
The revbranchcache is read on demand before it will be used for updating the
branch map. It is written back when the branchmap is written and it will thus
use the same locking as branchmap. The revbranchcache instance is short-lived;
it is only stored in the branchmap from .update() is invoked and until .write()
is invoked. Branchmap already assume that the repo is locked in that case.

The use of revbranchcache for branch map updates will make sure that the
revbranchcache "always" is kept up-to-date.

The perfbranchmap benchmark is somewhat bogus, especially when we can see that
the caching makes a significant difference between the realistic case of a
first run and the rare case of rerunning it with a full cache. Here are some
'base' numbers on mozilla-central:
Before:
! wall 6.912745 comb 6.910000 user 6.840000 sys 0.070000 (best of 3)
After - initial, cache is empty:
! wall 7.792569 comb 7.790000 user 7.720000 sys 0.070000 (best of 3)
After - cache is full:
! wall 0.879688 comb 0.880000 user 0.870000 sys 0.010000 (best of 4)

The overhead when running with empty cache comes from checking, missing and
updating it every time.

Most of the performance improvement comes from not having to extract the branch
info from the changelog. The last doubling of performance comes from no longer
having to convert all branch names to local encoding but reuse the few already
converted branch names.

On the hg repo:
Before:
! wall 0.715703 comb 0.710000 user 0.710000 sys 0.000000 (best of 14)
After:
! wall 0.105489 comb 0.110000 user 0.110000 sys 0.000000 (best of 87)
2015-01-08 00:01:03 +01:00
Mads Kiilerich
1b3892318f branchcache: introduce revbranchcache for caching of revision branch names
It is expensive to retrieve the branch name of a revision. Very expensive when
creating a changectx and calling .branch() every time - slightly less when
using changelog.branchinfo().

Now, to speed things up, provide a way to cache the results on disk in an
efficient format. Each branchname is assigned a number, and for each revision
we store the number of the corresponding branch name. The branch names are
stored in a dedicated file which is strictly append only.

Branch names are usually reused across several revisions, and the total list of
branch names will thus be so small that it is feasible to read the whole set of
names before using the cache. It will however do that it might be more
efficient to use the changelog for retrieving the branch info for a single
revision.

The revision entries are stored in another file. This file is usually append
only, but if the repository has been modified, the file will be truncated and
the relevant parts rewritten on demand.

The entries for each revision are 8 bytes each, and the whole revision file
will thus be 1/8 of 00changelog.i.

Each revision entry contains the first 4 bytes of the corresponding node hash.
This is used as a check sum that always is verified before the entry is used.
That check is relatively expensive but it makes sure history modification is
detected and handled correctly. It will also detect and handle most revision
file corruptions.

This is just a cache. A new format can always be introduced if other
requirements or ideas make that seem like a good idea. Rebuilding the cache is
not really more expensive than it was to run for example 'hg log -b branchname'
before this cache was introduced.

This new method is still unused but promise to make some operations several
times faster once it actually is used.

Abandoning Python 2.4 would make it possible to implement this more efficiently
by using struct classes and pack_into. The Python code could probably also be
micro optimized or it could be implemented very efficiently in C where it would
be easy to control the data access.
2015-01-08 00:01:03 +01:00
Anton Shestakov
6fe7d43de3 hgweb: move archive entries outside of <li> in monoblue style
archiveentry already includes surrounding <li></li>, so putting archive entries
inside <li> element produced incorrect markup.
2015-01-09 22:53:38 +08:00
Anton Shestakov
8bdbccf3bf hgweb: add searchhint to templates/coal/map
coal style uses every template (except header.tmpl) directly from paper style,
but doesn't use paper/map file. Elements defined in such map files are used in
templates as you would expect. For example, paper/search.tmpl contains
'{searchhint}' and template engine replaces that with the actual hint. But when
coal style reuses paper/search.tmpl, it needs to define searchhint in its map
file as well, or template engine will not find it. So let's copy it from
paper/map to coal/map.

Before this change, if the coal style was selected, the hint for the search
field in page header was present, but it was completely empty. Although the
absence of searchhint in coal/map produced no error.
2015-01-09 15:24:55 +08:00
Gregory Szorc
73fa937531 cmdutil.jsonchangeset: properly compute added and removed files
jsonchangeset._show() was computing the reverse status of the current
changeset. As a result, added files were showing up as removed and
removed files were showing up as adds.

There were existing tests for this code and they were flat out wrong.
2015-01-05 22:18:55 -08:00
Yuya Nishihara
b67b0a75ea revset: drop pre-lazyset optimization for stringset of subset == entire repo
It was introduced at deb42ca4dd93, where spanset.__contains__() did not exist.
Nowadays, we have to pay huge penalty for len(subset).

The following example showed that OR operation could be O(n * m^2)
(n: len(repo), m: number of OR operators, m >= 2) probably because of
filteredset.__len__.

revset #0: 0|1|2|3|4|5|6|7|8|9
0) wall 8.092713 comb 8.090000 user 8.090000 sys 0.000000 (best of 3)
1) wall 0.445354 comb 0.450000 user 0.430000 sys 0.020000 (best of 22)
2) wall 0.000389 comb 0.000000 user 0.000000 sys 0.000000 (best of 7347)
(0: 3.2.4, 1: 3.1.2, 2: this patch)
2015-01-03 10:25:08 +09:00
Matt Harbison
b391094100 largefiles: properly sync lfdirstate after removing largefiles
The more aggressive synchronization of lfdirstate that was backed out in
4fe80f20ab06 masked the problem where lfdirstate would hold an 'R' for a
largefile that was added and then removed without a commit between.  We could
just conditionally call lfdirstate.drop() or lfdirstate.remove() here, but this
also properly updates lfdirstate if the standin doesn't exist for the file
somehow (i.e. call drop instead of remove).

Without this change, the precommit status in the commit command immediately
after the test change lists the removed (and never committed) largefile as 'R'.
It can also lead to situations where the status command reports the same, long
after the commit [1].

[1] http://www.selenic.com/pipermail/mercurial-devel/2015-January/065153.html
2015-01-04 15:26:26 -05:00
Matt Mackall
e50959fc84 Added signature for changeset 4fe80f20ab06 2015-01-01 16:30:11 -06:00
Mads Kiilerich
b438c7467e largefiles: backout d20af8be6a14 - linear updates handle m -> a differently
d20af8be6a14 introduced a significant performance regression: All largefiles
were marked 'normallookup' by linear (or noop) updates and had to be rehashed
by the next command.

The previous change introduced a different solution to the problem d20af8be6a14
solved and we can thus back it out again.
2014-12-31 14:46:03 +01:00
Mads Kiilerich
6cfab77588 largefiles: mark lfile as added in lfdirstate when the standin is added
This is an alternative solution to the problem addressed by d20af8be6a14. This
implementation has the advantage that it doesn't mark clean largefiles as
normallookup. We can thus avoid repeated rehashing of all largefiles when
d20af8be6a14 is backed out.

This implementation use the existing 'lfmr' actions that 4f7f7352d9d0
introduced for handling another part of the same cases.
2014-12-31 14:46:02 +01:00
Mads Kiilerich
d0a915efcf tests: add test coverage for lfdirstate invalidation of linear update
d20af8be6a14 introduced a significant performance regression: All largefiles
are marked 'normallookup' in lfdirstate by linear (or noop) updates and has to
be rehashed by the next command.

To avoid such regressions, keep an eye on the dirstate content after a plain
'hg up'.
2014-12-31 14:45:02 +01:00
Matt Harbison
efebc89ab9 largefiles: enable subrepo support for remove
Previously, remove failed when operating on a largefile in a subrepo, stating
that the file is untracked.
2014-12-30 21:12:52 -05:00
Pierre-Yves David
171c6e502b transplant: properly skip empty changeset (issue4423)
If resolving a merge conflict result in an empty changesets, we now properly
skip the changeset instead of crashing.

Original patch from Robert Collins <robertc@robertcollins.net>.
2015-01-08 21:36:12 -08:00
Mathias De Maré
1521d2118c color: add support for colorizing git subrepo diffs 2015-01-08 21:30:22 +01:00
Matt Harbison
5aac6fe79c tests: fix test-casefolding.t output
This change started with 59dfa285ee25.
2015-01-08 23:33:56 -05:00
Matt Mackall
bf17f56a67 sshpeer: more thorough shell quoting
This fixes an issue spotted by Jesse Hertz.
2014-12-29 14:27:02 -06:00
FUJIWARA Katsunori
ef3bad18bd i18n-ja: synchronized with 04d70d13ef9d 2014-12-29 15:59:56 +09:00
Wagner Bruna
1546a1d329 i18n-pt_BR: synchronized with 480699610f70 2014-12-26 17:21:08 -02:00
Augie Fackler
ffd2cf1dba demandimport: blacklist distutils.msvc9compiler (issue4475)
This module depends on _winreg, which is windows-only. Recent versions
of setuptools load distutils.msvc9compiler and expect it to
ImportError immediately when on non-Windows platforms, so we need to
let them do that. This breaks in an especially mystifying way, because
setuptools uses vars() on the imported module. We then throw an
exception, which vars doesn't pick up on well. For example:

In [3]: class wat(object):
   ...:     @property
   ...:     def __dict__(self):
   ...:         assert False
   ...:

In [4]: vars(wat())
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-2781ada5ffe6> in <module>()
----> 1 vars(wat())

TypeError: vars() argument must have __dict__ attribute

Which is similar to the problem we run into.
2014-12-22 17:27:31 -05:00
Matt Harbison
93382de245 largefiles: fix a spurious missing file warning with forget (issue4053)
If an uncommitted and deleted file was forgotten, a warning would be emitted,
even though the operation was successful.  See the previous patch for
'remove -A' for the exact circumstances, and details about the cause.
2014-12-21 15:06:54 -05:00
Matt Harbison
8edc086e01 largefiles: fix a spurious missing file warning with 'remove -A' (issue4053)
The bug report doesn't mention largefiles, but the given recipe doesn't fail
unless the largefiles extension is loaded.  The problem only affected normal
files, whether or not any largefiles are committed, and only files that have
not been committed yet.  (Files with an 'a' state are dropped from dirstate,
not marked removed.)  Further, if the named normal file never existed, the
warning would be printed out twice.

The problem is that the core implementation of remove() calls repo.status(),
which eventually triggers a dirstate.walk().  When the file isn't seen in the
filesystem during the walk, the exception handling finds the file in
dirstate, so it doesn't complain.  However, the largefiles implementation
called status() again with all of the original files (including the normal
ones, just dropped).  This time, the exception handler doesn't find the file
in dirstate and does complain.  This simply excludes the normal files from
the second repo.status() call, which the largefiles extension has no interest
is processing anyway.
2014-12-21 15:04:13 -05:00