Commit Graph

261 Commits

Author SHA1 Message Date
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