Commit Graph

98 Commits

Author SHA1 Message Date
David Tolnay
713973975d Replace *fbinit::FACEBOOK with #[fbinit::main]
Summary:
This diff moves initFacebook calls that used to happen just before FFI calls to instead happen at the beginning of main.

The basic assumption of initFacebook is that it happens at the beginning of main before there are additional threads. It must be allowed to modify process-global state like env vars or gflags without the possibility of a data race from other code concurrently reading those things. As such, the previous approach of calling initFacebook through `*fbinit::FACEBOOK` near FFI calls was prone to race conditions.

The new approach is based on attribute macros added in D17245802.

 ---

The primary remaining situations that still require `*fbinit::FACEBOOK` are when we don't directly control the function arguments surrounding the call to C++, such as in lazy_static:

    lazy_static! {
        static ref S: Ty = {
            let _ = *fbinit::FACEBOOK;
            /* call C++ */
        };
    }

and quickcheck:

    quickcheck! {
        fn f(/* args that impl Arbitrary */) {
            let _ = *fbinit::FACEBOOK;
            /* call C++ */
        }
    }

I will revisit these in a separate diff. They are a small fraction of total uses of fbinit.

Reviewed By: Imxset21

Differential Revision: D17328504

fbshipit-source-id: f80edb763e7f42b3216552dd32f1ea0e6cc8fd12
2019-09-13 20:17:29 -07:00
David Tolnay
577a31b2a1 Delete extern crate lines
Summary:
`extern crate` is usually no longer needed in 2018 edition of Rust. This diff removes `extern crate` lines from fbcode where possible, replacing #[macro_use] with individual import of macros.

Before:

```
#[macro_use]
extern crate futures_ext;
extern crate serde_json;
```

After:

```
use futures_ext::try_boxfuture;
```

Reviewed By: Imxset21

Differential Revision: D17313537

fbshipit-source-id: 70462a2c161375017b77fa44aba166884ad2fdc3
2019-09-11 22:01:58 -07:00
David Tolnay
ecc30ffe8a Delete lines of the form "use [a-z_]+;"
Summary: I think these are left over from pre-2018 code where they may have been necessary. In 2018 edition, import paths in `use` always begin with a crate name or `crate`/`super`/`self`, so `use $ident;` always refers to a crate. Since extern crates are always in scope in every module, `use $ident` does nothing.

Reviewed By: Imxset21

Differential Revision: D17290473

fbshipit-source-id: 23d86e5d0dcd5c2d4e53c7a36b4267101dd4b45c
2019-09-10 15:06:19 -07:00
Stanislau Hlebik
4817255395 mononoke: replace Box::new with boxify()
Summary:
Originally that was part of D16361366 which turned BoxStream into struct with
must_use. However we decided to take another approach with must_use

That said, the cleanup is still useful even without must_use

Reviewed By: farnz

Differential Revision: D16376122

fbshipit-source-id: 295e9e71d7da82651e12139d35de5bd300e44153
2019-07-19 01:49:52 -07:00
Stanislau Hlebik
1270d709a8 mononoke: remove Logger from BlobRepo
Summary:
It's used only in a very few places, and most likely that's by accident. We
pass logger via CoreContext now

Reviewed By: krallin

Differential Revision: D16336953

fbshipit-source-id: 36ea4678b3c3df448591c606628b93ff834fae45
2019-07-17 08:31:56 -07:00
David Tolnay
fed2ac83f4 rust: Head start on some upcoming warnings
Summary:
This diff sets two Rust lints to warn in fbcode:

```
[rust]
  warn_lints = bare_trait_objects, ellipsis_inclusive_range_patterns
```

and fixes occurrences of those warnings within common/rust, hg, and mononoke.

Both of these lints are set to warn by default starting with rustc 1.37. Enabling them early avoids writing even more new code that needs to be fixed when we pull in 1.37 in six weeks.

Upstream tracking issue: https://github.com/rust-lang/rust/issues/54910

Reviewed By: Imxset21

Differential Revision: D16200291

fbshipit-source-id: aca11a7a944e9fa95f94e226b52f6f053b97ec74
2019-07-12 00:56:44 -07:00
Greg Cowan
041770b090 Transition fbcode Rust crates to 2018 edition
Summary: Marking all Cargo.tomls in fbcode as 2018 edition.

