Commit Graph

467 Commits

Author SHA1 Message Date
Shannon Zhu
8d850b8a15 Codemod imports from libfb to use full path /scm
Summary:
Codemoding imports from libfb.py of the format "from libfb import X".
This is part of a larger codemod to remove the mapping from libfb/py to libfb,
in the interest of enabling static typechecking in fbcode.

Reviewed By: dark

Differential Revision: D7335696

fbshipit-source-id: f1a1c3b11bec15610ef2bb24cd1c2941f9409b49
2018-03-20 09:46:55 -07:00
Siddharth Agarwal
cfa69e147d mononoke-types: add types for file changes
Summary:
A Mononoke tiny changeset is going to have a list of these file
changes.

Reviewed By: farnz

Differential Revision: D7336315

fbshipit-source-id: 25d9908cf825e665ac7605435ce5a4056f221e17
2018-03-20 08:57:42 -07:00
Siddharth Agarwal
611eea829b mononoke-types: add a wrapper for file contents
Summary:
For now this just wraps a blob, but in the future this will have
special support for large files.

Reviewed By: farnz

Differential Revision: D7336121

fbshipit-source-id: f4c9e216efdd250fde90307264c1931de97d8592
2018-03-20 08:57:42 -07:00
Siddharth Agarwal
bb6e012ad8 mononoke-types: add a type to represent datetimes
Summary: Represented as a chrono datetime in Rust and an (i64, i32) pair in Thrift.

Reviewed By: jsgf

Differential Revision: D7325332

fbshipit-source-id: 22c3b17961ffb0b4fdb4e6e8aece3b257b3c718e
2018-03-20 08:57:42 -07:00
Siddharth Agarwal
d33426121b rename BlobHash to ContentId, UnodeHash to UnodeId
Summary:
External code should consider these identifiers opaque -- the fact
that they're hashes is an implementation detail.

Also a "blob" is too generic here -- what we're talking about is file contents.
In the future (e.g. for 10GB+ files) the content hash might point to something
more complicated than file contents.

Reviewed By: farnz

Differential Revision: D7320932

fbshipit-source-id: 11a781345a1973f0af8222b809004daa948c3a47
2018-03-20 03:07:23 -07:00
Stanislau Hlebik
f023874ed9 mononoke: remove unused parameter
Reviewed By: farnz

Differential Revision: D7324591

fbshipit-source-id: 53b16d0a44fea0011a15634939b3f385658288e4
2018-03-19 15:36:01 -07:00
Lukas Piatkowski
4d4d90928f integration tests: use RocksDb based blobs rather than File based for testing
Summary: just to excersise our RocksDb blobstore which might come in handy more often than file based as it should be more efficient

Reviewed By: StanislavGlebik

Differential Revision: D7290069

fbshipit-source-id: ce776cfa14e43dc45cca796ef187655ba665d177
2018-03-16 13:41:55 -07:00
Lukas Piatkowski
20ec470e7e mercurial: better error contexts in RevlogManifest
Summary: The new error contexts contain not only static information, but also the runtime values for which the error happen, so are easier to act upon

Reviewed By: StanislavGlebik

Differential Revision: D7289693

fbshipit-source-id: e0fd2d9872343093beef23a508d5672ac2c06f8e
2018-03-16 13:41:55 -07:00
Lukas Piatkowski
64bf88d263 mercurial: add parent info to RevlogManifest
Summary: The parent information is very valuable when using RevlogManifest to blobimport manifests (actual usage happens in pending diff)

Reviewed By: farnz

Differential Revision: D7289650

fbshipit-source-id: 2483dd6085af6b16afefee03cc93d55494795368
2018-03-16 13:41:55 -07:00
Lukas Piatkowski
6462c757bb integration test: add test with file of large length and content
Summary: This test should excercise the situation when a path to a file is hashed when stored in revlog and for a large file the index revlog is split into index and data revlog

Reviewed By: StanislavGlebik

Differential Revision: D7299332

