Commit Graph

424 Commits

Author SHA1 Message Date
Lowik Chanussot
33c25691f3 Make ManifestMissing error accept HgManifestId
Summary:
- ManifestMissing accepts HgManifestId instead of HgNodeHash
- Update calls to ManifestMissing
- Update unit test accordingly

Reviewed By: StanislavGlebik

Differential Revision: D10337392

fbshipit-source-id: b70ac6381043cbf64ec7cdafbf338c2af1e00076
2018-10-11 14:20:42 -07:00
Lukas Piatkowski
cad69fedd0 filenodes: use sqlfilenodes instead of dieselfilenodes; pass myrouter_port around
Reviewed By: farnz

Differential Revision: D10338868

fbshipit-source-id: 60734d9635df442691cad3637aebd5bc838e03ad
2018-10-11 10:52:05 -07:00
Lowik Chanussot
395b124f5d Make get_manifest_by_nodeid accept HgManifestId
Summary: Make get_manifest_by_nodeid accept HgManifestId and correct all calls to get_manifest_by_nodeid.

Reviewed By: StanislavGlebik

Differential Revision: D10298425

fbshipit-source-id: 932e2a896657575c8998e5151ae34a96c164e2b2
2018-10-11 06:50:16 -07:00
Anastasiya Zhyrkevich
0f6bba1de0 PUT request upload to mononoke API
Summary:
PUT request upload to mononoke API
hg client sends a PUT request to store a file into blobstore during push supporting LFS

Upload file by alias is divied into 2 parts:
- Put alias : blobstore key
- Put blobstore_key: contents

Keep in mind, that file content is thrift encoded

host_address for batch request is from command line flags -H for host, -p for port

Reviewed By: StanislavGlebik

Differential Revision: D10026683

fbshipit-source-id: 6c2726c7fee2fb171582bdcf7ce86b22b0130660
2018-09-27 11:20:46 -07:00
Simon Farnsworth
1c3f40aaf5 Log a JSON blob to Scribe for every commit to Manifold repos
Summary:
JSON blobs let other users of Mononoke learn what they need to know
about commits. When we get a commit, log a JSON blob to Scribe that other users can pick up to learn what they want to know.

Because Scribe does not guarantee ordering, and can sometimes lose messages, each message includes enough data to allow a tailer that wants to know about all commits to follow backwards and detect lost messages (and thus fix them up locally). It's expected that tailers will either sample this data, or have their own state that they can use to detect missing commits.

Reviewed By: StanislavGlebik

Differential Revision: D9995985

fbshipit-source-id: 527b6b8e1ea7f5268ce4ce4490738e085eeeac72
2018-09-27 04:25:16 -07:00
Simon Farnsworth
bbd00294bb Set up the infrastructure to log changesets after commit
Summary:
We want to be able to do post-commit logging for all changesets. Set
up the data structures I intend to use for now, and arrange to discard all
logging.

A later diff will add logging to a ScribeClient.

Reviewed By: StanislavGlebik

Differential Revision: D9995984

fbshipit-source-id: 796b390f6b83ace576f73a217ac564c4251d7ec5
2018-09-27 04:25:14 -07:00
Stanislau Hlebik
f0b0fdad63 mononoke: prefetch caches of changesets from blobstore
Summary:
This diff adds a real implementation for CachingChangesetFetcher. Now it
fetches the data for the cache from the blobstore.

The rest is explained in the comments.

Reviewed By: farnz

Differential Revision: D9908320

fbshipit-source-id: 5427f3ed312cb7753434161423cb27b48744347f
2018-09-25 05:07:50 -07:00
Stanislau Hlebik
30ccc3b75b monononoke: add caching changesets fetcher
Summary:
Initial implementation of ChangesetsFetcher that will use cache smarter.
At the moment it doesn't do anything special, but in the next diffs it will pre
warm cache in case it has a lot of cache misses (that's why it has to have a
reference to the cachelib CachePool).

Reviewed By: farnz

Differential Revision: D9908319

fbshipit-source-id: 6377a947696bae6b060de5a441722c28309b341c
2018-09-25 05:07:50 -07:00
Stanislau Hlebik
ec43bcc0fb mononoke: add ChangesetFetcher trait
Summary:
High-level goal: we want to make certain big getbundle requests faster. To do
that we'd store blobs of commits that are close to each other in the blobstore
and fetch them only if we had too many cache misses. All this logic will be
hidden in ChangesetFetcher trait implementation. ChangesetFetcher will be
created per request (hence the factory).

Reviewed By: farnz

Differential Revision: D9869659

fbshipit-source-id: 9e3ace3188b3c13f83ef1bd61b668d4f22103f74
2018-09-25 03:23:52 -07:00
Anastasiya Zhyrkevich
f33ea55653 download mononoke api
Summary:
WIP

Mononoke API download  for lfs
support get request
curl http://127.0.0.1:8000/{repo_name}/lfs/download/{sha256}

Reviewed By: StanislavGlebik

Differential Revision: D9850413

fbshipit-source-id: 4d756679716893b2b9c8ee877433cd443df52285
2018-09-20 01:37:00 -07:00
Stanislau Hlebik
72e4b21ba9 mononoke: check case conflicts in commit API
Summary:
Let's check that new case conflicts are not added by a commit.
That diff also fixes function check_case_conflict_in_manifest - it needs to
take into account that if one of the conflicting files was removed then there
is no case conflict.

There should be a way to disable this check because we sometimes need to allow
broken commits. For example, during blobimport

Reviewed By: aslpavel

Differential Revision: D9789809

fbshipit-source-id: ca09ee2d3e5340876a8dbf57d13e5135344d1d36
2018-09-18 07:23:13 -07:00
Sebastian Lund
847ccb0bef mononoke: use ChangesetId in DifferenceOfUnionsOfAncestorsNodeStream
Summary: Use `ChangesetId` in `DifferenceOfUnionsOfAncestorsNodeStream` instead of `HgNodeHash`. This avoids several bonsai lookups of parent nodes.

Reviewed By: StanislavGlebik

Differential Revision: D9631341

fbshipit-source-id: 1d1be7857bf4e84f9bf5ded70c28ede9fd3a2663
2018-09-17 09:52:29 -07:00
Anastasiya Zhyrkevich
c603c9d19b Add additional reference to blob
Summary:
Additional 2-step reference for blob:

For each file add an additional blob with:
   key = aliases.sha256.sha256(raw_file_contents)
   value = blob_key

Pay attention, that sha256 hash is taken `from raw_file_content`, not from a blob content.

Additional blob is sent together with the file content blob.

Reviewed By: lukaspiatkowski, StanislavGlebik

Differential Revision: D9775509

fbshipit-source-id: 4cc997ca5903d0a991fa0310363d6af929f8bbe7
2018-09-13 07:53:00 -07:00
Stanislau Hlebik
831e52a98c mononoke: do not generate Blob<Id> unnecessarily
Summary:
In `fetch_file_contents()` `blobstore_bytes.into()` converted the bytes to
`Blob<Id>`. This code calls `MononokeId::from_data()` which calls blake2
hashing. Turns out it causes big problems for large many large files that
getfiles can return.

Since this hash is not used at all, let's avoid generating it.

Reviewed By: jsgf

Differential Revision: D9786549

fbshipit-source-id: 65de6f82c1671ed64bdd74b3a2a3b239f27c9f17
2018-09-13 05:53:10 -07:00
Stanislau Hlebik
91dceba40a mononoke: add logic to do batch creation of bonsai changesets
Summary:
Profiling showed that since we are inserting objects into blobstore
sequentially it takes a lot of time for long stacks of commit. Let's do it in
parallel.

Note that we are still inserting sequentially into changesets table

Reviewed By: farnz

Differential Revision: D9683037

fbshipit-source-id: 8f9496b97eaf265d9991b94243f0f14133f463da
2018-09-11 09:53:22 -07:00
Pavel Aslanov
af69be4b3b case-conflict checking functions
Summary:
Adds case conflict checking functions
- `manifest + path` case
- `[path]` case

Reviewed By: StanislavGlebik

Differential Revision: D9700760

fbshipit-source-id: 582430f61bed1ae279dafbe7804a562d5b2ddf59
2018-09-07 09:06:17 -07:00
Jeremy Fitzhardinge
c4ece89763 mononoke: use Chain for errors
Summary:
Use .chain_err() where appropriate to give context to errors coming up from
below. This requires the outer errors to be proper Fail-implementing errors (or
failure::Error), so leave the string wrappers as Context.

Reviewed By: lukaspiatkowski

Differential Revision: D9439058

fbshipit-source-id: 58e08e6b046268332079905cb456ab3e43f5bfcd
2018-09-06 14:24:08 -07:00
Stanislau Hlebik
0403dba05c mononoke: remove unused options
Reviewed By: lukaspiatkowski

Differential Revision: D9627883

fbshipit-source-id: b235cb272f93178c942ebf662d77ca73c3790a40
2018-09-03 04:06:14 -07:00
Pavel Aslanov
cf9cd619c1 compute changed files and find conflicts
Summary:
This diff fills missing parts of push-rebase implementation
- `find_closest_root` - find closest root to specified bookmark
- `find_changed_files` - find file affected by changesets between provided `ancestor` and `descendant`
- `intersect_changed_files` - rejects push rebase if any conflicts have been found
- `create_rebased_changes` - support for merges
- `do_pushrebase` - returns updated bookmark value

Reviewed By: StanislavGlebik

Differential Revision: D9458416

fbshipit-source-id: c0cb53773eba6e966f1a5928c43ebdec761a78d3
2018-08-29 06:52:11 -07:00
Zeyi Fan
c1b1005d91 clean up HgBlob and HgBlobHash
Summary: This commits change `HgBlob` from an enum into a struct that only contains one Bytes field, completely removes `HgBlobHash` and changes the methods of `HgBlob` from returning `Option`s into directly returning results.

Reviewed By: farnz

Differential Revision: D9317851

fbshipit-source-id: 48030a621874d628602b1c5d3327e635d721facf
2018-08-19 15:52:34 -07:00
Alex Maloney
1496846903 Futures split Stats into FutureStats and TimedStats
Summary: Since this data is specific to TimedStream and not TimedFuture I split the Stats struct into FutureStats and StreamStats

Reviewed By: StanislavGlebik

Differential Revision: D9355421

fbshipit-source-id: cc2055706574756e2e53f3ccc57abfc50c3a02ba
2018-08-17 13:07:24 -07:00
Stanislau Hlebik
8bba54d313 mononoke: change RangeNodeStream to use ChangesetId
Summary:
Revsets must use ChangesetId, not HgNodeHash. I'm going to use
`RangeNodeStream` in pushrebase so I thought it was a good time to change it

Reviewed By: farnz

Differential Revision: D9338827

fbshipit-source-id: 50bbe8f73dba3526d70d3f816ddd93507db99be5
2018-08-17 06:51:52 -07:00
Zeyi Fan
6a27deae88 remove fetch_file_content_and_renames_from_blobstore
Summary: This function is unnecessary.