Reviewed By: jsgf

Differential Revision: D15951175

fbshipit-source-id: edf18449c214ee1ff285d6a2cb61839aaf58a8cd
2019-06-24 13:15:17 -07:00
Johan Schuijt-Li
02a82f4f0b types: speed up hex encode and decode
Summary:
Hex encoding and decoding is in the hot path for gettreepacks, particularly
when we have large fetches (for example with clones), we can easily do this in
the order of tens or hundreds of thousands.

Switch to using a SSE/AVX2 optimized hex encoding/decoding which results in
a 10x performance improvement for decoding. Encoding was already using a
relatively optimized version, so gain is expected to be much lower for encoding.

Reviewed By: farnz

Differential Revision: D15940209

fbshipit-source-id: 28734f45f7508a94b110e25c01e1baa955ebd4e4
2019-06-21 10:48:46 -07:00
Stanislau Hlebik
8368b2dec0 mononoke: fix filenode generation if one filenode is ancestor of another
Summary:
If a file has two parent filenodes and one of them is ancestor of another then
we want to keep only the descendant filenode as a parent.

(NOTE) Note that this diff doesn't fix all the corner cases. In integration tests a file that has
two parents is modified in a merge commit. Note that if it wasn't modified in
a merge commit then Mercurial produces a hash different from Mononoke. I'll
investigate why it happens

(NOTE) We had incorrect hashes in our test fixtures - this diff fixes them as well

Reviewed By: farnz

Differential Revision: D15896735

fbshipit-source-id: ea31071bc69fab02935887c665f6d03b64d5c572
2019-06-20 01:50:47 -07:00
Jeremy Fitzhardinge
fd31ee649b Convert scm/mononoke/revset to Rust 2018
Summary:
Rust 2018 updates to:
  //scm/mononoke/revset:revset
  //scm/mononoke/revset:revset-unittest

Reviewed By: StanislavGlebik

Differential Revision: D15466975

fbshipit-source-id: b4a42a5997e1d1ad42af250b0771c15d5094c0f4
2019-05-28 15:14:57 -07:00
Stanislau Hlebik
e6c8ef00aa mononoke: fix computing of changed files
Summary:
The problem was in using `file_changes()` of a bonsai object. If a file
replaces a directory, then it just returns an added file, but not a removed
directory.

However `changed_entry_stream` didn't return an entry if just it's mode was changed (i.e. file became executable, or file became a symlink). This diff fixes it as well

Let's use the same computing changing files method instead of `file_changes()`.

Differential Revision: D14279470

fbshipit-source-id: 976b0abd93646f7d68137c83cb07a8564922ce17
2019-03-08 06:28:49 -08:00
Kostia Balytskyi
e561682ecd mononoke: rename crates to contain underscores instead of dashes
Summary: Let's not use dashes in crate names.

Reviewed By: StanislavGlebik

Differential Revision: D14341596

fbshipit-source-id: 85a7ded60cf2e326997ac70ee47a29116af97590
2019-03-06 07:18:28 -08:00
Lukas Piatkowski
515a2909eb monononoke hashes: remove usages of borrows of hashes which are Copy
Summary: The Copy trait means that something is so cheap to copy that you don't even need to explicitly do `.clone()` on it. As it doesn't make much sense to pass &i64 it also doesn't make much sense to pass &<Something that is Copy>, so I have removed all the occurences of passing one of ouf hashes that are Copy.

Reviewed By: fanzeyi

Differential Revision: D13974622

fbshipit-source-id: 89efc1c1e29269cc2e77dcb124964265c344f519
2019-02-06 15:11:35 -08:00
Stanislau Hlebik
a6f6f28564 mononoke: split reachability index
Summary:
Let's split reachability index crate. The main goal is to reduce compilation
time. Now crates like revsets will only depend on traits definition but not on
the actual implementation (skiplist of genbfs).

Reviewed By: lukaspiatkowski

Differential Revision: D13878403

fbshipit-source-id: 022eca50ac4bc7416e9fe5f3104f0a9a65195b26
2019-01-31 00:41:48 -08:00
Stanislau Hlebik
41116a4ed7 mononoke: add revset-test-helper
Summary:
This crate depends on BlobRepo and will be used only in tests. For the rest of
the revsets we'll be able to get rid of BlobRepo dependency.