fbshipit-source-id: 6b0f0385e391c8396d5a3702ced5feb1aba2163c
2018-03-16 13:41:55 -07:00
Simon Farnsworth
34251570d1 Direct repo logs to the Scuba table, too
Summary:
When Mononoke server is running, it can log to Scuba; repo logs are
meant to go to Scuba or similar, so send them there, too.

Reviewed By: kulshrax

Differential Revision: D7261637

fbshipit-source-id: 99f6e948eec53b0287b939fc5d1d637ba1e4ccc9
2018-03-16 10:36:44 -07:00
Simon Farnsworth
54618629b5 Gather a full set of changeset creation timings
Summary:
To diagnose slow changeset creation, we need to know which chunk was
slow. As with upload_blob and process_entries in past diffs, measure key
phases.

The idea is that we can combine all these times (5 per changeset, 2 per blob)
to work out what needs tracing when we're looking for slowness

Reviewed By: StanislavGlebik

Differential Revision: D7195013

fbshipit-source-id: 9769ead981f02d6ecf0258190763e90762936387
2018-03-16 10:36:44 -07:00
Simon Farnsworth
3864f2e0d3 Record the time spent processing entries during changeset creation
Summary:
Processing entries does two things:

1. Polls all the upload futures until they're all complete.
2. Works out what entries are required to be present for this changeset.

This is the bulk of the Blobstore operations in creating a changeset, so we
know that if this is slow, then we either have a slow Blobstore, *or* we have a
bug. Further, we can combine this with the metrics for upload_blob to know
whether we're doing uploads nicely in parallel, or whether there's
serialization we didn't intended (time taken here greater than sum of time
taken in blob uploads)

Reviewed By: StanislavGlebik

Differential Revision: D7182445

fbshipit-source-id: 205b43700f28ff7e5461235e16a6955b8c597a52
2018-03-16 10:36:44 -07:00
Siddharth Agarwal
4073388b7c mononoke-types: add BlobHash and ChangesetId as other typed hashes
Summary:
I think it makes a lot of logical sense to have three separate hash
types:

* `ChangesetId` for changesets
* `UnodeHash` for unodes
* `BlobHash` for file blobs

These three are never going to mix. Note that manifests and file unodes are
going to mix in e.g. tree manifest unodes.

Reviewed By: farnz

Differential Revision: D7300742

fbshipit-source-id: 688b410f7a5304fdd5ab3a6800137632887f97b9
2018-03-16 10:15:05 -07:00
Siddharth Agarwal
f3a8eaabfe mononoke-types: add Thrift types for MPath and MPathElement
Summary:
As part of conversion from Thrift to native Rust data structures,
verify that they're valid.

Reviewed By: farnz

Differential Revision: D7297264

fbshipit-source-id: d0bb46a5a5ed2113d9616a56fc100943802cbc1f
2018-03-16 10:15:05 -07:00
Siddharth Agarwal
40c9d50062 add a Thrift type for a Blake2 hash
Summary:
Also add conversions to and from the Thrift type to the Rust type.

There are tradeoffs around having parallel sets of data structures vs using
Thrift as the only data structure, but I believe that for these hashes (and
transitively, anything that includes them), having a separate type is best.
That's because:
* these hashes are going to be used all over the place, and using a
heap-allocated vector is just a waste. Even a `SmallVec` that's inline will
consume some extra memory for storing the fact that it's inline.
* something has to verify that the vector is valid, and it's nice for that
to be encoded in the type system.

Reviewed By: farnz

Differential Revision: D7285116

fbshipit-source-id: e887414862821076ef0b11e2d0cb0783be897d4a
2018-03-16 10:15:05 -07:00
Siddharth Agarwal
76027dfac0 verify that MPathElement instances are sane
Summary:
While writing Thrift deserialization code I realized there was nothing
that actually checked that MPathElement instances don't have embedded nulls or
slashes.

Reviewed By: farnz

Differential Revision: D7296838