Reviewed By: farnz

Differential Revision: D9308779

fbshipit-source-id: a8d0520f8c815a22690af054d938c1f58cf90715
2018-08-15 11:31:56 -07:00
Pavel Aslanov
c7badc8b47 store bonsai changesets in bookmarks instead of hg changesets
Summary: - Use `ChangesetId` instead of `HgChangesetId` in `Bookmarks`

Reviewed By: StanislavGlebik

Differential Revision: D9333273

fbshipit-source-id: 96a4d585f9a0479b87556a5f05ae7a9692dd8926
2018-08-15 07:36:15 -07:00
Stanislau Hlebik
b2f747cd9c mononoke: store better copy info error message
Summary: Store where it was copied from

Reviewed By: farnz

Differential Revision: D9132560

fbshipit-source-id: a7a73e1f3de08340f5add5fffa32dd0373eb27fa
2018-08-15 01:51:55 -07:00
Stanislau Hlebik
75452452b5 mononoke: switch back to thrift manifold
Summary:
The issues were fixed, and also thrift manifold works better during bulk
blobimport.

Reviewed By: farnz

Differential Revision: D9132384

fbshipit-source-id: ab4a04eeff86bb4968b80af00c404fad710db183
2018-08-15 01:51:55 -07:00
Lukas Piatkowski
9f08d1d60f Back out "[mononoke] store bonsai changesets in bookmarks instead of hg changesets"
Summary: Original commit changeset: e18661793d14

Reviewed By: StanislavGlebik

Differential Revision: D9317492

fbshipit-source-id: 5959936d604d7f2bf9e493e72977bf02003bc247
2018-08-14 11:47:56 -07:00
Pavel Aslanov
fafa719365 store bonsai changesets in bookmarks instead of hg changesets
Summary: - Make `Bookmakrs` work with `ChangsetId` instead of `HgChangesetId`

Reviewed By: StanislavGlebik, farnz

Differential Revision: D9297139

fbshipit-source-id: e18661793d144669354e509271044410caa3502a
2018-08-14 03:21:30 -07:00
Stanislau Hlebik
7acaa4474b mononoke: more stats
Reviewed By: farnz

Differential Revision: D9296612

fbshipit-source-id: b71d3b5992443f638a4cd635219178f910d54ed5
2018-08-13 10:06:09 -07:00
Lukas Piatkowski
425c397217 blobrepo: add get_filenode method to simplify filenode access
Summary: As a bonus this diff also contains unifying the linknode family of methods (they all now accept arguments via reference) and better tracing for get_files request

Reviewed By: StanislavGlebik

Differential Revision: D9031283

fbshipit-source-id: 4526a8446984904bce7d4dcef240088c7f2ffaa3
2018-08-10 10:06:27 -07:00
Simon Farnsworth
3733848cef Use Abomonation and cachelib to replace Asyncmemo
Summary:
Asyncmemo has two issues for our use:

1. Separate memory pool from cachelib caches.
2. Future fusion means that a `get` that should succeed will fail because there
was an earlier get still in progress.

The second is good for memoization, where the worst case from a failed get is
extra CPU work, but not so good for caching. Replace uses of Asyncmemo for
caches with a cachelib based cache

Reviewed By: StanislavGlebik

Differential Revision: D9013679

fbshipit-source-id: b85d4eec7294e0c8ee08faa671d26901b35cf1fc
2018-08-07 13:37:09 -07:00
Simon Farnsworth
cc1454d333 Restore cachelib blob caching
Summary: Reverts D8989404 so that we're using cachelib again.

Reviewed By: jsgf

Differential Revision: D9036003

fbshipit-source-id: 9867a12b81369156ee2e6aa7a7f1c81a638185d6
2018-08-07 11:37:37 -07:00
Stanislau Hlebik
231dde7cd4 mononoke: better error message
Reviewed By: farnz

Differential Revision: D9179314

fbshipit-source-id: c44fa6cbb95032e7a24786d65982a9518513c6bb
2018-08-07 06:22:01 -07:00
Stanislau Hlebik
9abd29d4c3 mononoke: use ChangesetId in Changesets
Summary:
Alas, the diff is huge. One thing is changing Changesets to use ChangesetId.
This is actually quite straightforward. But in order to do this we need to
adapt our test fixtures to also use bonsai changesets. Modifying existing test
fixtures to work with bonsai changesets is very tricky. Besides, existing test
fixtures is a big pile of tech debt anyway, so I used this chance to get rid of
them.

Now test fixtures use `generate_new_fixtures` binary to generate an actual Rust
code that creates a BlobRepo. This Rust code creates a bonsai changeset, that
is converted to hg changeset later.
In many cases it results in the same hg hashes as in old test fixtures.
However, there are a couple of cases where the hashes are different:
1) In the case of merge we are generating different hashes because of different
changed file list (lukaspiatkowski, aslpavel, is it expected?). this is the case for test
fixtures like merge_even, merge_uneven and so on.
2) Old test fixtures used flat manifest hashes while new test fixtures are tree
manifest only.

Reviewed By: jsgf

Differential Revision: D9132296

fbshipit-source-id: 5c4effd8d56dfc0bca13c924683c19665e7bed31
2018-08-06 10:36:43 -07:00
Stanislau Hlebik
543e8a6c23 mononoke: rename
Summary: To make them more explicit

Reviewed By: matthewdippel

Differential Revision: D9132294

fbshipit-source-id: a365d7b58ba095d11fb0570e5ab6994a158873b3
2018-08-06 10:36:42 -07:00
Stanislau Hlebik
8e53fa1f6c mononoke: use BonsaiChangeset in commit API
Summary:
This is a split from D8893504. It just enables functionality to create bonsai changesets.

The split was done so that I can land the biggest chunk of work.

Reviewed By: farnz

Differential Revision: D9081430

fbshipit-source-id: 7437c7789998f5691afe83d5b16a8f2c5faac8b4
2018-08-06 10:36:42 -07:00
Stanislau Hlebik
6a33e51971 mononoke: fix bug in bonsai -> hg generation
Summary:
It was using manifest hash as parent hash. One more reason to fix all the types
in Mononoke

Reviewed By: aslpavel

Differential Revision: D9123653

fbshipit-source-id: 0841f7ac64e50e9234d80040b7f286930af53420
2018-08-02 05:21:26 -07:00
Rain ⁣
2ab0bdb915 blobrepo: fix missing enum in find_file_changes
Summary: Semantic merge conflict.

Reviewed By: matthewdippel

Differential Revision: D9095236

fbshipit-source-id: 0da06fbedea245e5fdd7599163f6140e0ebabc82
2018-07-31 15:22:50 -07:00
Pavel Aslanov
2fdc5ddd70 get/generate hg changeset from bonsai changeset
Summary:
This code adds generation of mercurial changeset from bonsai changeset:
  - now handles move file info
  - updates filenodes and changesets tables

Reviewed By: StanislavGlebik

Differential Revision: D9027741

fbshipit-source-id: b10ae9a87565f2e1e9f59954c45815b844033fa5
2018-07-31 11:36:14 -07:00
Stanislau Hlebik
a9ccfe8cc1 mononoke: create BonsaiChangeset in commit API
Summary:
Now bonsai changesets are created at the same time as hg changesets, and
the mapping between bonsai and hg changesets is recorded

One important piece is missing. At the moment copy info information is ignored.
I'll add it in the next diffs.

Before diff is landed, I re-run the blobimport to prefill missing bonsai changesets.

Reviewed By: farnz

Differential Revision: D8893504

fbshipit-source-id: 1cc4bbcca2f489a0ef6990d6c04d5b3fd8bef92c
2018-07-31 02:24:28 -07:00
Stanislau Hlebik
5191e7e328 mononoke: refactor handle_parents
Summary:
Make it return manifest hashes. This is not very useful right now, but it will
be useful in the later diffs where we add BonsaiChangeset generation.

Reviewed By: farnz

Differential Revision: D9013976

fbshipit-source-id: 85f0c78bc7b944d300d537dd29cfd66f6f6530c6
2018-07-30 06:36:31 -07:00
Lukas Piatkowski
8748c72eea filenodes: use Memcache to cache get_all_filenodes results
Summary: Because get_all_filenodes can go above 1MB (but still less than 3MB) I added a chunking logic to speed up fetching of even the long histories

Reviewed By: farnz

Differential Revision: D9029774

fbshipit-source-id: c2d46a4b49bfebd3c778a0b9c5cf226857f34768
2018-07-27 13:21:20 -07:00
Zeyi Fan
82ab81238d re-exporting types from other crate is not a good idea
Summary:
I had enough seeing compiler giving me error messages with `blobrepo::Error` whereas it should be `failure::Error`.

`pub type` is exporting a type alias whereas `pub use` is re-exporting. The later apparently will fool the compiler to think that they own the thing they are re-exporting which in this case, failure::Error. If it is for the purpose of declaring the error type the crate is using, type alias is obviously more suitable as it won't take the ownership of the type.

Reviewed By: lukaspiatkowski

Differential Revision: D8926275

fbshipit-source-id: 6b1346adf52bec6b666a3f8b23e7a4ea4e0ab070
2018-07-26 14:23:07 -07:00
Lukas Piatkowski
dec3e9a444 mononoke: backout cachelib integration for blob caching
Summary:
Back out "[mononoke] Switch to cachelib for blob caching"

Original commit changeset: 2549d85dfcba

Back out "[mononoke] Remove unused asyncmemo imports"

Original commit changeset: e34f8c34a3f6

Back out "mononoke: fix blobimport"

Original commit changeset: b540201b93f1

Reviewed By: StanislavGlebik

Differential Revision: D8989404

fbshipit-source-id: e4e7c629cb4dcf196aa56eb07a53a45f6008eb4e
2018-07-26 10:09:32 -07:00
Stanislau Hlebik
9a6b7273c6 mononoke: fix blobrepo test
Summary:
Previously incorrect filenodes were recorded. Instead of filenode "dir/file",
"file" was recorded as a path in filenodes table.
The next diff that adds creating file copies in bonsai changesets relies on
correct filenodes being present in the table.

Reviewed By: farnz

Differential Revision: D8915297

fbshipit-source-id: dcbde286d935bc726847f788779cfdc7c888c023
2018-07-26 10:09:31 -07:00
Stanislau Hlebik
97764f13e1 mononoke: make test less flakey
Summary:
The test was working fine, however, with the next diff in the stack
it started to fail under stress runs. And in that case I assume the problem in
the test itself.

The test creates two commits, that create file with the same content.
However, one filenode wasn't ancestor of another, and that's semantically
incorrect.

Reviewed By: farnz

Differential Revision: D8913129

