Commit Graph

3642 Commits

Author SHA1 Message Date
Mark Thomas
bf8616188d perftweaks: support treedirstate maps
Treedirstate maps won't have an inner _map, so will never be logged by
perftweaks.  The maps have an efficient size lookup, so it's OK to always
obtain their size.

Differential Revision: https://phab.mercurial-scm.org/D1410
2017-11-28 04:51:38 -08:00
Mark Thomas
6f77bc33b9 treedirstate: implement casefolding maps for case insensitive filesystems
The dirfoldmap and filefoldmap on the dirstatemap object map from normalized
filename to the form it appears in the dirstate (denormalized form).

The dicts these functions return are also modified by the dirstate with
filenames discovered by examining the disk, so use an overlay dictionary backed
by the real dirstate to allow this to happen.

Differential Revision: https://phab.mercurial-scm.org/D1409
2017-11-28 04:51:38 -08:00
Mark Thomas
26e77a0173 treedirstate: use vlqencoding for numbers
Change to use VLQ-encoded numbers for everything in the tree file.  Block sizes
remain as u32s so that they can be read by the store in a single read
operation, but everything else is a VLQ as it is generally smaller and more
futureproof.

Differential Revision: https://phab.mercurial-scm.org/D1408
2017-11-28 04:51:38 -08:00
Mark Thomas
dc03a8d3da treedirstate: auto-repack treedirstate once it reaches 3x its original size
Differential Revision: https://phab.mercurial-scm.org/D1407
2017-11-28 04:51:38 -08:00
Mark Thomas
9fc8a5ecf5 treedirstate: implement efficient case collision detection
Add a mechanism to the dirstate trees to allow lookups based on filtered views
of the keys.  For a given filtering function, this returns one (if any) of the
keys for which filter(key) matches the input.  The filtered values in each
directory node are cached to improve subsequent lookups.

Differential Revision: https://phab.mercurial-scm.org/D1406
2017-11-28 04:51:38 -08:00
Mark Thomas
437cacd205 treedirstate: allow absent non-normal sets
If the non-normal sets get particularly large, the dirstate root file can get
large again.  Avoid this happening by not storing large sets, and instead
recalculating them on-demand as needed.  Large sets of non-normal files should
be rare, so this shouldn't be a performance hit in the normal case.

Differential Revision: https://phab.mercurial-scm.org/D1405
2017-11-28 04:51:38 -08:00
Mark Thomas
d0a2fc313b treedirstate: clear ambiguous times when writing the dirstate
When writing out changes to the dirstate, mark any files that have the same
mtime as the current time as requiring lookup.  This matches the behaviour
of the C-based pack_dirstate.

Differential Revision: https://phab.mercurial-scm.org/D1404
2017-11-28 04:51:38 -08:00
Mark Thomas
842e5de551 treedirstate: better iteration using visitor pattern
In order to allow the python interface code to perform actions on each node in
the tree without creating python-specific interfaces in the generic Rust code,
add a method of iterating over the tree, executing a closure at each file.

Use this to implement the methods that give iterators over the filenames in the
tree.  This performs better than the get_first/get_next-style iterators.

Differential Revision: https://phab.mercurial-scm.org/D1403
2017-11-28 04:51:38 -08:00
Mark Thomas
71fa542789 treedirstate: cache dirstate data when iterating all files
Iterations over all files will cause most of the file to be read in a piecemeal
fashion.  This will be inefficient on disks with slow seek times.   Instead,
read the whole file into memory before iterating.

Differential Revision: https://phab.mercurial-scm.org/D1402
2017-11-28 04:51:38 -08:00
Mark Thomas
92b2ce7563 treedirstate: add Python linkage
Adds a python module that uses the Rust treedirstate to replace the dirstate
map.

Differential Revision: https://phab.mercurial-scm.org/D1401
2017-11-28 04:51:38 -08:00
Mark Thomas
b0b8543136 treedirstate: add Dirstate
A Dirstate object links a Tree to an underlying Store and StoreView
implementation.

Differential Revision: https://phab.mercurial-scm.org/D1400
2017-11-28 04:51:38 -08:00
Mark Thomas
7bc6c8d231 treedirstate: add Tree
Adds Tree, an implementation of a dirstate tree.

Differential Revision: https://phab.mercurial-scm.org/D1399
2017-11-28 04:51:38 -08:00
Mark Thomas
5294b5f050 treedirstate: add FileStore
Adds FileStore, an implementation of the Store and StoreView traits that uses a
file on disk to store the data, and reads and writes blocks using file I/O.