Reviewed By: lukaspiatkowski

Differential Revision: D13878389

fbshipit-source-id: bf5c5861882b18397842ff5f779999a52b963c2b
2019-01-31 00:41:48 -08:00
Stanislau Hlebik
3d06332693 mononoke: move changeset_fetcher out of blobrepo into separate crate
Summary:
Some crates, namely revsets and reachabilityindex, currently depend on
blobrepo, while all they need is the ability to fetch commits.

By moving changeset_fetcher outside this dependency will be removed. That may
make builds faster

Reviewed By: lukaspiatkowski

Differential Revision: D13878369

fbshipit-source-id: 9ee8973a9170557a4dede5404dd374aa4a000405
2019-01-31 00:41:48 -08:00
Stanislau Hlebik
56b867be32 mononoke: migrate RangeNodeStream to ChangesetFetcher
Reviewed By: lukaspiatkowski

Differential Revision: D13860325

fbshipit-source-id: 3c51d964b6fd4a55587230682c644132f71fd619
2019-01-30 06:31:10 -08:00
Stanislau Hlebik
1f1206be3f mononoke: do not use HgNodeHash in revsets
Summary: Use bonsai changesets instead

Reviewed By: aslpavel

Differential Revision: D13860075

fbshipit-source-id: b9f48f5b01e838746b3383e0e3bb6b319a865578
2019-01-29 08:40:12 -08:00
Liubov Dmitrieva
abe70d4324 move Send + Sync to the trait for LeastCommonAncestorsHint
Summary: This hint is passed to many places, so it reduces the code.

Reviewed By: StanislavGlebik

Differential Revision: D13802159

fbshipit-source-id: 891eef00c236b2241571e24c50dc82b9862872cc
2019-01-24 07:59:46 -08:00
Stanislau Hlebik
936a31a0e0 mononoke: fix warnings and enable deny(warnings) for revsets
Reviewed By: lukaspiatkowski

Differential Revision: D13710072

fbshipit-source-id: cdc0a4abd1133b1510158fdf8f3d99e4bd7d969d
2019-01-17 04:33:49 -08:00
Fatih Aydin
0c8adaa4c4 Replacing HgNodeHash with Changesetid - Without formatting changes
Differential Revision: D13692998

Reviewed By: lukaspiatkowski

fbshipit-source-id: 0ba0d30a96b0a4d4d84f64b410036e9e58cf64b9
2019-01-16 11:08:41 -08:00
Fatih Aydin
b43b908a4b Lint Formatting Changes for Revsets
Summary: This diff is created to separate the lint formatting work from the rest of the code changes in D13632296

Reviewed By: lukaspiatkowski

Differential Revision: D13691680

fbshipit-source-id: 8e12016534d2e6066d803b51b5f12cbf6e89a822
2019-01-16 11:08:41 -08:00
Stanislau Hlebik
6989441a6e mononoke: replacing SingleNodeHash revset with SingleChangesetId
Summary:
All revsets should use bonsai changesets and not hg chnagesets.
This diff replaces usages of SingleNodeHash with SingleChangesetId.
It doesn't remove all of the usages, but it removes most of them

Reviewed By: aslpavel

Differential Revision: D13467116

fbshipit-source-id: 92c5b8f63f07e13af642a8cdb91fc77c46cdd595
2018-12-19 11:07:20 -08:00
Stanislau Hlebik
5d483c3f2f mononoke: use mock context in string_to_bonsai
Summary:
It's a test function, and passing additional parameter is annoying. Let's just
create mock context

Reviewed By: ikostia

Differential Revision: D13467118

fbshipit-source-id: fd27893d80f6b0ba59c2b7e5083d4ec7727a0e89
2018-12-19 11:07:20 -08:00
Jeremy Fitzhardinge
5f3d7307da mononoke/revset: suppress warning
Summary: PhantomData only used for test builds.

Reviewed By: StanislavGlebik

Differential Revision: D13460298

fbshipit-source-id: e712e468a4dacd6ddad3b6159c3020d49e87306f
2018-12-14 13:27:44 -08:00
Abhay Bothra
f146e8e389 mononoke: migrate SetDifferenceNodeStream to use ChangesetId
Summary:
Made changes to SetDifferenceNodeStream struct, and associated member functios.
Also ran :RustFmt on quickcheck.rs and setdifferencenodestream.rs