fbshipit-source-id: 1b3838c6cf5060d768e71ef056cb7765ebbabc99
2018-07-26 10:09:31 -07:00
Stanislau Hlebik
ff04a36412 mononoke: rename BlobChangeset and ChangesetContent
Summary:
These types are Hg specific. Since we are going to add bonsai changeset
creation soon, let's make it clear in the types

Reviewed By: farnz

Differential Revision: D8911359

fbshipit-source-id: 8b6cc45122402d7b7e074e66d904d979030de705
2018-07-26 10:09:31 -07:00
Stanislau Hlebik
113bc68bec mononoke: fix returned linknode type
Summary: That's actually HgChangesetId, not HgNodeHash

Reviewed By: farnz

Differential Revision: D8911209

fbshipit-source-id: b7f47b57e93f554bbd78e8f5ae281a50e9a128ff
2018-07-23 10:25:13 -07:00
Simon Farnsworth
2d15681343 Switch to cachelib for blob caching
Summary:
Start deprecating AsyncMemo for caching purposes, by removing its use
as a blobstore cache.

Reviewed By: StanislavGlebik

Differential Revision: D8840496

fbshipit-source-id: 2549d85dfcba6647e9b0824ab55ab76165a17564
2018-07-21 13:37:14 -07:00
Rain ⁣
fa58de6e4e blobrepo: add support for doing in-memory writes to blobstore
Summary:
This proves to be extremely useful for the upcoming bonsai
verification code.

The in-memory stuff is more complicated for the database backends, so punt on
that for now with some warnings.

Reviewed By: farnz

Differential Revision: D8909426

fbshipit-source-id: 1d66d877cfa48ef06bbe614f37c66cf6c2f0446c
2018-07-20 11:37:36 -07:00
Rain ⁣
3e28228560 Back out "[mononoke][manifold] switch to thrift backed manifold client"
Summary:
The thrift client should return false or None for missing objects, but instead
errors out.

Reviewed By: StanislavGlebik

Differential Revision: D8899842

fbshipit-source-id: 81e5433ee63b7c8e6a4e898443a2a24bc784d014
2018-07-18 13:37:11 -07:00
Rain ⁣
aec68835af mercurial-types: don't overload Display for Type's manifest suffix
Summary:
I don't like this because particularly the empty string for regular
files looks weird.

Reviewed By: StanislavGlebik

Differential Revision: D8888553

fbshipit-source-id: 20a9048a19b3fdfe681160a637bc2dfc8932c113
2018-07-18 11:22:30 -07:00
Pavel Aslanov
455d59b715 fix full traversal of manifest in MemoryManifestEntry::is_empty
Summary: `MemoryManifestEntry::is_empty` caused full traversal of memory manifest

Reviewed By: sunshowers, farnz

Differential Revision: D8895341

fbshipit-source-id: 15b6d4c4e2c9ec36094fedb09d3f74a49c24bea5
2018-07-18 10:07:42 -07:00
Stanislau Hlebik
74783f77d8 mononoke: use cloned in blobrepo
Summary: Also make it possible to have mutable clones

Reviewed By: farnz

Differential Revision: D8889900

fbshipit-source-id: 77d304ec5e07c84398e328b361ebf062cd18de45
2018-07-18 04:21:42 -07:00
Stanislau Hlebik
08dd810568 mononoke: use ChangesetMetadata
Summary: Let's pass just one field instead of 4

Reviewed By: farnz

Differential Revision: D8889899

fbshipit-source-id: 8b30496a86950ed534439f5469f8740ee32345b8
2018-07-18 04:21:42 -07:00
Zeyi Fan
59103d8996 switch to thrift backed manifold client
Summary: This commit removes the usage of the old manifold client so we can get rid of `tokio_io::Remote`;

Reviewed By: jsgf

Differential Revision: D8751815

fbshipit-source-id: 41ab75076f1b2591496919ea91eb6b1d4d7ae506
2018-07-17 11:57:48 -07:00
Pavel Aslanov
894fb1e75d fixed manifest_lookup concurency issue
Summary:
Bonsai verification tool fails
`buck run mode/opt scm/mononoke:bonsai-verify -- --repo-id 1001 867ca5df5dd87de7a98ffd4495bc97ea57a8af61 --debug --limit 1 --changes`

After debuggin this run with a lot of printfs it turned out we only keeping last entry, `manifest_lookup` was to blame

Reviewed By: farnz

Differential Revision: D8875499

fbshipit-source-id: 0df4c766d55657c8c4cd7005facce715b31e733e
2018-07-17 09:22:44 -07:00
Lukas Piatkowski
24dc56c8a3 manifoldblob: remove usages of tokio_core
Summary: tokio::runtime can handle multithreading, no need for all this bolierplate

Reviewed By: StanislavGlebik

Differential Revision: D8861170

fbshipit-source-id: 2c489068a55f8cba1854f8a748df1e6efe8b47b7
2018-07-17 04:54:58 -07:00
Pavel Aslanov
6a77477d4d added BonsaiHgMapping to BlobRepo
Summary: Makes `BonsaiHgMaping` accessible from `BlobRepo` object

Reviewed By: StanislavGlebik

Differential Revision: D8821709

fbshipit-source-id: 03070ac4f9f390b76740c5d493f5a86b14024158
2018-07-13 08:03:13 -07:00
Matthew Dippel
c6fd393842 Removed RepoGenCache from the public API of revset
Summary:
Removed all references to RepoGenCache from publically callable functions in the revset package. This involved:
- Modifying blobrepo so that its get_generation_number method returned a Generation wrapper instead of a raw usize, to allow it to be used in a cleaner manner in the revset code.
- Simultaneously changing the constructors of all the structures in revset. This seems like a big change, but many of them call each other, passing a RepoGenCache object down the line, so eliminating them all at once made for the cleanest update.
- Modifying helper functions in the revset structures which would create streams of nodes by taking ownership of a RepoGenCache object within a closure. Instead they now take ownership of a clone of the repo. This strategy was already done earlier in the same helper functions, so I am assuming the cost of cloning a repo into a closure is small.
- Modifying the only external usage of revset within the mononoke server code.

This is part of a several step process to completely remove RepoGenCache from the code base. The next steps should be:
- Remove all references to RepoGenCache in the testing macros for revset.
- Delete RepoGenCache and clean up any dangling references to it.

Reviewed By: StanislavGlebik

Differential Revision: D8743560

fbshipit-source-id: 125f851075d836d40224d339e1daee912a39f7e4
2018-07-12 09:24:32 -07:00
Simon Farnsworth
d40a725f7b Refactor MemcacheBlobstore to split into common and memcache parts
Summary:
When we add cachelib bindings to Rust, we're going to want to implement a
cachelib blobstore that's more or less the same as the memcache version, but
backed by a cachelib pool instead of a memcache instance.

Split this code up so that we don't duplicate functionality

Reviewed By: StanislavGlebik

Differential Revision: D8523713