Differential Revision: https://phab.mercurial-scm.org/D1398
2017-11-28 04:51:38 -08:00
Mark Thomas
1537d3833e treedirstate: add Store and StoreView traits
These traits represent abstract store objects than can store arbitrary data
blocks with store-generated indexes.

A NullStore implementation is provided which acts an always-empty StoreView.

Differential Revision: https://phab.mercurial-scm.org/D1397
2017-11-28 04:51:38 -08:00
Mark Thomas
5931d6cf5d treedirstate: add vecmap implementation
This adds an implementation of an ordered map that uses a vector pairs, sorted
by the key.

This is largely compatibly with std::collections::BTreeMap, but has performance
characteristics more suited for use in treedirstate.

Differential Revision: https://phab.mercurial-scm.org/D1396
2017-11-28 04:51:38 -08:00
Mark Thomas
21b68a9e17 treedirstate: create empty Rust project
Create an empty Rust project for treedirstate.  This will be a
re-implementation of the dirstate map using a tree structure, where nodes in
the tree are directories, and leaves are files.

Differential Revision: https://phab.mercurial-scm.org/D1395
2017-11-28 04:51:38 -08:00
Mark Thomas
f2610526b0 tests: update githelp test
The githelp for apply was updated in D1522.  Update the tests to match.

Differential Revision: https://phab.mercurial-scm.org/D1529
2017-11-28 04:50:17 -08:00
Durham Goode
fce353c28d fastannotate: pass commitctx to filectx to prevent tree downloads
Previously fastannotate was creating filectx's by doing commitctx[path]. This
invokes logic that resovles the filenode immediately, which require loading the
manifest for that commit. In a repo where manifests are downloaded lazily, this
can result in a lot of time spent downloading manifests.

Since commands like hg blame -u only need the filectx so they can resolve the
commitctx for commit information, let's just pass the commitctx straight to the
filectx. It can later derive the filenode if it needs to.

Differential Revision: https://phab.mercurial-scm.org/D1488
2017-11-27 16:33:50 -08:00
Durham Goode
4467b77ca1 remotefilelog: avoid _fileid in remotefilelogctx
_fileid is only set in some cases. We should access the file node through
_filenode instead, which can compute the node from either the _fileid or the
_changeid. This will be useful in a future diff where we construct
remotefilelogctx with just a path and a commit hash, and not a file id.
2017-11-27 16:33:50 -08:00
Wojciech Lis
4a6289577f remotefilelog: keep metacache per thread
This fixes the race condition in remotefilelog surfaced by
https://phab.mercurial-scm.org/D1458. The issue was that the remotefilelog
contentstore had 1 object for caching metadata of a file which could be
ovewriten by other threads, resulting in trying to
deserialize a textfile as lfs.

This adds per thread cachefor metadata

Test Plan:
on CentOS ran rt in fb-hgext and all were sucessful

on Windows ran 500 iterations of sparse --enable-profile / --disable-profile with 43k files
profile without hitting any issues. This was >30 hours of continuous excercise
for this code.

Differential Revision: https://phab.mercurial-scm.org/D1513
2017-11-27 14:42:16 -08:00
Piotr Gabryjeluk
8d1350eab9 githelp: update suggestion for apply
Current:

$ hg githelp apply abc.diff
hg import abc.diff

Expected:

$ hg githelp apply abc.diff
hg import --no-commit abc.diff

git apply doesn't commit the applied diff, hg import (without the flag) does.

Differential Revision: https://phab.mercurial-scm.org/D1522
2017-11-27 11:40:57 -08:00
Durham Goode
bd4a9549cb treemanifest: automatically backfill missing manifests during hg pull
Previously, if a repo went from treeonly to not treeonly, the user had to run a
command to backfill the missing flat manifests. This patch makes it happen
automatically as part of hg pull.

Differential Revision: https://phab.mercurial-scm.org/D1485
2017-11-27 09:22:06 -08:00
Hollis Blanchard
f2c455130c p4fastimport: only disable LFS uploads if p4fastimport.lfsmetadata is set
Currently, normal LFS uploads are completely disabled during a p4fastimport,
and users must run an external SQLite-reading uploader app after the import.

Instead, allow normal LFS functionality to work, but users may override it to
do the SQLite thing.

