Commit Graph

17 Commits

Author SHA1 Message Date
David Tolnay
a6c9a3844a rust: Replace derive(Fail) with derive(Error)
Summary:
This diff replaces code of the form:

```
use failure::Fail;

#[derive(Fail, Debug)]
pub enum ErrorKind {
    #[fail(display = "something failed {} times", _0)]
    Failed(usize),
}
```

with:

```
use thiserror::Error;

#[derive(Error, Debug)]
pub enum ErrorKind {
    #[error("something failed {0} times")]
    Failed(usize),
}
```

The former emits an implementation of failure 0.1's `Fail` trait while the latter emits an impl of `std::error::Error`. Failure provides a blanket impl of `Fail` for any type that implements `Error`, so these `Error` impls are strictly more general. Each of these error types will continue to have exactly the same `Fail` impl that it did before this change, but now also has the appropriate `std::error::Error` impl which sets us up for dropping our various dependencies on `Fail` throughout the codebase.

Reviewed By: Imxset21

Differential Revision: D18523700

fbshipit-source-id: 0e43b10d5dfa79820663212391ecbf4aeaac2d41
2019-11-14 22:04:37 -08:00
David Tolnay
5ca972ac2e Rename rust2 code generator to rust
Summary: This diff replaces 5248 lines of Rust code with 1221 lines of C++ and 2019 lines of Mustache template. -.-

Reviewed By: Imxset21

Differential Revision: D18287690

fbshipit-source-id: 57b7cea49a4baf4b6eb5d58d81d1cb9df53798e8
2019-11-04 13:06:55 -08:00
Andres Suarez
cf36295fa4 Yearless license header
Summary:
This diff updates all license headers to use the new text and style.
Also, a few internal files were missing the header, but now they have it.
`fbcode/common/rust/netstring/` had the internal header, but now it has
GPLV2PLUS - since that goes to Mononoke's Github too.

Differential Revision: D17881539

fbshipit-source-id: b70d2ee41d2019fc7c2fe458627f0f7c01978186
2019-10-11 13:52:34 -07:00
Stanislau Hlebik
42ad4278c8 mononoke: rename fields and log them as integers
Reviewed By: krallin

Differential Revision: D17808423

fbshipit-source-id: a44c1f2a5d96524ffd173e95aafaf2fe5e62e6e5
2019-10-09 11:02:55 -07:00
Kostia Balytskyi
db9b66e1cb mononoke: invalidate bonsai_hg_mapping cache
Summary: A fallout from T54639354.

Reviewed By: HarveyHunt

Differential Revision: D17718890

fbshipit-source-id: a10c7f82100fe2477777bc57cbc145367e77ce99
2019-10-03 10:00:59 -07:00
David Tolnay
1cd333be79 rust/thrift: Rename rust_thrift runtime library to fbthrift
Summary:
As suggested by yfeldblum in https://our.intern.facebook.com/intern/diff/D17544447/?transaction_id=2964022370277861.

> the `rust_` bit seems superfluous; the `_thrift` bit opens the door for confusion with apache thrift. Any issue using a module name like `fbthrift`?

 ---

```
$ fastmod '\brust_thrift\b' fbthrift -d ~/fbcode -e rs,toml
$ fastmod '\brust_thrift\b' fbthrift -d ~/fbcode -g '**/TARGETS'
$ hg revert experimental
$ arc lint -a
```

Reviewed By: bolinfest

Differential Revision: D17611123

fbshipit-source-id: b621a422480b00eb2e339ff7542cc66c3ca5b8ec
2019-09-26 20:23:47 -07:00
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
Thomas Orozco
aa6922a340 common/rust/sql: don't ask for slices of references for >list
Summary:
We don't need to create double-indirection when accepting `>list` arguments.
This tends to force callers into creating new Vecs of references here and
there.

Since I was in here fixing D17286200, I figured I might as well do this too.

Reviewed By: farnz

Differential Revision: D17286608

fbshipit-source-id: 994f7d6da309b16b4e613d05faeaa3ae70ae70ab
2019-09-11 01:40:10 -07:00
Stanislau Hlebik
d38e729c23 mononoke: add perf counters for our backends
Summary:
That's something we'd like to do for a while - for each request track how many requests it
sends to our storages (i.e. manifold and xdb). That might make perf debugging easier.