fbshipit-source-id: 882298abab8c208103f6d8c74fee60a768c877f6
2018-07-10 10:10:18 -07:00
Pulkit Goyal
fc880f518b Add Cargo.toml files to crates. (#7)
Summary:
This is a series of patches which adds Cargo.toml files to all the crates and tries to build them. There is individual patch for each crate which tells whether that crate build successfully right now using cargo or not, and if not, reason behind that.

Following are the reasons why the crates don't build:

  * failure_ext and netstring crates which are internal
  * error related to tokio_io, there might be an patched version of tokio_io internally
  * actix-web depends on httparse which uses nightly features

All the build is done using rustc version `rustc 1.27.0-dev`.
Pull Request resolved: https://github.com/facebookexperimental/mononoke/pull/7

Differential Revision: D8778746

Pulled By: jsgf

fbshipit-source-id: 927a7a20b1d5c9643869b26c0eab09e90048443e
2018-07-09 19:52:27 -07:00
Tim Fox
5adf5c109b Implement per file hooks
Summary:
This diff implements hooks which act upon individual files. The results of the hooks are cached using Asyncmemo.

The cache is currently keyed on (changeset_id, hook_name, file path) but this will change to file content hash once we move to Bonsai changesets.

Reviewed By: StanislavGlebik

Differential Revision: D8707726

fbshipit-source-id: ceaf94abd09e1dd7f6b2d8f9c87a9a221439a252
2018-07-04 07:07:02 -07:00
Pavel Aslanov
b5670e3bdc correctly handle conflicts in memory manifest
Summary:
Correctly resolve file/directory conflict in `MemoryManifest`
 - when we have file/directory conflict and have entry in `BonsaiChangeset` that indicates that file should be deleted we need resolve conflict by keeping directory
 - more details in [Bonsai changeset actions](https://fb.quip.com/A2kqArd9Nb90#WHBACA4Vitd)

Reviewed By: lukaspiatkowski

Differential Revision: D8658958

fbshipit-source-id: 815a91b847c5c0c9586eb5d317ebb9412196d5f4
2018-07-02 05:21:36 -07:00
Rain ⁣
33d7591900 blobrepo: turn manifold connection arguments into a struct
Summary:
There are so many individual arguments here that it's honestly hard to keep
track.

It is unfortunate that a bunch of string copies have to be done, but not really
a big deal.

Reviewed By: jsgf

Differential Revision: D8675237

fbshipit-source-id: 6a333d01579532a0a88c3e26b2db86b46cf45955
2018-06-28 11:46:06 -07:00
Rain ⁣
355e1a3216 admin: allow decoding Thrift-serialized structures
Summary: This will be pretty useful while debugging.

Reviewed By: jsgf

Differential Revision: D8667770

fbshipit-source-id: 1c776741844d74529415124ab826b013414678c7
2018-06-28 11:46:06 -07:00
Lukas Piatkowski
2731dca698 scuba_ext: separate static tag from dynamic message in scuba logs
Summary:
It's easier to use scuba when you separate the part of log that identifies the log from the part that can have arbitrary data in it.
It's also easier to search for code after a sample was found

Reviewed By: jsgf

Differential Revision: D8625612

fbshipit-source-id: 7d7e382530dd5d7e5d69c6d34caccda4b6d2921b
2018-06-26 02:51:40 -07:00
Stanislau Hlebik
531986e5da mononoke: rename *test_manifold to *_manifold
Summary: It's no longer test, we use it in prod

Reviewed By: farnz

Differential Revision: D8611639

fbshipit-source-id: dc52e0bcdc26c704c0d9cf820d7aa5deae3e06e4
2018-06-25 07:51:20 -07:00
Pavel Aslanov
6b1b5eb36f Bonsai::ChangeFile saving unittest
Summary: `Bonsai::ChangeFile` saving unittest

Reviewed By: farnz

Differential Revision: D8420777

fbshipit-source-id: 732da663583b160e1a4512cb287eef720d435340
2018-06-22 05:21:14 -07:00
Pavel Aslanov
cd3a0df197 merge same data different parents
Summary: This code handles "trivial merge"  (when file blob contains same data but different parents) of `MemoryManifest`

Reviewed By: farnz

Differential Revision: D8420775

fbshipit-source-id: dd0c640b8cc822d2dc42eed8f0e9a8e0a00f2cdc
2018-06-22 05:21:13 -07:00
Lukas Piatkowski
5a5688c2e7 blobrepo: add scuba logging for changeset creation
Summary: more logging more fun

Reviewed By: StanislavGlebik

Differential Revision: D8577655

fbshipit-source-id: 92a160ea8f8c0b8e012a1461fbd3f5d71b4bd171
2018-06-21 15:51:59 -07:00
Rain ⁣
93c181c35d mercurial-types: simplify Manifest API significantly
Summary:
Manifests are always able to return entries immediately, and never
fail.

Reviewed By: lukaspiatkowski, farnz

Differential Revision: D8556499

fbshipit-source-id: e21a2522f1219e47db9b55b24b6ac6c0c463933e
2018-06-20 18:22:55 -07:00
Stanislau Hlebik
1da09b3735 changesets: use connection to master only as fallback and for writes
Summary: Going to master adds a latency. Let's go to master only if we haven't found anything in the replica

Reviewed By: lukaspiatkowski

Differential Revision: D8548598

fbshipit-source-id: b0632ccf7f148d20e66763981c8ef4e615fd7f6c
2018-06-20 17:37:22 -07:00
Lukas Piatkowski
93cee8f271 filenodes: use connection to master only as fallback and for writes
Summary: we want most of the read traffic to be handled by replicas

Reviewed By: lukaspiatkowski

Differential Revision: D8548027

fbshipit-source-id: 297b070b5b33ec114026ecf3f1079fdb26f54b19
2018-06-20 17:37:22 -07:00
Rain ⁣
972822e218 blobrepo: simplify code for converting bonsai FileChange to hg
Summary:
Fetching the blob is still required to compute the node hash, but we don't have
to reupload it.

Reviewed By: farnz

Differential Revision: D8508462

fbshipit-source-id: 341a1a2f82d8f8b939ebf3990b3467ed7ad9244c
2018-06-20 13:24:57 -07:00
Rain ⁣
4eca2ec2d9 upload file blobs as Thrift data structures
Summary:
This will also allow file blob sharing between the Mercurial and Mononoke
data models.

Reviewed By: farnz

Differential Revision: D8440330

fbshipit-source-id: a29cd07dcecf0959dffb74b7428f3cb11fbd3db6
2018-06-20 13:24:56 -07:00
Rain ⁣
8b05fd5c16 blobrepo: use thrift blobs for manifests
Summary:
Store manifests as Thrift blobs instead. Required fixing up a lot of
different places, but they should all be pretty clear now.

Reviewed By: farnz

Differential Revision: D8416238

fbshipit-source-id: 523e3054e467e54d180df5ba78445c9b1ccc3b5c
2018-06-20 13:24:56 -07:00
Rain ⁣
dd3a8b59df blobrepo: improve function to get raw content
Summary:
Since file and manifest nodes are going to be stored differently, rename this to
get_hg_raw_content to make it clear that it'll work for both files and
manifests.

I tried allowing a `Chain` to be used, but ran into https://github.com/carllerche/bytes/issues/213. Boo.

Reviewed By: farnz

Differential Revision: D8413001

fbshipit-source-id: 2f06affa265beaed2ac0a48ee4fec8ce922307da
2018-06-20 13:24:56 -07:00
Rain ⁣
9ede6636a7 BREAKING CHANGE: switch to Thrift encoding for changesets
Summary:
Pretty straightforward. Also using this opportunity to add per-repo
prefixes, since all the hashes are going to break anyway.

Note for reviewers: almost all the change is regenerated test fixtures (unfortunately necessary to make atomic). The actual substantive changes are all in the first few files.

Reviewed By: farnz

Differential Revision: D8392234

fbshipit-source-id: c93fc8c6388cb00fe5cff95646ad8c853581cb8c
2018-06-20 13:24:56 -07:00
Tim Fox
7a71a18012 Introduce ChangesetStore so hook manager can get changesets from blobstore or in memory cache
Summary:
This diff introduces the ChangesetStore trait so the HookManager does not directly depend on the BlobRepo. This means the manager can obtain changesets from a simple in memory implementation of ChangesetStore which can be populated with changesets before they are committed to the server. This means the exact same hook manager logic can be used irrespective of whether the changesets are committed or not.

The diff includes two implementations of ChangesetStore - A simple in memory implementation backed by a HashMap, and one that backs onto BlobStore.

Reviewed By: StanislavGlebik

Differential Revision: D8446430

fbshipit-source-id: 8d14e48cb562fcd10a17370e34f13a662af827df
2018-06-19 20:53:00 -07:00
Simon Farnsworth
43c9f2f29a Use different memcache keys for each backing blobstore
Summary:
It would be suboptimal if memcache could be abused to examine objects
you should not have access to. Change the key used so that (a) it's a regional
cluster for wider caching, and (b) it's got the blobstore details in it so that
you cannot extract objects not from your blob store.

Reviewed By: StanislavGlebik

Differential Revision: D8424298

fbshipit-source-id: 78f9a1a7302b4a60575f257bda665f719dc1a7b6
2018-06-15 14:03:44 -07:00
Pavel Aslanov
25f253d3b4 save the file FileChange as a Mercurial format HgBlobEntry
Summary: Added logic to save `FileChange` as a Mercurial format `HgBlobEntry`

Reviewed By: sunshowers

Differential Revision: D8187792

fbshipit-source-id: 4714c81ab23ebac528cfec15c4a9e66083d4fb6c
2018-06-15 12:33:23 -07:00
Lukas Piatkowski
86e5dcae14 blobrepo: add counters for various operations done in blobrepo
Reviewed By: farnz

Differential Revision: D8449057

fbshipit-source-id: 03a2293080c49969ab4c1ae258f832c01b264239
2018-06-15 10:10:41 -07:00
Jeremy Fitzhardinge
66db975869 tp2: update to rust 1.26.2
Summary:
Update to Rust 1.26.2 toolchain, which has a fix for a soundness
problem in match ergonomics. There was one instance of code affected by this.

Reviewed By: farnz

Differential Revision: D8401773

fbshipit-source-id: 9dfdd933b1e0cf92cdc179a84ea1b67064585ba1
2018-06-13 13:45:31 -07:00
Rain ⁣
46a2603ba1 blobrepo: add the ability to prefix all blobstore gets and puts
Summary:
Note that no prefix is actually prepended at the moment -- there's an
XXX marking the spots we'll need to update. We'll probably add a prefix once Thrift serialization is turned on.

Reviewed By: farnz

Differential Revision: D8387761

fbshipit-source-id: 0fe2005692183fa91f9787b4c80f600df21d1d93
2018-06-13 13:13:07 -07:00
Pavel Aslanov
df655aad8c generic store|fetch for mononoke types
Summary:
Implementation of generic `store|fetch` for bonsai types.
 - bonsai types have unique typed hashes associated with each bonsai type, I'm leveraging this fact to implement generic `store|fetch` methods on `BlobRepo`

Reviewed By: farnz

Differential Revision: D8254810

fbshipit-source-id: 5f798fade4cb8d1ac851f94c7ad7e64636bbca65
2018-06-13 02:35:32 -07:00
Rain ⁣
e3ff3de80c blobstore: move memblob into main blobstore
Summary: It's really straightforward and useful for internal blobstore testing.

Reviewed By: farnz

Differential Revision: D8374496

fbshipit-source-id: 8501e31218ecb5d80530a114e0be5e5d0e8f6c91
2018-06-12 15:40:10 -07:00
Rain ⁣
ed033f2b25 store and return p1 and p2 separately for changesets
Summary:
Unfortunately `HgParents` can't represent all valid parents, because
it can't represent the semantically important case where `p1` is `None` and
`p2` is not. (For incoming changesets we'd like to keep full fidelity with
Mercurial.)

All the Thrift definitions store `p1` and `p2` separately anyway, so just make
that change throughout `RevlogChangeset` and `BlobChangeset`.

Reviewed By: StanislavGlebik

Differential Revision: D8374125

fbshipit-source-id: 63674daaad05d4d4cae3778744dbf1c14b3c2e3b
2018-06-12 15:40:10 -07:00
Rain ⁣
3665c48fc7 remove the old blobimport tool
Summary:
The old blobimport tool will not be able to import commits with the new Thrift serialization they'll be switching to.

`blobrepo::utils::RawNodeBlob` is also used by the admin tool, and it will go away once we start using Thrift serialization.

Reviewed By: farnz

Differential Revision: D8372455

fbshipit-source-id: d02a37e33e1ccd4dd1f695e38dbb40851dd51cd6
2018-06-12 15:40:10 -07:00
Rain ⁣
72ba438c95 switch fixture generation to new_blobimport
Summary:
Mostly this was about adding support for file stores to
`new_blobimport`.

Reviewed By: StanislavGlebik

Differential Revision: D8372063

fbshipit-source-id: 2e3791c6222ec430015008f038e1df0464d3f0ba
2018-06-12 15:40:10 -07:00
Lukas Piatkowski
18d475fb9a filenodes: separate pool of connection for writes from reads
Summary: There shouldn't be more than one thread writing to the database, because it causes lags in slaves and they race for database locks between themselves. One write connection should be sufficient enough.

Reviewed By: StanislavGlebik

Differential Revision: D8348604

fbshipit-source-id: ceef081ed89611978accfa55969883078d65a58f
2018-06-11 06:38:14 -07:00
Lukas Piatkowski
c90ee251ab blobrepo: add more cotext around processing and fetching from blobstore
Summary: Lack of proper error context makes it hard to understand errors returned from Mononoke

Reviewed By: StanislavGlebik

Differential Revision: D8298154

fbshipit-source-id: 57fe5df7d891b5215fba783255178f14122199cf
2018-06-08 05:33:41 -07:00
Lukas Piatkowski
186d9ec623 blobrepo: improve error contexts for ChangesetCreate
Summary: the newly added context should add much more visibility into why an error was returned

Reviewed By: jsgf

Differential Revision: D8286343

fbshipit-source-id: d65387f40da2c14964e85552ae1ec7e75a135c47
2018-06-08 05:33:41 -07:00
Lukas Piatkowski
4f44c3f130 mercurial_types: remove D* types and move mercurial types around
Summary:
Now it is as it should be: mercurial_types have the types, mercurial has revlog related structures
burnbridge

Reviewed By: farnz

Differential Revision: D8319906

fbshipit-source-id: 256e73cdd1b1a304c957b812b227abfc142fd725
2018-06-07 13:19:16 -07:00
Rain ⁣
e18b0c3676 blobrepo: factor out local state initialization code
Summary: Factor out common stuff for local state.

Reviewed By: StanislavGlebik

Differential Revision: D8310823

fbshipit-source-id: e1ce7eebd76d37688e830a5df0486bdfd1e3361c
2018-06-07 09:51:31 -07:00
Lukas Piatkowski
0aa3c76930 blobrepo: lower severity level of "Upload blob stats" log
Summary: This log is by far the most common one and it makes reading logs much harder. It should probably be changed to ODS counters, but for now lets just make it trace!

Reviewed By: farnz

Differential Revision: D8235663

fbshipit-source-id: 3685b260f1c6c43c1fde8501731583debc8d063b
2018-06-05 13:48:28 -07:00
Lukas Piatkowski
27bdcb40b2 filenodes: control size of the connection pool
Summary:
The new_blobimport job is having difficulties when the pool is too large, because the write transactions are taking too long. If the pool is configured to be 1 for it then everything seems fine and fast enough.
On the other hand the Mononoke server should have bigger connectino pool size to be able to quickly respond for read requests.

Reviewed By: farnz

Differential Revision: D8235413

fbshipit-source-id: 84e0013ce569c3f103a2096001605aab828d178c
2018-06-05 05:58:31 -07:00
Jeremy Fitzhardinge
a2daf8c2d5 mononoke: no need to pass Mysql connection params by value
Summary: It only needs to borrow them.

Reviewed By: kulshrax

Differential Revision: D8244267

fbshipit-source-id: 2a24a3b7c6eb65177e4e26c57650dd7e096b4202
2018-06-04 08:51:25 -07:00
Stanislau Hlebik
3ab7c84382 mononoke: rename path to dirname
Summary:
I got confused myself, so decided to rename it.

dirname here means "all the path without the last path component". So for directory "a/b/c", "a/b" is a dirname. For file "a/b.txt", "a" is a dirname For root dirname is empty.

Reviewed By: jsgf

Differential Revision: D8207274

fbshipit-source-id: 0744ee020d3cf1ecc185efee445f6d40183d6366
2018-06-01 02:22:52 -07:00
Simon Farnsworth
d39f6bc82e Improve style in memory_manifest.rs
Summary:
This is a follow-on from D8014913 (Make in-memory manifests load lazily), addressing jsgf's review comments.

I've made the following stylistic changes:

1. Use `impl Future` for all private APIs instead of `BoxFuture` (making use of `Either` instead of boxing where possible).
2. Use Rust 1.26 style `match` statements with inferred `ref` and `&` whenever possible.
3. Rework the logic in `MemoryManifestEntry::save` to not need `filter_map`.
4. Remove `future::result` and exploit `impl IntoFuture for Result` where possible to reduce code
5. Improve a couple of comments

Reviewed By: jsgf

Differential Revision: D8209186

fbshipit-source-id: c759ad8894fc25616dc6a291d46c487191f96382
2018-05-30 14:42:04 -07:00
Lukas Piatkowski
60610bfdd7 blobrepo: upload filenodes in parallel
Summary: The filenodes were uploaded serially, this caused significant performance losses.

Reviewed By: StanislavGlebik

Differential Revision: D8202109

fbshipit-source-id: 8ccc3f7bfa736d51a980e206f9868a0168b2d1b4
2018-05-30 12:06:27 -07:00
Lukas Piatkowski
0eb217cdf8 blobrepo: move signal_parent_ready before processing the entires
Summary: Since signal_parent_ready purpose is to ensure that the child Changesets might perform their own checks it is good enough to send signal_parent_ready after all blobs have been written out, but before the parent did it's own checks

Reviewed By: farnz

Differential Revision: D8202108

fbshipit-source-id: 15ac85bd18bcf9ded61363a6380ad05462c189d6
2018-05-30 12:06:27 -07:00
Simon Farnsworth
e1a783d3e6 Add a Memcache-backed caching blobstore
Summary:
Memcache provides us with a low-latency out-of-process cache, shared
between multiple machines. If we use this to provide a write-through cache,
then we get a couple of benefits:

1. Mononoke servers accessing the same memcache backend get low latency access
to commonly requested blobs.
2. Recently written blobs are available at low latency to the server that just
wrote them, hopefully speeding up new_blobimport.

Reviewed By: StanislavGlebik

Differential Revision: D8124623

fbshipit-source-id: 5af085aa8bb63c1366740edfda9020d72b8a9015
2018-05-30 07:21:15 -07:00
Lukas Piatkowski
586bf6089a blobrepo: parallelize process_entries
Summary:
instead of doing for_each which causes the entries to be processed one-by-one use the map + buffer_unordered technique
This has speeden up new_blobimoprt of 2 commits from >2m to <1m30s

Reviewed By: farnz

Differential Revision: D8184176

fbshipit-source-id: 4a0c3124d2398ed41f8b93785bc3c890a23a88aa
2018-05-30 06:26:38 -07:00
Stanislau Hlebik
e874915f83 mononoke: use get_all_filenodes
Summary:
In previous diffs we've added a function that does a bulk prefetch of
filenodes. Now we can use it in the getfiles request handling code.

Before constructing file history we do a bulk prefetch. Then we use
results of the bulk prefetch as a cache. It means that we first check
whether we have file history node in the prefetched data, and if not it will be
fetched again. It allows us to later plugin a memcache or some other kind of
cache.

repo.rs file is getting bigger and bigger. I'm planning to split it, however
only after I land this diff in order not to deal with merges

Reviewed By: farnz

Differential Revision: D8185701

fbshipit-source-id: 6ca37aeb029236db51d2b5a03cb7053f969cf47e
2018-05-30 04:36:48 -07:00
Simon Farnsworth
2e24a77e85 Rename CachingBlobstore to MemoizedBlobstore
Summary:
I'm about to introduce a MemoizedBlobstore - let's ensure that
ambiguity is kept to a minimum by renaming CachingBlobstore

Reviewed By: jsgf

Differential Revision: D8124625

fbshipit-source-id: 301fbb31c5a772c11e84566889b8a6ac86cdae19
2018-05-29 10:08:16 -07:00
Simon Farnsworth
e33d05223f Make CachingBlobstore generic, to allow optimization through the Arc
Summary:
In practice, caching blobstores are always wrapped around a known
concrete blob store. Make it generic in the type of the Blobstore, so that
rustc can reach in and inline appropriately if it sees an optimization
opportunity.

This is a micro-optimization, hence nice to have

Reviewed By: StanislavGlebik

Differential Revision: D8124627

fbshipit-source-id: 0d5d9b11fdede062ceaa949ace574b3d1c75e6b5
2018-05-29 10:08:16 -07:00
Simon Farnsworth
32f8f01e82 RFC: [mononoke] Use memory_manifest to generate Mercurial from Bonsai form
Summary:
We want to be able to go to and from Bonsai Changesets in Mononoke, so
that we can operate with Mercurial clients that haven't yet been updated to
support Bonsai form. This RFC commit shows a shell of doing so, as an
illustration for the hackamonth task

Reviewed By: jsgf

Differential Revision: D8014909

fbshipit-source-id: 28adf18ecf80e0116290662c117731b4c1632ff9
2018-05-29 08:52:54 -07:00
Simon Farnsworth
11019c0a7e Make in-memory manifests load lazily
Summary:
Loading the entire manifest tree just for a limited set of conflicts
and changes is wasteful. Lazily load the referenced parts of the tree instead

Reviewed By: jsgf

Differential Revision: D8014913

fbshipit-source-id: 07678bee39de02414fdc062cf680fcd049a28415
2018-05-29 08:52:54 -07:00
Lukas Piatkowski
bce740ec29 blobrepo: sort list of changed files as mercurial would sort them
Reviewed By: StanislavGlebik

Differential Revision: D8159064

fbshipit-source-id: d1d5141aa2b84bfc48a2edc6d0cd3959b69cef93
2018-05-25 03:51:37 -07:00
Lukas Piatkowski
3a7893942b blobrepo: print Blob content when hash consistency check failed
Reviewed By: StanislavGlebik

Differential Revision: D8144316

fbshipit-source-id: 1b98b2bf0814bde2539d610580ec8a5e842bb27f
2018-05-25 03:05:37 -07:00
Lukas Piatkowski
86490e1ea5 new_blobimport: add --skip, --commits-limit and --changeset flags
Summary:
Those flags will let us control the subset of commits that the new_blobimport is supposed to import.
It's a temporary solution to be used instead of the old blobimport but before "hg push" works

Reviewed By: farnz

Differential Revision: D8122318

fbshipit-source-id: a1ac0824020341cd4bb18ec46d91caee50d9606e
2018-05-23 13:25:25 -07:00
Simon Farnsworth
02ce7eee2d Remove Result from HgBlobEntry constructor
Summary:
This could never fail - so don't allow for failure, but use the type
system to deal with the error case.

Reviewed By: jsgf

Differential Revision: D8014910

fbshipit-source-id: 8f5f0a3ff55a96b57cd4c246d072793c986724d5
2018-05-22 12:22:24 -07:00
Simon Farnsworth
0d8fd3e491 Make conflict handling a thing, albeit with asserts
Summary:
We want to handle conflicts here - do so, but with asserts, by merging
two manifests together.

The asserts will be removed once we make this all lazy

Reviewed By: jsgf

Differential Revision: D8014912

fbshipit-source-id: 7a09186f7e24a3af93d15a859c877e3a319fb110
2018-05-22 12:22:24 -07:00
Simon Farnsworth
05acc629e0 Make memory manifests use less mutation
Summary: Once we have a lazy loading version, we'll want a way to cope with multiple accessors all trying to update the same `children` array with identical data; make it immutable in use, so that overwriting it multiple times is harmless

Reviewed By: jsgf

Differential Revision: D8014908

fbshipit-source-id: 9a2750fb1fca54601051fede1d9a37de8cfc2a74
2018-05-21 06:57:34 -07:00
Simon Farnsworth
2a1b5533c3 Add and remove items from memory manifests
Summary:
We're going to need to be able to edit memory manifests. Provide
remove and set operations, to match the Bonsai Changeset data structures

Reviewed By: StanislavGlebik

Differential Revision: D7620527

fbshipit-source-id: e85459c5dbfa8855267fd2cf6578c9fc39f223f8
2018-05-16 09:35:28 -07:00
Simon Farnsworth
0ff53dd012 Skip empty manifests on save
Summary:
Removing entries can leave us with empty manifests. Rather than clean
that up mid-flow, simply skip empty manifests when saving

Reviewed By: StanislavGlebik

Differential Revision: D7620526

fbshipit-source-id: 2f0799eba305a5295eaad28cd4ad90c9de04306f
2018-05-16 09:35:28 -07:00
Simon Farnsworth
5cfff4305d Make it possible to keep the manifest tree in memory
Summary:
To do Bonsai Changesets, we're going to need to perform surgery on
manifests. Provide a mechanism to get the Tree nodes only into memory, and
write them back out, so that we can do the surgery the easy way.

Reviewed By: StanislavGlebik

Differential Revision: D7557271

fbshipit-source-id: 7afdc3ef464fc042eb758af863ade8938c4e9fc5
2018-05-16 09:35:28 -07:00
Simon Farnsworth
4f1a5d8ea1 Make it possible to generate hashes for uploaded content during upload
Summary:
Previously, we assumed that all content hashes came from Mercurial;
this is not going to remain true, as we will want to be able to upload manifests
that have been synthesised from Bonsai Changesets. Turn the previous boolean
into a tri-state, and fix up all callers to get the behaviour they expect.

Reviewed By: StanislavGlebik

Differential Revision: D8014911

fbshipit-source-id: 9156b9fab4542ceb269626ad005e1b28392b5329
2018-05-16 09:35:28 -07:00
Jeremy Fitzhardinge
51c49a47be tp2: update to rust 1.26.0 and corresponding rust-crates-io rebuild
Summary:
Rust 1.26 adds many new language features. In particular `impl Trait` is now
stable, so we no longer need `conservative_impl_trait`.

There also seems to have been changed in the (unstable) TryFrom with respect to
usize, and the behaviour of the never type `!`.

There are still a few deprecation warnings, but they don't cause the build to
fail.

Path remapping is now stable, so the buck config needs to change to use it
rather than the unstable command line option.

TODO:
- get aarch64 rust-crates-io build (can defer to a later update)

Reviewed By: Imxset21

Differential Revision: D7966091

fbshipit-source-id: 2e61e262c21eb01c852a36f49c6a6369cdaddcdb
2018-05-11 11:07:33 -07:00
Stanislau Hlebik
37db2d0ff7 mononoke: configure Manifold QPS via config option
Summary:
This is a (hopefully) short term hack to overcome the problem of overloading
Manifold.
Ideally manifold client has to adjust dynamically to the load. However
implementing it is
not trivial, so for now let's configure via config option.

Reviewed By: jsgf

Differential Revision: D7910979

fbshipit-source-id: c2dc32b592747732e7e6574e0fecf2d0aaef447e
2018-05-10 02:02:39 -07:00
Stanislau Hlebik
88051823df mononoke: simple precaching
Summary:
Simple precaching. Reads all the manifests for a bookmark and up to
`commit_warmup_limit` of ancestors.

Warming up file content can be slow, so we don't do it now.

Reviewed By: jsgf

Differential Revision: D7863728

fbshipit-source-id: bed1508b01e4e002a399d00ea45faf8a8e228d0a
2018-05-10 02:02:34 -07:00
Stanislau Hlebik
e99fce6bd4 mononoke: add separate types for Bookmark and BookmarkPrefix
Summary:
This will make it easier to change the "real" bookmark type from AsciiString to
String if we decide to do that.

BookmarkPrefix is a separate type because we may want to change it from
AsciiString to String. Also we don't want to confuse a bookmark prefix with a
bookmark name.

Reviewed By: jsgf

Differential Revision: D7909992

fbshipit-source-id: 3d4d075c204ed5ef1114a743430982c2836bac04
2018-05-09 02:11:17 -07:00
Jeremy Fitzhardinge
22bc45bf1f mononoke: migrate DelayBlob to new timer model
Summary:
We don't need to explicitly create timers since the environment has
one set up by default.

Reviewed By: StanislavGlebik

Differential Revision: D7873576

fbshipit-source-id: bfcdc27a46397bff0730f64ad4f3de3865c7cfa1
2018-05-04 10:15:26 -07:00
Stanislau Hlebik
12968b1b9e mononoke: make it possible to fetch config repo by bookmark
Summary: It will make deploying mononoke considerably easier

Reviewed By: farnz

Differential Revision: D7831620

fbshipit-source-id: 77db867f5ce03975eadea7a8693bc88c1d1122cd
2018-05-03 10:31:32 -07:00
Stanislau Hlebik
b94f7fe0c1 mononoke: use many threads for the blobstore
Summary:
Let's use the new feature in SendWrapper to use many io threads. That will help
us mitigate the high cpu usage issues we were having with blobstore requests.

Manifold blobstore now creates the io threads itself.

Reviewed By: kulshrax

Differential Revision: D7831420

fbshipit-source-id: ec9f3327347ca6bfbd23c482e69a6fee663b1da5
2018-05-03 10:31:32 -07:00
Stanislau Hlebik
b3432410ae mononoke: use caching for filenodes
Summary: As with changesets and blobs, let's cache filenodes data

Reviewed By: jsgf

Differential Revision: D7831105

fbshipit-source-id: 334cb474f5cc3ef8dba0945d11273b2b3875e8ad
2018-05-03 10:31:32 -07:00
Stanislau Hlebik
a5f31946ac mononoke: revsets optimized for pull
Summary:
Specialized revsets to make pull faster.
Previous Union + Intersect combination was extremely slow because it fetched a
lot of stuff that wasn't used.

Reviewed By: farnz

Differential Revision: D7829394

fbshipit-source-id: c038f184c305e48e18b6fcb0f83bab9e9a42b098
2018-05-02 02:23:43 -07:00
Lukas Piatkowski
3232bfa4b2 blobrepo: accept a list of exepcted changed files for Changeset creation
Summary:
The commits that are blobimported have out of order or simply incorrect lists of changed files.
Because we have to persists Changesets as is we are passing the untouched list of files here to be used by Changeset.

Reviewed By: farnz

Differential Revision: D7830310

fbshipit-source-id: 56adec2c317896decaa9176b3a6bfb0cab187ed0
2018-05-01 16:35:08 -07:00
Lukas Piatkowski
4d854a243e blobrepo: verify that the Changeset's hash provided by client matches our computed hash
Reviewed By: jsgf

Differential Revision: D7779664

fbshipit-source-id: c844c41c1ff825babe653e4d2caa98348ad34483
2018-04-28 16:33:03 -07:00
Lukas Piatkowski
346183fa8c blobrepo: fix delta application by applying it on raw content of filenode
Summary: The deltas are meant to be applied on raw filenode content that has incorporated copy/move information. Make it so

Reviewed By: jsgf

Differential Revision: D7777329

fbshipit-source-id: 23ce90269cdf5dbb8a16aab026c031c2af68fccb
2018-04-28 16:33:03 -07:00
Lukas Piatkowski
18800e00ea heads: remove related crates
Summary: the idea of Mercurial heads in Mononoke will be represented by bookmarks, so there is no need to have them around

Reviewed By: StanislavGlebik

Differential Revision: D7775032

fbshipit-source-id: 1618a1e51862d7c115b2955082f40ee890a045f1
2018-04-27 04:35:21 -07:00
Lukas Piatkowski
b8961c0bd7 blobrepo: use real MySql db instead of in memory Sqlite for test manifold blobrepo
Reviewed By: StanislavGlebik

Differential Revision: D7774623

fbshipit-source-id: 4c866f20d103521212bba757a448f5f7afb5c412
2018-04-26 13:21:56 -07:00
Lukas Piatkowski
35656a1e7d blobrepo: use all server side bookmarks as heads for the sake of discovery
Summary: Although this change is breaking with the traditional definition of heads in Mercurial, we decided that using bookmarks as heads is sufficient for fbsource use case as well as it matches the git model where every unnamed branch is garbage collected.

Reviewed By: jsgf

Differential Revision: D7745541

fbshipit-source-id: 2ec716db7799bf7bab8b2b77a85d1521a880f3df
2018-04-25 04:22:19 -07:00
Lukas Piatkowski
7e6b69046c blobrepo: persist bookmarks in on-disk Sqlite database
Summary: For on-disk-rocksdb use cases we should persist bookmarks like any other table we use

Reviewed By: farnz

Differential Revision: D7728717

fbshipit-source-id: f63a6410f5ed254a719a16a7504d1b31da5a20a8
2018-04-24 11:17:06 -07:00
Lukas Piatkowski
f28ce26504 blobrepo: handle changesets with null root manifests
Summary: The eden integration test contains a commit with no content which new_blobimport couldn't import. With this changes the commit API is capable of handling such commits.

Reviewed By: jsgf

Differential Revision: D7709243

fbshipit-source-id: 7d55eb2ec421820d189ab05b0f8cb4411f850a7b
2018-04-24 11:17:06 -07:00
Lukas Piatkowski
2187aa38ef blobrepo: fix compute_changed_files bug - use intersection instead of symmetric difference
Summary: The problem in compute_changed_files is that for 2 parents given instead of producing a list of files that were changed in the merge commit from perspective of both parents it produced the opposite of that. This should fix it

Reviewed By: jsgf

Differential Revision: D7708215

fbshipit-source-id: d58457054625beb853f61cb060d25b09279ecceb
2018-04-24 11:17:06 -07:00
Stanislau Hlebik
3f600af142 mononoke: add Changesets cache
Summary:
Use asyncmemo to cache Changesets.

Unfortunately currently we are using separate asyncmemo cache, so we have to
specify the size for the caches separately. Later we'll have a single cache for
everything, and the number of config knobs will go down.

Reviewed By: lukaspiatkowski

Differential Revision: D7685376

fbshipit-source-id: efe8a3a95fcc72fab4f4af93564e706cd1540c2f
2018-04-22 04:59:27 -07:00
Stanislau Hlebik
a48e52fb7e mononoke: use caching blobstore
Summary:
Let's use it! Pass config option that set's the cache max memory usage (don't
put a limit on the number of entries, it's useless in that case).

Currently we'll set a separate size for each of the caches that we use
(blobstore, changesets, filenodes, etc). Later we'll have just one single option that
sets the cache size for all of them.

Reviewed By: lukaspiatkowski

Differential Revision: D7671814

fbshipit-source-id: f9571078e6faaa80ea4c31c76a9eebcc24d8a68a
2018-04-22 04:59:27 -07:00
Siddharth Agarwal
c652345586 blobrepo: optionally verify that provided and computed entry hashes are consistent
Summary:
We know that the hashes for non-root-tree-manifests and filenodes
should always be consistent. Verify that.

Reviewed By: farnz

Differential Revision: D7704087

fbshipit-source-id: 7f6207878c5cd372b272aa6970506dd63b5a3c7c
2018-04-20 08:40:54 -07:00
Siddharth Agarwal
9b5ee510cb blobrepo: use the incoming provided hash as the blobstore key instead of computing it
Summary:
As the comment explains, sometimes the hashes don't match the
contents. Accept such pushes.

Reviewed By: farnz

Differential Revision: D7699930

fbshipit-source-id: 376f01b6cf03f6cad84c2c878d192d55f8d81812
2018-04-20 08:40:54 -07:00
Siddharth Agarwal
16c35f6aac blobrepo: some improvements to test utils
Summary:
* `Into<Bytes>`, not `Into<String>`
* Centralize in one place because I'm going to be adding more non-trivial code to this in upcoming diffs

Reviewed By: farnz

Differential Revision: D7694764

fbshipit-source-id: e6373cf1562b9a464894466ecf3be59e9892ac78
2018-04-20 08:40:54 -07:00
Siddharth Agarwal
9e49e6da1a blobrepo: make upload_entry arguments named, move to Hg domain
Summary:
We're going to keep this around for now as part of double-writing.
All the hashes here are definitely Mercurial hashes, so use them that way.

Reviewed By: lukaspiatkowski

Differential Revision: D7683890

fbshipit-source-id: 270091cd11f3cec7ef4cf565de5ef913fcf7adea
2018-04-20 08:40:54 -07:00
Siddharth Agarwal
3591b86b9f mercurial: switch file::File to HgNodeHash
Summary:
file::File works entirely in the Mercurial domain, so these
conversions are good.

Reviewed By: StanislavGlebik

Differential Revision: D7665973

fbshipit-source-id: 8a192c5d1886492ad21593693b080c8e5ddf8f7e
2018-04-20 08:40:54 -07:00
Siddharth Agarwal
ed1c842dcd blobrepo: rename BlobEntry to HgBlobEntry
Summary:
This is because these Mercurial entries are (at least currently) going
to be stored as they come in, and this data structure is entirely in the
Mercurial domain.

Reviewed By: lukaspiatkowski

Differential Revision: D7664972

fbshipit-source-id: 9de5475eed0d7ab7085c29fd0282f205043cfe5a
2018-04-20 08:40:54 -07:00
Siddharth Agarwal
65e4e05ed1 bundle2-resolver: also upload Thrift-encoded content blobs
Summary:
This is the first step to getting bonsai changesets into the blob store.

So far the code just waits for content blob uploads to be done. In future diffs Mononoke will synthesize this information into a bonsai changeset as well.

Reviewed By: lukaspiatkowski

Differential Revision: D7627784

fbshipit-source-id: da0c96772ce4d18aed579cecca6135137a8dbe18
2018-04-20 08:40:54 -07:00
Siddharth Agarwal
7dc019e422 blobrepo: add some context + clean up error messages
Summary:
I was trying to debug something with the new blobimport, and this was
getting in the way.

Reviewed By: StanislavGlebik

Differential Revision: D7664660

fbshipit-source-id: 2ec4ee79fbe13584f35e7dcd9e8df2b8bdf181c0
2018-04-18 19:53:34 -07:00
Siddharth Agarwal
41824251b8 bundle2-resolver: add some comments around the use of Shared
Summary:
This confused me at first -- took me a while to figure out what's going on
here. Hopefully these comments will help the next person who stares at this
code.

Reviewed By: StanislavGlebik

Differential Revision: D7659993

fbshipit-source-id: a009041501f9108d2c01532e9df793cfcecb5496
2018-04-18 19:53:34 -07:00
Siddharth Agarwal
1cd28c2587 blobrepo: use named args for creating a changeset
Summary:
The list of arguments is becoming too long, and I need to add even
more here.

Reviewed By: StanislavGlebik, farnz

Differential Revision: D7652096

fbshipit-source-id: 62a4631e163e95cf5c950a949e72facab629ea54
2018-04-18 19:53:34 -07:00
Siddharth Agarwal
8282139719 mercurial-types: use the base DateTime from mononoke-types
Summary:
The base type is better because it can represent dates from before
1970 as well.

Reviewed By: StanislavGlebik

Differential Revision: D7652095

fbshipit-source-id: 6d66a06e18ba28e13e70b9f0e921acbd3d55baaf
2018-04-18 19:53:33 -07:00
Siddharth Agarwal
4e9f826728 blobstore: restrict the types that can be stored
Summary:
Currently, any sort of `Bytes` can be stored in the blobstore. That
caused me to make several mistakes while writing the code to store bonsai
changesets, because I'd just end up storing the wrong set of `Bytes`.

Introduce stronger typing so that only types that explicitly implement
`BlobStorable` can be stored in the blobstore.

Currently, these sorts of blobs can be stored in the blob store:

* `ChangesetBlob` and `ContentBlob` in `mononoke-types` (these are Thrift-serialized structures)
* The envelope `RawNodeBlob` and `RawCSBlob` types in `blobrepo`, once converted to `EnvelopeBlob` instances
* `HgBlob`, which contains revlog data (manifests or files) exactly as serialized by Mercurial

Reviewed By: StanislavGlebik

Differential Revision: D7627290

fbshipit-source-id: d1bcbde8881e365dec99618556e7b054985bccf7
2018-04-18 19:53:32 -07:00
Stanislau Hlebik
b60d44f4b8 mononoke: use MysqlChangesets for manifold-based blobrepo
Summary: Let's use real changesets storage

Reviewed By: lukaspiatkowski

Differential Revision: D7585246

fbshipit-source-id: f73bf81d86286de802655f032f721fb0e3780623
2018-04-18 04:09:09 -07:00
Stanislau Hlebik
23ce735b81 mononoke: add xdb tier to the config and use it for filenodes
Summary:
Pass mysql tier name to the BlobRepo, so that we can use it to connect to mysql
based storages like mysql changeset storage, filenodes storage etc.

Note that currently Filenodes storage only connects to master region. This will
be fixed in the later diffs

Reviewed By: lukaspiatkowski

Differential Revision: D7585191

fbshipit-source-id: 168082abfeb7ccba549c7a49e6269cc01c490c14
2018-04-18 04:09:09 -07:00
Lukas Piatkowski
c7299331b7 blobrepo: add comments about conversions between NodeHash types
Reviewed By: sid0

Differential Revision: D7655357

fbshipit-source-id: 5b3cf3eb93dc3de0d6ecb232a04b4fdc1f827674
2018-04-18 03:30:07 -07:00
Siddharth Agarwal
e120f886ec blobrepo: use improved file API
Summary:
This helps out with the stricter-types-in-blobstore work I'm doing,
and is nice cleanup anyway.

Reviewed By: StanislavGlebik

Differential Revision: D7625562

fbshipit-source-id: c27901ef94a03a716368403b63a6afd74a1c2a90
2018-04-17 11:37:29 -07:00
Siddharth Agarwal
4b607998bf mercurial: some improvements to File API
Summary:
Now that `BlobNode` no longer returns `None`:

* don't expose the `BlobNode` API outside the crate because it turns out to not be very useful (it should probably go away eventually?)
* make the `File` API not return `Option` types
* Add a new `file_contents` that returns a brand-new `FileContents` (this is the first time we're tying together Mercurial and Mononoke data structures!)

Also remove a `Symlink` API that isn't really correct honestly.

Reviewed By: StanislavGlebik

Differential Revision: D7624729

fbshipit-source-id: 38443093b8bfea91384c959f3425cf355fac9f65
2018-04-17 11:37:29 -07:00
Siddharth Agarwal
cc57855b90 mercurial: use FileContents for file contents
Summary:
This is not only the newer, more specific type -- it also makes a couple
of upcoming diffs more straightforward.

Reviewed By: StanislavGlebik

Differential Revision: D7622906

fbshipit-source-id: 4e453b827512c538f4f9777ae4d24627f3b124cf
2018-04-17 11:37:29 -07:00
Lukas Piatkowski
7114d4cb42 blobrepo: make RevlogChangest parsing into ChangesetContent explicit
Summary: Having an implicit `From` parsing makes it hard to track the exceptional places where RevlogChangest can be directly translated to BlobChangeset. Make it explicit for better tracking of this behavior

Reviewed By: StanislavGlebik

Differential Revision: D7637247

fbshipit-source-id: 781341315102ea6b2265c33bb09a89aae3d0c329
2018-04-17 05:26:27 -07:00
Siddharth Agarwal
cf81c04664 move raw blob serialize/deserialize to a central location
Summary:
I'm going to put in some stronger typing around what can be stored in
the blob store. Centralizing the management here makes that much easier.

Reviewed By: StanislavGlebik

Differential Revision: D7619519

fbshipit-source-id: a428679018f0a1571e54bc01bb5483ba9fdf1cb5
2018-04-16 17:16:28 -07:00
Lukas Piatkowski
10857e6a37 CODEMOD: rename mercurial::BlobNode to HgBlobNode
Reviewed By: sid0

Differential Revision: D7620628

fbshipit-source-id: 8d616c3b9cd3342f71155f11bcef4feb760ddf0e
2018-04-16 03:40:25 -07:00
Lukas Piatkowski
086640fdd0 CODEMOD: rename mercurial_types::BlobNode to DBlobNode
Summary: mercurial_types::DBlobNode should be replaced by types from mononoke_types or mercurial in most cases. This rename should help with tracking this

Reviewed By: sid0

Differential Revision: D7619793

fbshipit-source-id: 261fd92acae825dc4bc8011c3716c5585eb0413c
2018-04-16 03:40:25 -07:00
Lukas Piatkowski
9436963e20 CODEMOD: rename mercurial_types::Parent to DParent
Summary: mercurial_types::DParent should be replaced by types from mononoke_types or mercurial in most cases. This rename should help with tracking this

Reviewed By: sid0

Differential Revision: D7619686

fbshipit-source-id: 5ad105113779387f1408c806860483e06ed5fb3d
2018-04-16 03:40:25 -07:00
Lukas Piatkowski
c35a537aaa CODEMOD: rename mercurial_types::EntryId to DEntryId
Summary: mercurial_types::DEntryId should be replaced by types from mononoke_types or mercurial in most cases. This rename should help with tracking this

Reviewed By: sid0

Differential Revision: D7619571

fbshipit-source-id: bf8d81ec9ffe6a5525d923d7ee67d8e92498aa4d
2018-04-16 03:40:24 -07:00
Lukas Piatkowski
73034a99b2 CODEMOD: rename mercurial_types::HgFileNodeId to DFileNodeId
Summary: mercurial_types::DFileNodeId should be replaced by types from mononoke_types in most cases. This rename should help with tracking this

Reviewed By: sid0

Differential Revision: D7619290

fbshipit-source-id: aa6a8e55ae3810c4531028c3b3db2e5730fe7846
2018-04-16 03:40:24 -07:00
Lukas Piatkowski
7e05a01ce5 CODEMOD: rename mercurial_types::HgManifestId to DManifestId
Summary: mercurial_types::DManifestId should be replaced by types from mononoke_types in most cases and by mercurial::HgManifestId in others. This rename should help with tracking this

Reviewed By: sid0

Differential Revision: D7619062

fbshipit-source-id: 447224194c6555334b64dc29ebabe3ef0d0cb87e
2018-04-16 03:40:24 -07:00
Lukas Piatkowski
f6c3f72745 CODEMOD: rename mercurial_types::HgChangesetId to DChangesetId
Summary: mercurial_types::DChangesetId should be replaced by types from mononoke_types in most cases and by mercurial::HgChangesetId in others. This rename should help with tracking this

Reviewed By: sid0

Differential Revision: D7618897

fbshipit-source-id: 78904f57376606be99b56662164e0c110e632c64
2018-04-16 03:40:24 -07:00
Lukas Piatkowski
16cbfd5133 CODEMOD: rename mercurial_types::NodeHash to DNodeHash
Summary: mercurial_types::NodeHash should be replaced by types from mononoke_types in most cases and by mercurial::NodeHash in others. This rename should help with tracking this fact.

Reviewed By: sid0

Differential Revision: D7618389

fbshipit-source-id: a876e723d911df626c7851fba56a056843b4e049
2018-04-16 03:40:24 -07:00
Siddharth Agarwal
f7c39a56c8 blobrepo: add some comments around copy info
Summary:
I haven't actually fixed the bug here because that's quite a bit of work that
will hopefully soon be somewhat moot.

Reviewed By: StanislavGlebik

Differential Revision: D7594278

fbshipit-source-id: b29861c71628a7dc903d6405c3348a9e41002fba
2018-04-13 11:34:14 -07:00
Lukas Piatkowski
dd3c638c1d api cleanup: clean api of mercurial and mercurial_types NodeHash
Summary:
This is a cleanup of NodeHash API. There were few unused methods and few ways to convert between mercurial and mercurial_types hashes. With this diff it is very easy to identify the places where this converstion happens.
A followup of this diff will be to use this new API to easily replace the NodeHash convertions in places where it requires remapping.

Reviewed By: sid0

Differential Revision: D7592876

fbshipit-source-id: 6875aa6df1a3708ce54ca5724f6eb960d179192b
2018-04-13 10:00:03 -07:00
Stanislau Hlebik
89befdb26d mononoke: avoid using linknodes
Summary: They are replaced by filenodes

Reviewed By: farnz

Differential Revision: D7443320

fbshipit-source-id: 13c7d07bc00dcbaa991663c8da8a07fcb0de1332
2018-04-13 02:47:24 -07:00
Siddharth Agarwal
8e7a1acc0f mercurial-types: rename Blob to HgBlob
Summary:
This will probably go away soon, but for now I want to be able to
disambiguate the new Thrift-encoded blobs in Mononoke from these.

Reviewed By: StanislavGlebik

Differential Revision: D7565808

fbshipit-source-id: d61f3096fa368b934a923dee54a0ea1e3469ae0d
2018-04-11 13:42:31 -07:00
Siddharth Agarwal
ead5f3be95 mercurial-types: rename left -> from, right -> to
Summary:
`left` and `right` are too vague in this context, since there's
already `Added` and `Removed` which imply an explicit direction.

Reviewed By: StanislavGlebik

Differential Revision: D7560975

fbshipit-source-id: 847f600508434d62857ff60a6e6678a4426ffa88
2018-04-11 13:42:31 -07:00
Siddharth Agarwal
32f1a4ef03 mercurial-types: represent symlinks as blobs, not paths
Summary:
There's no guarantee that a symlink is a valid `MPath` -- in fact, it
frequently will be an absolute symlink which is not a valid `MPath`.

Reviewed By: lukaspiatkowski

Differential Revision: D7541672

fbshipit-source-id: c7eca54cd06e811cf54932ab8f671c13a62b5f71
2018-04-09 12:06:57 -07:00
Siddharth Agarwal
7cb68c0c60 mercurial-types: make the Type enum use FileType
Summary:
Since `FileType` now exists, the `Type` enum can use it instead of
defining its own stuff.

Reviewed By: farnz

Differential Revision: D7526046

fbshipit-source-id: 3b8eb5502bee9bc410ced811dc019c1ce757633f
2018-04-06 13:16:55 -07:00
Arun Kulshreshtha
f3e27be2eb Make TimedFuture take asynchronous callback
Summary: Previously, the `.timed()` combinator exported by the `futures-stats` would accept a synchronous callback to log the recorded stats. In practice, logging the stats may require blocking IO, so this combinator should be modified to accept a closure that returns a Future instead.

Reviewed By: farnz

Differential Revision: D7492957

fbshipit-source-id: c634b511e5a93a18787ab3e11ab8e1c19de7566e
2018-04-06 11:34:00 -07:00
Stanislau Hlebik
618308b470 mononoke: use filenodes to get copy and parent info
Summary:
filenodes are faster than blobstore in answering `get_parents` and
`get_copy_info` queries. So let's use them instead of going to blobstore.

Reviewed By: jsgf

Differential Revision: D7485151

fbshipit-source-id: f9e2ce9dd42b3e9b18140cc3de2c9718f20ab6d4
2018-04-06 06:56:47 -07:00
Stanislau Hlebik
9587c7e694 mononoke: use filenodes in blobrepo
Summary:
Use filenodes in BlobRepo instead of linknodes.

That involves changes in commit API because we need to write filenodes not linknodes.
Also it involves changes to memblob test repos.
Note that in this diff they are basically "broken" - linknodes were replaced with empty filenodes. However looks like our unittests haven't exercised this functionality, so no unit-tests has failed. In the next diffs the correct filenodes will be added.

Reviewed By: farnz

Differential Revision: D7413481

fbshipit-source-id: 7f994ea55887b96a0eacf8e6ffdebd1f8c5f025d
2018-03-29 03:29:57 -07:00
Stanislau Hlebik
fc3971aa62 mononoke: remove a few BlobRepo constructors
Summary:
They do not provide a lot of value, so let's not have them at all. It will make
adding filenodes easier.

Reviewed By: farnz

Differential Revision: D7428601

fbshipit-source-id: 647fa36d962cb6a8996f92246e4d900751040a52
2018-03-29 03:29:57 -07:00
Stanislau Hlebik
7fd6e274ea mononoke: remove blob_files
Summary: We are not using it, so there is no point in keeping it around

Reviewed By: farnz

Differential Revision: D7400428

fbshipit-source-id: 481ef3ec8ef1f188e01add36e81da789f186548e
2018-03-28 04:22:46 -07:00
Simon Farnsworth
2d0c41cf06 Make manifests contain MPathElement instead of MPath
Summary:
For historical reasons (back when we thought Mononoke might need to handle both flat and tree manifests natively), we decided to make the entry type in a Manifest be `MPath`, not `MPathElement`.

In the tree manifest only world we're now in, it's a bug if a Manifest contains a path instead of a path element - enforce this through the type system, so that we can't backslide accidentally.

Reviewed By: StanislavGlebik

Differential Revision: D7413870

fbshipit-source-id: fa13b676475ea8a3265fc962910542f2f555d7de
2018-03-27 07:44:39 -07:00
Simon Farnsworth
86ba6a7715 Run perf tests against a simulated blobstore
Summary: Make it possible to use a simulated remote backend as a blobstore. This allows me to look at the test results and be happy that Mononoke is at fault for any slowness.

Reviewed By: kulshrax

Differential Revision: D7353229

fbshipit-source-id: 57528af704b517a70570bb2b9b140caa9120a956
2018-03-26 05:11:00 -07:00
Jeremy Fitzhardinge
3373c16b62 scm/mononoke: run changeset operations in worker threads
Summary:
Run changeset db operations in worker threads to make them async as
far as the rest of the system is concerned.

Reviewed By: farnz

Differential Revision: D7350002

fbshipit-source-id: 66fadf9ad2f16929e0c07a6907aa9d5f5a7075a8
2018-03-23 13:47:55 -07:00
Jeremy Fitzhardinge
d6504de44c scm/mononoke: make Changesets::add take ChangesetInsert by value
Summary:
There's no point passing it by reference since callers don't need to
retain it, and the async implementation needs to move it into another context.

Reviewed By: farnz

Differential Revision: D7350001

fbshipit-source-id: 5947557a84621afae801dc20e3994496244e3a10
2018-03-23 13:47:54 -07:00
Lukas Piatkowski
d0e66cc5f7 mercurial: distinguish between NodeHash used in mercurial Revlogs and in Mononoke Blobstore
Summary:
This codemod tries not to change the existing behavior of system, only introduce new types specific to Mercurial Revlogs.
It introduces a lot of copypasta intentionally and it will be cleaned in following diffs.

Reviewed By: farnz

Differential Revision: D7367191

fbshipit-source-id: 0a915f427dff431065e903b5f6fbd3cba6bc22a7
2018-03-22 12:24:35 -07:00
Arun Kulshreshtha
c12923a087 Use std::time instead of time crate in futures-stats
Summary: Remove usage of deprecated `time` crate in `futures-stats`, and fix all callsites using the new `time-ext` crate.

Reviewed By: farnz

Differential Revision: D7349956

fbshipit-source-id: 10ef86c4942b8533a734c7daadfa895f5ef92f23
2018-03-22 06:01:43 -07:00
Siddharth Agarwal
9eb63ab31f ensure all MPaths are non-empty
Summary:
A lot of Mononoke expects MPath instances to be non-empty, and some
Mononoke code wants empty MPaths. Have formerly-empty `MPath` instances be
represented as `None` instead.

There's a bit of a wart where we have to check for some instances being empty
even though they should never be. This is not a regression -- this is actually
a deficiency in our current type hierarchy being exposed. `Entry` can sometimes
represent a root manifest, but a root path and a root manifest will never be
joined together in practice. We may want to figure out a better way to
represent that in the future.

Also clean up a bunch of code that checks for empty `MPath` instances. That
just isn't possible any more -- yay.

Reviewed By: StanislavGlebik

Differential Revision: D7359048

fbshipit-source-id: 684f908dabaa06cb25b1dd33f4fd7bb021cb5e1b
2018-03-22 05:21:57 -07:00
Siddharth Agarwal
df5c6c7202 use Option<MPath> instead of empty MPaths whenever desired
Summary:
Lots of places specifically want a non-empty `MPath`, and earlier those cases
weren't type-checked. Now `Option<MPath>` stands for an empty `MPath`. In the
next diff `MPath::empty()` will go away and the only way to represent an
`MPath` that doesn't exist will be with `Option<MPath>`.

Reviewed By: farnz

Differential Revision: D7350970

fbshipit-source-id: 1612aec67134e7a0ebad15dbaa93b5ea972f8ddf
2018-03-21 15:59:31 -07:00
Stanislau Hlebik
6c2bb328aa mononoke: update bookmarks in pushkey part
Summary:
Actually update the bookmarks using pushkey part. Note that bookmark deletion
doesn't currently work. It will be fixed in the next diffs

Reviewed By: farnz

Differential Revision: D7271600

fbshipit-source-id: fd13d1adfd3ea490174c31e23289e8560dc2b737
2018-03-21 14:25:00 -07:00
Stanislau Hlebik
91d795ec72 mononoke: use diesel bookmarks
Summary: Replace old_bookmarks with the new diesel implementation

Reviewed By: farnz

Differential Revision: D7271599

fbshipit-source-id: cb6433fe44a8e6f87046a3820f7c3e68725505f6
2018-03-21 14:24:51 -07:00
Siddharth Agarwal
2c2dabdd38 use Option<&MPathElement> instead of &Option<MPathElement>
Summary:
The `Option<&MPathElement>` type is more general -- it's easy to
convert from `&Option<MPathElement>` to it, but the other way around can
require a clone.

Reviewed By: farnz

Differential Revision: D7339161

fbshipit-source-id: 0c8ab57a19bc330245c612e3e0e3651e368ab8cb
2018-03-21 09:32:11 -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
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
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
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
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
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
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
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