fbshipit-source-id: 6a23d559da11e5e935e23d7b9a13f58894efaf62
2018-03-16 10:15:05 -07:00
Stanislau Hlebik
b35bd5dd9d mononoke: pushkey part parsing
Summary:
Pushkey part is used to send bookmark updates from hg client to the server.
This diff does all the wireproto parsing, but doesn't actually apply bookmark
updates on the server.

Also this diff "implements" branchmap method. We have no plans to support it,
but currently remotenames extension calls it. So this diff adds a fake
implementation that always returns empty response.

Reviewed By: farnz

Differential Revision: D7150973

fbshipit-source-id: 6889c02a1105127b1805ef1fafa6fbe9c2d57e7d
2018-03-16 04:21:32 -07:00
Siddharth Agarwal
b338897dc4 prefix ChangesetId, ManifestId and BlobHash with Hg
Summary:
Mononoke will introduce its own ChangesetId, ManifestId and BlobHash, and it
would be good to rename these before that lands.

Reviewed By: farnz

Differential Revision: D7293334

fbshipit-source-id: 7d9d5ddf1f1f45ad45f04194e4811b0f6decb3b0
2018-03-15 17:45:29 -07:00
Jeremy Fitzhardinge
5b798ed1ff mononoke: schema for various Mononoke tables and data stores
Summary: Overview of the various SQL schema Mononoke will use. These are pseudo-schema for documentation purposes, and not directly usable (in particular, foreign keys and "engine = 'manifold'").

Reviewed By: kulshrax

Differential Revision: D6965062

fbshipit-source-id: dc73f7612b10c50a35b27b927abcf2a093cd92ef
2018-03-15 12:33:05 -07:00
Stanislau Hlebik
1568ef24a6 mononoke: do not encode empty chunks in bundle2 parts
Summary:
Empty chunks results in '\x00\x00\x00\x00' being sent to the client. However
this is also a marker for end of the bundle2 part. So previously if listkeys
part were empty we were sending corrupted bundles - it had additional
'\x00\x00\x00\x00' in the end. This wasn't a problem earlier, because getbundle
was the last called wireproto command. However we want to support remotenames,
and remotenames sends listkeys wireproto request after the getbundle.

Reviewed By: farnz

Differential Revision: D7271598

fbshipit-source-id: 1304e2e74725a75726b78bcd4a9664995025191f
2018-03-15 10:42:31 -07:00
Stanislau Hlebik
1de996bcc6 mononoke: RFC: new bookmarks crate
Summary:
First draft of the new bookmarks trait. Note that it doesn't support Bookmarks
& Heads simultaneous transactions.

There are a few notable differences from old bookmarks trait:
1) New `Transaction` trait was added that handles all write operations.
2) It has two different set methods: `set()` and `set_unconditionally()`.
   `set()` checks the current bookmark value before updating it,
   and `set_unconditionally()` doesn't.

Reviewed By: farnz

Differential Revision: D7138038

fbshipit-source-id: 8cbec5caa972d847a30baa0a351df651306b4fd1
2018-03-15 10:17:23 -07:00
Siddharth Agarwal
a7912e687f add a new hash type for unodes
Summary:
These hashes will be the used throughout Mononoke's data model.

Also add mocks.

Note that a `UnodeHash` cannot be null.

Reviewed By: farnz

Differential Revision: D7260955

fbshipit-source-id: d5be5c67848e7b93218a26282e0a757708df7e62
2018-03-14 18:46:46 -07:00
Stanislau Hlebik
f25bc15119 mononoke: mask the flakiness of test-infinitepush.t
Summary:
I've spent quite some time but wasn't able to get to the bottom of why
test-infinitepush.t has been flaky. For some reason error message

```
Expected Bundle2 Changegroup
```

hasn't made it's way to the hg client. Adding a multisecond delay before
sending the error "fixes" the problem, but I haven't found the actual reason
behind the problem. So since that's not a #1 priority now I suggest to postpone
fixing it for now.

Reviewed By: farnz

Differential Revision: D7246511