Differential Revision: https://phab.mercurial-scm.org/D1307
2017-11-27 03:34:35 -08:00
Hollis Blanchard
4937529d4c tests: split p4fastimport-import-lfs.t into normal LFS vs SQLite
p4fastimport has the ability to bypass the normal LFS upload mechanisms, and
that's what the original testcase actually tested.

We also want to ensure that normal LFS works with p4fastimport too, so we need
a testcase for that.

Differential Revision: https://phab.mercurial-scm.org/D1306
2017-11-27 03:34:35 -08:00
Thomas Jacob
35c42f65ae fbamend: allow general rev for --to, fix aborts
Summary:
Didn't work when --to wasn't specified as a 12 char
short hash, and since no errors were raised
due to the missing "raise" before error.abort
also effectively deleted changes in the working copy.

Now should work with anything repo[input] accepts
as a valid commit.

Also checks for predicatable error conditions before
the repo is modified to avoid changing working copy
on error.

Test Plan: TBD

Reviewers: #sourcecontrol

Subscribers: #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D6379590

Tasks: T22281996
2017-11-25 09:19:09 -08:00
Mark Thomas
e40329b294 clindex: add prebuilt cython file
The build currently fails on systems without Cython.  Add a prebuilt cython
file for clindex to allow builds on those systems.

Differential Revision: https://phab.mercurial-scm.org/D1504
2017-11-24 02:20:54 -08:00
Jun Wu
ec352026f4 perftweaks: add missing imports
This unblocks the branchcache issue.
2017-11-23 11:39:46 -08:00
Jun Wu
1b97b622fb Backed out D1451 and D1495
In `branchmap.updatecache`, there is an assertion:

    assert partial.validfor(repo)

That will break if `partial` (branchcache) does not have correct tiprev or
tipnode.

The long term fix will be probably reviving D1450.
2017-11-23 10:46:31 -08:00
Adam Simpkins
0dcddbbc06 perftweaks: unbreak the branchcache code
Summary:
D1451 changed _branchmapupdate() so that it no longer updates self.filteredhash
when changing self.tiprev.  This causes branchcache.validfor() to report that
the cache is no longer valid, causing an assertion failure at the end of
updatecache().

Test Plan: Running hg commands no longer crash.

Reviewers: quark, durham, #fbhgext

Reviewed By: quark, #fbhgext

Differential Revision: https://phab.mercurial-scm.org/D1495
2017-11-22 22:31:23 -08:00
Kostia Balytskyi
e85582c7ce phabricator: fix lint warning
Summary: Fix lint.

Test Plan:
`test-check-code-hg.t` is now pasing
`test-check-config` is also passing

Reviewers: #fbhgext

Differential Revision: https://phab.mercurial-scm.org/D1491
2017-11-22 15:16:10 -08:00
Kostia Balytskyi
60026b3811 remotefilelog: implement threaded _getfiles
Summary:
A better way to avoid deadlocks and not sacrifice performance on `_getfiles`
call.

Test Plan:
- build, pull and update on Windows
- build, pull and update on Linux
- do not observe it hanging

Reviewers: durham, #fbhgext

Differential Revision: https://phab.mercurial-scm.org/D1467
2017-11-22 14:15:06 -08:00
Mateusz Kwapich
8cb98da240 conduit: suuport oauth tokens in addition to certs
Summary: We're migrating towards the new tech.

Test Plan: tried deleting 'cert' from my .arcrc, still works

Reviewers: medson, #mercurial

Reviewed By: medson

Subscribers: medson, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D6376729

Signature: 6376729:1511302323:24066afd17b14c13100b70df9c0fca9220e71799
2017-11-22 02:54:20 -08:00
Saurabh Singh
7ba26bc3b9 lint-checks: remove unused imports and unnecessary space
Summary:
The tests `test-check-pyflakes-hg.t` and `test-check-code-hg.t` are
currently failing because of this.

Test Plan: Ran all the tests.

Reviewers: #fbhgext, quark

Reviewed By: #fbhgext, quark

Differential Revision: https://phab.mercurial-scm.org/D1489
2017-11-21 18:26:20 -08:00
Jun Wu
bb772606f4 perftweaks: micro optimization about branchcache.update
This patch did two micro optimizations:

- Avoid sorting `headrevs` since it's already sorted.
- Inline `cl.node` so there is no `node` hash table lookups inside the loop.