Reviewed By: StanislavGlebik

Differential Revision: D13448043

fbshipit-source-id: c38567ad8fb94d55b463b28abf4bd78987a9c68a
2018-12-13 15:09:12 -08:00
Stanislau Hlebik
ed3a163b7c mononoke: remove get_changesets method
Summary: It's useless

Reviewed By: HarveyHunt

Differential Revision: D13305842

fbshipit-source-id: 72426e92ab9e2a4c3795a70f6fac0100f1e0375c
2018-12-06 10:22:15 -08:00
Kostia Balytskyi
cced1d0478 mononoke: change unionnodestream to use ChangesetId
Summary:
Refactored UnionNodeStream to use changesetid
Modified all other classes using it
Modified tests.

Depends on: D13275956

Reviewed By: StanislavGlebik

Differential Revision: D13326684

fbshipit-source-id: fd34f52739cf3e2876aa7a30c5060b3b3410f413
2018-12-05 04:57:58 -08:00
Filip Hrenić
49579b36d0 Change IntersectNodeStream to use ChangesetId
Summary:
Refactored intersect nodestream to use changesetid
Modified all other classes using it
Modified tests (some still need to be modified, see `TODO Hrenic`)

Reviewed By: StanislavGlebik

Differential Revision: D13275956

fbshipit-source-id: 90d3c191e161be8a9ce1841de0e04ce60438764b
2018-12-04 13:32:05 -08:00
Lukas Piatkowski
5d9a151d85 mononoke: pass CoreContext down to blobstore
Reviewed By: jsgf

Differential Revision: D13324220

fbshipit-source-id: af7a2a650338ea66e504ea0acae1d103af10f8e3
2018-12-04 11:40:15 -08:00
Lukas Piatkowski
02e79837a4 mononoke: pass CoreContext down to bookmarks
Reviewed By: StanislavGlebik

Differential Revision: D13302943

fbshipit-source-id: 356ec3cd3c47f843a5869edb7079d4cbd0ee33aa
2018-12-04 01:16:32 -08:00
Stanislau Hlebik
bd7246dcf7 mononoke: use common traits from NodeFrontier
Summary: Address aslpavel's comments from D13275471

Reviewed By: aslpavel

Differential Revision: D13301218

fbshipit-source-id: 5e51dd3b19a6cd41ae9b4071ec3edb2f0c81999c
2018-12-03 05:09:02 -08:00
Lukas Piatkowski
14636545aa mononoke: pass CoreContext down to changesets
Reviewed By: StanislavGlebik

Differential Revision: D13277448

fbshipit-source-id: 6e9a8dac77af8ab991005d14f654e315c234fe44
2018-11-30 10:14:22 -08:00
Lukas Piatkowski
08db0a35eb mononoke: pass CoreContext down to bonsai-hg-mapping
Reviewed By: aslpavel

Differential Revision: D13277450

fbshipit-source-id: 97cfbd917b321727bb4d960c91a784787660eb5b
2018-11-30 10:14:22 -08:00
Stanislau Hlebik
c6f21b1cc8 mononoke: efficient search of max generation in NodeFrontier
Summary:
Previously `max_gen()` function did a linear scan through all the keys, and it
was linear. Let's use `UniqueHeap` datastructure to track maximum generation
number.

Reviewed By: lukaspiatkowski

Differential Revision: D13275471

fbshipit-source-id: 21b026c54d4bc08b26a96102d2b77c58a981930f
2018-11-30 04:34:02 -08:00
Stanislau Hlebik
3ae6daeb0c mononoke: use skiplist in getbundle
Reviewed By: jsgf, lukaspiatkowski

Differential Revision: D13169016

fbshipit-source-id: 59c567663680a99dd977e087f38374e77c72afd6
2018-11-29 08:19:30 -08:00
Stanislau Hlebik
52f12e92ac mononoke: remove recursion from SkiplistIndex lca_hint
Summary:
Recursion can easily become too deep and overflow the stack. Let's use
`loop_fn` instead

Reviewed By: lukaspiatkowski

Differential Revision: D13169015