fbshipit-source-id: a385130e6bdc978765e04f44c6a536405ee12e02
2018-03-14 03:49:35 -07:00
Stanislau Hlebik
4b22e44847 mononoke: fix flakiness of test-gettreepack.t
Summary:
The reason for flakiness was in unpredictable order of the tree items from
Mononoke. In the first gettreepack call we request two different revisions, and
Mononoke can return them in any order. hg handles it just fine (see updated
test with `hgmn up ...`), but hashes of the tree packs may change.

To remove flakiness let's not rely on the treepack files hash

Reviewed By: farnz

Differential Revision: D7237559

fbshipit-source-id: c04e9d45c41f1d288a90706d0ecc27ede36f8008
2018-03-14 03:49:35 -07:00
Simon Farnsworth
7452236c99 Refactor special stats drain into a macro
Summary:
I'm going to reuse this for unit-testing changeset timings. Make it a
macro so that I don't keep repeating myself.

Reviewed By: StanislavGlebik

Differential Revision: D7182442

fbshipit-source-id: de40e0f10892b2268c4d39cf771b7a8be6e1cf76
2018-03-13 12:28:20 -07:00
rleungx
2c35ac873f add .gitignore
Summary: Closes https://github.com/facebookexperimental/mononoke/pull/5

Reviewed By: quark-zju

Differential Revision: D7241539

Pulled By: sid0

fbshipit-source-id: d70ed9a07a22e07d2e4fef296117afcaf8a1d166
2018-03-13 11:58:20 -07:00
Stanislau Hlebik
f4a8559f13 mononoke: fix flakiness of test-eden-server.t
Summary:
It was flaky because server may not yet be ready to accept connections when we
send first request. Sometimes delay needs to be > 1 sec.
Let's query eden server in a loop until it responds.

Reviewed By: farnz

Differential Revision: D7233069

fbshipit-source-id: 8bcb5b2b8ebdc52d2447b33e18580e50c1e27031
2018-03-12 08:45:18 -07:00
Simon Farnsworth
050c7d95d8 Support a key prefix in ManifoldBlob Blobstore
Summary:
I want to be able to work in a private Manifold namespace when testing
that my hunches about Manifold/Mononoke interactions are good, and when testing
changes to the ManifoldBlob that should make life better. Make that possible.

In the future, once I have a Blobstore that simulates Manifold locally, this
also makes it possible to compare the simulation to Manifold without tripping
over other users.

Reviewed By: StanislavGlebik

Differential Revision: D7194754

fbshipit-source-id: 601bf1c2ded1af5db6a123fdd05600bc3eb5d7cf
2018-03-12 07:59:56 -07:00
Siddharth Agarwal
6dc04f8903 mononoke-types: add a blake2 hash type
Summary:
This is ripped off pretty much directly from the `Sha1` type in
`mercurial-types`.

Reviewed By: StanislavGlebik

Differential Revision: D7205225

fbshipit-source-id: facb243735d858c68886ad932920024eaf3de536
2018-03-09 10:24:55 -08:00
Lukas Piatkowski
c4ede3aa71 blobrepo: wrap Error in Compat for SharedError<Compat<Error>>
Summary: SharedError has a default implementation for std Error, but the parameter must implement std Error, that is why I wrapped failure::Error in failure::Compat. Thanks to that we can use SharedError as any other normal std Error (including the fact that it implements failure::Fail)

Reviewed By: farnz

Differential Revision: D7213459

fbshipit-source-id: 54899c64c2627dfdba276630d986a3d6007ea59a
2018-03-09 08:44:32 -08:00
Siddharth Agarwal
6204e214d1 create a mononoke-types crate
Summary:
These are types that are going to be used throughout Mononoke -- I'm hoping to
avoid references to current Mercurial data structures in here.

For now, the only module I've moved is part of the `path` module. The
Mercurial-specific `fsencode` bits have been kept in mercurial-types (though
maybe they should move to `mercurial`?)

In the future, this module will also include definitions for unodes, etc.

Reviewed By: jsgf

Differential Revision: D7188722