These are good practices. Although practically we don't have that many
headrevs to notice a difference.

Differential Revision: https://phab.mercurial-scm.org/D1452
2017-11-21 15:41:57 -08:00
Jun Wu
acc62da1ae perftweaks: do not update branchcache cache keys
filteredhash, tiprev, tipnode are only used for detecting whether the
on-disk cache is up-to-date or not. Since we don't have on-disk cache, it's
unnecessary to calculate them.

Differential Revision: https://phab.mercurial-scm.org/D1451
2017-11-21 15:41:57 -08:00
Jun Wu
995d879d5e smartlog: only resolve master revset once
Differential Revision: https://phab.mercurial-scm.org/D1449
2017-11-21 15:41:57 -08:00
Jun Wu
40b5838e3e revset: optimize "head() & draft()" to "heads(draft())"
`head()` has visible overhead if there are too many heads (ex. 10k+).
Usually when we only care about draft heads, `heads(draft())` is better
since `draft()` are usually pre-calculated and the revset gets calculated as
`draft() - parents(draft())`, unrelated to the number of total heads.

Note that `head() & draft()` and `heads(draft())` are not strictly
equivalent (ex, a head with a secret phase) so it's changing the behavior a
bit. The new behavior is probably more desirable - in both smartlog and
backup case, people do want to see/backup the draft head, regardless of
whether it has secret descendants or not.

This makes `smartlogrevset` take 50ms less:

Before:

  148           | smartlogrevset                smartlog.py:438
  117            \ revs (3 times)               localrepo.py:783
  116             | mfunc (3 times)             revset.py:2202
  116             | getset (3 times)            revset.py:92
  116             | andset (2 times)            revset.py:165
  116             | getset (4 times)            revset.py:92
   62              \ andset (2 times)           revset.py:165
   62               | getset (4 times)          revset.py:92
   78                \ func (3 times)           revset.py:235
   49                  \ head (2 times)         revset.py:1117
   49                    \ branchmap (4 times)  localrepo.py:953
   46                    \ <genexpr> (16348 times) revset.py:1126
   38                     | rev (16344 times)   changelog.py:353 <<<< too many heads
   67                  \ branch (2 times)       revset.py:465
   42                    \ wrapper (2 times)    localrepo.py:141
   42                     | revbranchcache (2 times) localrepo.py:959
   40                     | __init__            branchmap.py:354
   12                     | read (2 times)      vfs.py:78
   25                    \ branchmap (2 times)  localrepo.py:953
   25                \ andset                   revset.py:165
   30              \ func (2 times)             revset.py:235
   30               | notbackedup               backupcommands.py:302
   52               | _backupheads (2 times)    backupcommands.py:389
   28            \ _masterrev                   smartlog.py:426

After:

   99       | smartlogrevset                    smartlog.py:438
   69        \ revs (3 times)                   localrepo.py:783
   68         | mfunc (3 times)                 revset.py:2202
   68         | getset (3 times)                revset.py:92
   68         | andset (2 times)                revset.py:165
   68         | getset (4 times)                revset.py:92
   13         | andset                          revset.py:165
   13         | getset (2 times)                revset.py:92
   27        \ _masterrev                       smartlog.py:426

Differential Revision: https://phab.mercurial-scm.org/D1448
2017-11-21 15:41:57 -08:00
Phil Cohen
138e8bb8b2 test-progressfile: add test for HGPLAIN behavior
Differential Revision: https://phab.mercurial-scm.org/D1487
2017-11-21 16:11:34 -06:00
Jun Wu
01f8f8f86a progressfile: do not swallow the progress bar if statefile is not set
The statefile-not-set case was not tested. Previously the code will make
`ui._progbar` return None, which means no progress bar.

Also move the docstring to the header so it shows up in `hg help -e`, and
use modern config registrar to avoid devel warnings.

Test Plan:
Added a test

Differential Revision: https://phab.mercurial-scm.org/D1486
2017-11-21 14:11:34 -08:00
Durham Goode
d73bc0c506 treemanifest: add command for backfilling manifests revlog
Previously, once you transitioned to treeonly mode you had no way of switching
back to hybrid mode. This patch adds a hg backfillmanifestrevlog command to
refill a manifest revlog with any bits that are missing.