There's a concern that it might increase cpu usage, and I'll run a canary to check
if it's the case.

Reviewed By: krallin

Differential Revision: D17091115

fbshipit-source-id: 27fea314241d883ced72d88d39f2e188716a1b9a
2019-09-10 10:16:39 -07:00
Pavel Aslanov
1bb01bb7a1 move mercurial related creates to mercurial subdirectory
Summary:
Start moving mercurial related stuff to `mercurial` directory:
- rename `mercurial` to `mercurial_revlog` and moved to `/mercurial/revlog`
- move `mercurial_types` to `/mercurial/types`
- move `mercurial_bundles` to `/mercurial/bundels`

Reviewed By: farnz

Differential Revision: D16783728

fbshipit-source-id: 79cf1757bb7cc84a6273a4a3c486242b1ef4cd00
2019-08-14 04:03:00 -07:00
Harvey Hunt
2504ed8b40 mononoke: Change stats prefix
Summary:
The stats prefix for bonsai hg mapping is "bonsai-hg-mapping" in lib.rs and
"bonsai_hg_mapping" in caching.rs. Convert lib.rs's prefix to match that of caching.rs,
making it easier to find stats.

Reviewed By: StanislavGlebik, farnz

Differential Revision: D16357147

fbshipit-source-id: f9c5bfa5a43c9b8c06ac8cb3b250cdf8fe689a28
2019-07-18 06:23:00 -07:00
Young Kim
f4e8e9bd0b Modify abomonation_future_cache to use VolatileLruCachePool
Summary: Add type safety to `abomonation_future_cache` by requiring usage of `VolatileLruCachePool`, and make that change for all usages of `LruCachePool`.

Reviewed By: farnz

Differential Revision: D15882275

fbshipit-source-id: 3f192142af254d7b6b8ea7f9cc586c2034c97b93
2019-06-21 23:35:07 -07:00
Thomas Orozco
a6004ae016 mononoke: caching_ext: elide DB calls for no data
Summary:
We don't control whatever `get_from_db` will do when asked to fetch no data. We can hope it'll do the smart thing and not hit the DB nor increment any monitoring counters.

This can be problematic, because it can result in confusing data in ODS. See T45198435 for a recent example of this.

Reviewed By: StanislavGlebik

Differential Revision: D15620424

fbshipit-source-id: 629c2eaad00d4977b0598c26e1f2a2ca64a1d66e
2019-06-04 05:16:52 -07:00
Jeremy Fitzhardinge
0b30f5c3cd Convert scm/mononoke/bonsai_hg_mapping to Rust 2018
Summary:
Rust 2018 updates to:
  //scm/mononoke/bonsai_hg_mapping:bonsai_hg_mapping
  //scm/mononoke/bonsai_hg_mapping:bonsai_hg_mapping-unittest
  //scm/mononoke/bonsai_hg_mapping:bonsai_hg_mapping_entry_thrift-rust
  //scm/mononoke/bonsai_hg_mapping:bonsai_hg_mapping_test
  //scm/mononoke/bonsai_hg_mapping:bonsai_hg_mapping_test-rust-build-info-lib

Reviewed By: aslpavel

Differential Revision: D15465954

fbshipit-source-id: fa7b0cff5ccecc0869dc85374cd2edd955cf8ecb
2019-05-23 14:26:32 -07:00
Jeremy Fitzhardinge
08fd9ce03b rust/sql: add LABEL to SqlConstructors
Summary:
Add a LABEL constant to the SqlConstructors trait to make it easier to identify
which table is being used, for stats and logging.

Reviewed By: HarveyHunt

Differential Revision: D13457488

fbshipit-source-id: a061a9582bc1783604f249d5b7dcede4b1e1d3c5
2019-05-21 12:25:14 -07:00
Stanislau Hlebik
1edc51cb05 mononoke: speed up insertion in bonsai hg mapping
Summary:
AnyMapping sql requests was unbearably slow - it took 1 seconds to finish.
Replacing it with two normal requests works much faster.

Note that it affected performance only if there was already an entry in the
mapping table

Reviewed By: farnz

Differential Revision: D14647179

fbshipit-source-id: e54f0474cdcc1f21bd429876cdbb04633f459d59
2019-05-21 12:24:56 -07: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