fbshipit-source-id: fc097ca12c38a787f83e35af9b8dd308f2b910ea
2018-03-08 10:57:35 -08:00
Simon Farnsworth
6d53f3e310 Add timing information to BlobRepo upload_blob
Summary:
We want to be able to measure the time it takes to upload individual
blobs, to confirm that we don't have a concurrency issue to chase down (e.g.
blobs accidentally uploaded in series).

Measure content upload time separately, so that we know not to dive down a
rabbit hole if the measured slowness is just the time spent uploading content

Reviewed By: StanislavGlebik

Differential Revision: D7172154

fbshipit-source-id: 08729a8ffaa69a364a64f6277edfa591a8712592
2018-03-07 13:45:51 -08:00
Simon Farnsworth
868e95e831 Split up the BlobRepo commit tests
Summary:
I'm going to be adding more to test the timing features, so split this
up to make code sharing easier

Reviewed By: StanislavGlebik

Differential Revision: D7172156

fbshipit-source-id: 056be70268dd1c8a37aff8e8d53342b8cea4a355
2018-03-07 04:37:27 -08:00
Arun Kulshreshtha
9f091474bb Fill in missing code in MysqlChangesets
Summary: Add in the missing code to establish a MySQL connection to the `changesets` crate. Also add unit tests for `MysqlChangesets`.

Reviewed By: jsgf

Differential Revision: D7174371

fbshipit-source-id: b531c5d5efb95eeb5e39188c4d608540f0c0261f
2018-03-06 17:07:46 -08:00
Simon Farnsworth
bb8c39183e Thread a logger into BlobRepo
Summary: I'm going to need a logger to log future-stats output to (and later trace output). Thread one through to BlobRepo

Reviewed By: StanislavGlebik

Differential Revision: D7167450

fbshipit-source-id: 4ed729e4d448b66e491cefa19380d3be9bc99091
2018-03-06 08:09:19 -08:00
Simon Farnsworth
98bc1a4e81 Fix blob size calculation
Summary:
We had two separate issues in blob size, which were breaking `test-eden-server.t`:

1. The value documented as "blob size without metadata" was calculated with metadata included (because we didn't strip the metadata from the content blob).
2. If the BlobNode was clean (i.e. had both data and a hash), the size was the size of the hash, not the data.

Reviewed By: StanislavGlebik

Differential Revision: D7167581

fbshipit-source-id: 965778c1d053af36c760a988f0d34130052e8a1a
2018-03-06 07:05:52 -08:00
Stanislau Hlebik
14031b91b6 mononoke: add helper ChangegroupPush struct
Summary:
Add a struct that helds parsed data from changegroup part. In the next diffs
we'll start parsing pushkey parts with bookmarks, and ChangegroupPush struct
knocks down the number of parameters that we need to pass from one function to
another.

Reviewed By: farnz

Differential Revision: D7150974

fbshipit-source-id: a8c0e260a4421168903894930befbab430a6418d
2018-03-06 04:47:34 -08:00
Stanislau Hlebik
801591845e mononoke: move bookmarks to bookmarks_old
Summary:
We are going to significantly change Bookmark trait and implementation.
We are going to use Diesel, and new Bookmark trait won't use Version. Instead
of changing the current implementation, let's just move it to the separate
directory which will soon be deleted.

Reviewed By: lukaspiatkowski

Differential Revision: D7138039

fbshipit-source-id: 72b81bf7f6524052b3a360bac23ab56a978b08cb
2018-03-06 04:47:34 -08:00
Alexander Putilin
b4cecd77da mononoke: add basic telemetry for some hg operations
Summary:
Add basic telemetry for some of hg operations that return a future. This is a draft I'm requesting feedback on (as advised by stash@).
1) The code is a bit repetitive. Is there a way to refactor it (for example, python decorator-like style)?
2) What is the best way to add telemetry for operations that return a BoxStream (and not a future)?

Reviewed By: StanislavGlebik

Differential Revision: D7056236

fbshipit-source-id: 7fd61b5533d0fe3857cc7865491b5e9e7240a886
2018-03-05 18:46:00 -08:00
Stanislau Hlebik
739933697c mononoke: fix infinitepush test one more time
Reviewed By: lukaspiatkowski