Differential Revision: https://phab.mercurial-scm.org/D1456
2017-11-21 12:31:27 -08:00
Durham Goode
75008a9386 pushrebase: fix manifest cache
The manifestctx constructor changed at some point in the past to take a
manifestlog and a node instead of a repo and a node. The pushrebase cache code
wasn't adjusted for this. Luckily the manifestctx object only ever uses the
manifestlog to look at the revlog, and the revlog is only ever used to look at
the delta as a fastpath, so most code paths weren't affected.

We encountered this issue on our server, despite it being in there for several
months. Unfortunately I wasn't able to repro it in a test, but I did insert
manual manifestctx._revlog() lines after the construction to ensure that the
revlog can now be created, versus crashing before.

Differential Revision: https://phab.mercurial-scm.org/D1439
2017-11-21 06:58:11 -08:00
Durham Goode
09bf8b4d91 treemanifest: use connection pool for hg pull
Previously hg pull created it's own ssh connection, then the tree prefetch
created one as well. Let's change hg pull to use a connection from the pool when
possible, so it can be reused by treemanifest later.

Differential Revision: https://phab.mercurial-scm.org/D1455
2017-11-21 06:52:51 -08:00
Durham Goode
02afbac4e7 treemanifest: use a connectionpool
remotefilelog and fastannotate already use a connection pool to share and reuse
connections. Treemanifest often does ondemand downloading of trees, such as
during hg log -p, and would greatly benefit from reusing connections as well.

This patch makes the connectionpool and attribute of the repo object, instead of
the fileserverclient object, which allows treemanifest to make use of it easily.

Differential Revision: https://phab.mercurial-scm.org/D1454
2017-11-21 06:52:51 -08:00
Kostia Balytskyi
818f7dee74 tweakdefaults: make util.popen4 input buffer size configurable on Windows
Summary:
This allows us to worry less about deadlocks and be more efficient in our
piped communications (like in fileserverclient.py, for example).

We can also make sure that deadlocks just plainly can't
happen by only writing a known amount of bytes to the pipe.

Test Plan:
- does not seem to break any additional tests on Linux

Reviewers: #fbhgext

Differential Revision: https://phab.mercurial-scm.org/D1436
2017-11-20 17:02:04 -08:00
Jun Wu
d393146974 sparse: try reading from working copy first
Previously sparse will resolve working file context via its parent
unconditionally if the file is outside sparsematch (introduced by D788).
That could be problematic if the file only exists in working copy.

This patch changes it to always try working copy first (fast), then fallback
to parent commit if the file is outside sparse.

Differential Revision: https://phab.mercurial-scm.org/D1464
2017-11-20 13:56:55 -08:00
Jun Wu
898106ae0f sparse: add a test case showing suboptimal behavior
This is reported by users a few times.

Differential Revision: https://phab.mercurial-scm.org/D1463
2017-11-20 13:56:55 -08:00
Durham Goode
792cc88a63 fbamend: disable --to
We've received multiple reports that the command is broken. Let's disable it for
now.

Differential Revision: https://phab.mercurial-scm.org/D1465
2017-11-20 13:17:44 -08:00
Saurabh Singh
e7c86b508e prefetch: do not attempt to prefetch trees for non-public commits
Summary:
This is a follow up to D1446. It extends the prefetch logic to not
download trees even for commits with `secret` phase. Also, it uses a better way
of dealing with revsets. Thanks @quark for this!

Test Plan: Ran all the tests.

Reviewers: #fbhgext, quark

Reviewed By: #fbhgext, quark

Subscribers: quark

Differential Revision: https://phab.mercurial-scm.org/D1461
2017-11-20 12:41:54 -08:00
Phil Cohen
58f3a2112d basepack: fix _getavailablepackfiles sizes
osutil.listdir yields (filename, type, stat), not (filename, size, stat), so we
need to look at the stat.st_size value to get the size. (Previously, we were
summing the file type codes :/)

This should fix packfile metrics.

Differential Revision: https://phab.mercurial-scm.org/D1447
2017-11-20 12:47:13 -06:00
Durham Goode
6334199a3a fbsparse: use unfiltered repo in many places
Computing the hidden commits was showing up as a hot spot in hg status because
hg sparse was accessing the changelog through a filtered repo. This probably
affects many other commands since sparse touches so many places. Since it has no
need to use a filtered repo, let's just have it use unfiltered.

This shaved off 25-30% of the hg status time in some circumstances.

Differential Revision: https://phab.mercurial-scm.org/D1437
2017-11-20 06:40:41 -08:00