fbshipit-source-id: bf5cf151e83fd4bd785ff4b81a93858e7e2dcfde
2018-11-29 08:19:30 -08:00
Stanislau Hlebik
e704bd24fe mononoke: use NodeFrontier in getbundle
Summary:
NodeFrontier is a hashset that stores commits and their generation numbers.
We'll use it to figure out what nodes client already has (`exclude` nodes).
Before this change we used `GroupedByGenenerationStream`, but it doesn't allow
us to skip some commits. We can skip commits with NodeFrontier though.

Reviewed By: lukaspiatkowski

Differential Revision: D13122521

fbshipit-source-id: 08eddb71e49b16b879f65bc9b8b177dc5dbcc034
2018-11-29 08:19:30 -08:00
Walter Schulze
fb5393f77e add stats collection in ChangesetFetcher
Summary:
Added a get_stats() Hashmap<String, Box<Any>> method for all ChangesetFetchers.
The CachingChangesetFetcher now returns statistics for cache.misses: usize, cache.hits: usize, fetches.from.blobstore: usize and max.latency: Duration.

Reviewed By: StanislavGlebik

Differential Revision: D10852637

fbshipit-source-id: 34114fd94c47aa26ea525fcc4ff76ad60827bc71
2018-11-07 15:14:30 -08:00
Pavel Aslanov
38c5145e9b hadle change only in executable bit same way as Hg
Summary:
Mercurial stores executable bit as part of the manifest, so if changeset only changes that attribute of a file Hg reuses file hash. But mononoke has been creating additional file node. So this change tries to handle this special case. Note this kind of reuse only happens if file has only one parent [P60183653](P60183653)

Some of our fixtures repo were effected, hence this hashes were replaced with updated ones
```
396c60c14337b31ffd0b6aa58a026224713dc07d => a5ab070634ab9cbdfc92404b3ec648f7e29547bc
339ec3d2a986d55c5ac4670cca68cf36b8dc0b82 => c10443fa4198c6abad76dc6c69c1417b2e821508
b47ca72355a0af2c749d45a5689fd5bcce9898c7 => 6d0c1c30df4acb4e64cb4c4868d4c974097da055
```

Reviewed By: farnz

Differential Revision: D10357440

fbshipit-source-id: cdd56130925635577345b08d8ed0ae6e229a82a7
2018-10-15 02:16:50 -07:00
Stanislau Hlebik
8297747e3b mononoke: make AncestorsNodeStream use ChangesetFetcher
Summary:
Main reason is to make startup faster because ChangesetFetcher can uses bulk
caches in the same way as getbundle does.

Reviewed By: farnz

Differential Revision: D10032435

fbshipit-source-id: 717114339edf31865b498893d75695968447bb43
2018-09-26 04:51:45 -07:00
Stanislau Hlebik
7cec9d7878 mononoke: make AncestorNodeStream use ChangesetId
Summary:
Revsets should use ChangesetId instead of NodeHash. This diff cleans up
ancestors revset

Reviewed By: farnz

Differential Revision: D10032436

fbshipit-source-id: 2c7d170738826154e3b606e9e29a739a34b1840e
2018-09-26 04:51:45 -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
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
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
Jeremy Fitzhardinge
2cfa682b33 mononoke: use err_downcast generally in mononoke
Summary: Cleans things up a bit, esp when matching Context/Chain.

Reviewed By: lukaspiatkowski

Differential Revision: D9439062

fbshipit-source-id: cde8727437f58b288bed9dfacb864bdcd7dea45c
2018-09-06 14:24:08 -07:00
Stanislau Hlebik
7a5b393f88 mononoke: replace Arc<BlobRepo> with BlobRepo
Summary: Arc<BlobRepo> is useless, because BlobRepo is cloneable.

Reviewed By: farnz

Differential Revision: D9654256

fbshipit-source-id: ec54d7669c17732112bee2ba4202b6eafd31bfae
2018-09-06 05:23:35 -07:00
Stanislau Hlebik
60150b9488 mononoke: stack pushrebase
Summary: Now pushrebasing stacks as well. Again, still no conflicts checks

Reviewed By: aslpavel

Differential Revision: D9359807

fbshipit-source-id: 9f6e7a05b45fb80b40faaaaa4fe2434b7a591a7c
2018-08-17 07:21:31 -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
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