Differential Revision: D7138708

fbshipit-source-id: 700355071ce6dfa677d62d1a45ee9b2698727ed3
2018-03-02 10:45:34 -08:00
Dino Wernli
fa2b14cd8b Remove the generic types from Blob and BlobNode in favor of Bytes
Summary: Replace the generic types if `Blob` and `BlobNode` with `Bytes`.

Reviewed By: lukaspiatkowski

Differential Revision: D7115361

fbshipit-source-id: 924d347377569c6d1b3b4aed14d584510598da7b
2018-03-02 09:45:04 -08:00
Dino Wernli
36917d583a Address some leftover comments from D7106766.
Reviewed By: lukaspiatkowski

Differential Revision: D7123890

fbshipit-source-id: 73d2531413d34bff6db8baaf959e11084def616e
2018-03-02 09:02:59 -08:00
Stanislau Hlebik
676762bfea mononoke: fix test
Reviewed By: simonwhitaker

Differential Revision: D7135635

fbshipit-source-id: 75a65b3709fa399bde2ad6ee1ec3ebe620d705b7
2018-03-02 03:00:40 -08:00
Stanislau Hlebik
04e471e453 mononoke: handle infinitepushscratchbookmarks part
Summary:
This is the part that sends client bookmarks to the server. Quite likely we are
not going to process it, so we are just reading the part and ignoring it.

Reviewed By: farnz

Differential Revision: D7123758

fbshipit-source-id: 7ad39bde77b6f77cf6e440e726ac3bdb9f340cea
2018-03-01 08:21:10 -08:00
Stanislau Hlebik
0c4f5bf3f8 mononoke: basic infinitepush implementation
Summary:
Support b2x:infinitepush part. It contains changegroup v2, so just reuse the
normal push path for it.
Note that pushbackup still fails because we don't support
b2x:infinitepushscratchbookmarks part. Also all wireproto params are ignored
for b2x:infinitepush.

Reviewed By: farnz

Differential Revision: D7086120

fbshipit-source-id: 2f98e5d59059ca3c2b82842c98e6dc771c70c6f0
2018-03-01 03:23:46 -08:00
Stanislau Hlebik
3011302908 mononoke: rewrite asyncmemo to use Shared
Summary:
Asyncmemo re-implementation using Shared future. The reasons for doing it are:

1 Now it's safe to drop MemoFuture
2 Now there will be no deadlocks where one future evict another future from the
cache, and then the second future evicts the first futures and so on.

Since Shared returns SharedError, I had to do a hack to work around that. More
details in the code comments.

Reviewed By: farnz

Differential Revision: D7099852

fbshipit-source-id: e08cb859ef06f28339ac9314edb8e53e92480874
2018-03-01 02:35:34 -08:00
Dino Wernli
5c84d1d8de Return file contents as Bytes in blobrepo.
Summary: This starts porting uses of Vec<u8> for file contents to the Bytes type.

Reviewed By: jsgf

Differential Revision: D7106766

fbshipit-source-id: 15d531836132317cede7a6f9d6b047a423deb5bb
2018-02-28 17:59:12 -08:00
Lukas Piatkowski
d24a501e9e blobrepo: write commit to HeadStore
Summary:
This is a hacky way of getting the push/pull working. We should instead remove the commits that are no longer heads from HeadStore and add those that are the new heads.
In this diff though we add all the commits as heads, just because this does not break the client

Reviewed By: farnz

Differential Revision: D7112279

fbshipit-source-id: 036f0fd230de52e96cbf4168c2cda7c2a1c5bd89
2018-02-28 14:15:13 -08:00
Lukas Piatkowski
722eba6c8a mercurial-types: make debug printing of MPath easier to read
Summary: Now both RepoPath and MPath are showing human readable paths when printed

Reviewed By: farnz

Differential Revision: D7112280

fbshipit-source-id: ba7698d2ffa90a125176d70d665cdef669d63b93
2018-02-28 14:15:13 -08:00