Commit Graph

181 Commits

Author SHA1 Message Date
Stefan Filip
66706d77c5 segmented_changelog: add SegmentedChangelog trait
Summary:
The trait provides two methods for location to hash translation. The first
returns a single hash and is existing functionality. The second returns a
list of hashes and represents new functionality. This diff also adds this
functionality to the Dag structure which is currently the only real
implementation for SegmentedChangelog.

Reviewed By: aslpavel

Differential Revision: D23456215

fbshipit-source-id: 0c2ca91672cf23129342c585f98446c0ebbdf7ef
2020-09-02 17:20:41 -07:00
Jun Wu
6fd7a2e582 dag: use concrete error types
Summary:
This is more complex than previous libraries, mainly because `dag` defines APIs
(traits) used by other code, which might raise error type not interested
by `dag` itself. `BackendError::Other(anyhow::Error)` is currently used to
capture types that do not fit in `dag`'s predefined error types.

Reviewed By: sfilipco

Differential Revision: D22883865

fbshipit-source-id: 3699e14775f335620eec28faa9a05c3cc750e1d1
2020-08-06 12:31:57 -07:00
Jun Wu
8d0f48c4da dag: rename some anyhow::Result to dag::Result
Summary:
Prefix some `Result` with `dag::Result`. Since `dag::Result` is just
`anyhow::Result` for now, this does not change anything but makes
it more compatible with upcoming changes.

Reviewed By: sfilipco

Differential Revision: D22883864

fbshipit-source-id: 95a26897ed026f1bb8000b7caddeb461dcaad0e7
2020-08-06 12:31:57 -07:00
Stefan Filip
2f3e569120 mononoke_api: add segmented changelog location to hash translation
Summary:
This functionality is going to be used in EdenApi. The translation is required
to unblock removing the changelog from the local copy of the repositories.
However the functionality is not going to be turned on in production just yet.

Reviewed By: kulshrax

Differential Revision: D22869062

fbshipit-source-id: 03a5a4ccc01dddf06ef3fb3a4266d2bfeaaa8bd2
2020-08-04 11:22:39 -07:00
Arun Kulshreshtha
5f0181f48c Regenerate all Cargo.tomls after upgrade to futures 0.3.5
Summary: D22381744 updated the version of `futures` in third-party/rust to 0.3.5, but did not regenerate the autocargo-managed Cargo.toml files in the repo. Although this is a semver-compatible change (and therefore should not break anything), it means that affected projects would see changes to all of their Cargo.toml files the next time they ran `cargo autocargo`.

Reviewed By: dtolnay

Differential Revision: D22403809

fbshipit-source-id: eb1fdbaf69c99549309da0f67c9bebcb69c1131b
2020-07-06 20:49:43 -07:00
Stefan Filip
422c84b659 mononoke: monitor replication lag in segmented_changelog::IdMap
Summary:
The (re)construction process for the IdMap will generate millions of rows
to be inserted in our database. We want to throttle the inserts so that
the database doesn't topple over.

Reviewed By: ikostia

Differential Revision: D22104349

fbshipit-source-id: 73b7c2bab12ae0cd836080bcf1eb64586116e70f
2020-07-01 18:18:55 -07:00
Jeremy Fitzhardinge
35b292ce9d eden: manual dependency fixes
Summary:
Tooling can't handle named_deps yet, but it can warn about them

P133451794

Reviewed By: StanislavGlebik

Differential Revision: D22083499

fbshipit-source-id: 46de533c19b13b2469e912165c1577ddb63d15cd
2020-06-17 17:55:04 -07:00
Jeremy Fitzhardinge
1b4edb5567 eden: remove unused Rust dependencies
Summary:
Remove unused dependencies for Rust targets.

This failed to remove the dependencies in eden/scm/edenscmnative/bindings
because of the extra macro layer.

Manual edits (named_deps) and misc output in P133451794

Reviewed By: dtolnay

Differential Revision: D22083498

fbshipit-source-id: 170bbaf3c6d767e52e86152d0f34bf6daa198283
2020-06-17 17:55:03 -07:00
Lukas Piatkowski
07e0427eb4 mononoke: make segmented_changelog OSS buildable
Reviewed By: krallin

Differential Revision: D21980974

fbshipit-source-id: 60e8f0e78b2bd654e5109b39c85f08ee5b3e9490
2020-06-12 06:54:32 -07:00
Jeremy Fitzhardinge
d03da109c7 mononoke: fix some little lints
Reviewed By: StanislavGlebik

Differential Revision: D22004427

fbshipit-source-id: 1418f91a3322ef3a3ff620c4e17745fc765dc971
2020-06-12 01:33:20 -07:00
Stefan Filip
c06de91150 mononoke: add tracking for SQL connection usage
Summary: Incrementing CoreContext::perf_counters().

Reviewed By: krallin

Differential Revision: D21875162

fbshipit-source-id: 0187034c3004efb86d74ce23ddf61a2b469efc61
2020-06-11 12:38:49 -07:00
Stefan Filip
754c1d00c0 mononoke: add counters to segmented changelog calls
Summary: Title.

Reviewed By: krallin

Differential Revision: D21875163

fbshipit-source-id: e7c50e30d10a4d192edb082c0cabe290c4e6d29a
2020-06-11 12:38:49 -07:00
Stefan Filip
0bb787d892 mononoke: add batch query capability to segmented changelog IdMap
Summary:
Useful for keeping the insert logic working nicely even when we double insert
or have other inconsistencies.

Reviewed By: krallin

Differential Revision: D21853048

fbshipit-source-id: 958cbc0435f330749c5aae1ea0f41ecd03b01468
2020-06-11 12:38:48 -07:00
Mark Thomas
76bff4c32d segmented_changelog: fix warnings
Reviewed By: sfilipco

Differential Revision: D21998893

fbshipit-source-id: f0b8d82ec4937263fbe0db2e626a3847118e5b08
2020-06-11 10:55:31 -07:00
Stefan Filip
da6a88756e mononoke: add IdMap::insert_many
Summary: Bulk insertion to the SQL backed IdMap.

Reviewed By: StanislavGlebik

Differential Revision: D21655847

fbshipit-source-id: 937cb910edbe399fed4e6b0c4013e18378cea82f
2020-06-02 19:17:53 -07:00
Stefan Filip
134a7a425c mononoke: update SegmentedChangelog building to pick up where it left off
Summary:
Instead of always building from scratch, continue assiging Vertexes and
Segments from the last commit that was processed.

Reviewed By: StanislavGlebik

Differential Revision: D21634699

fbshipit-source-id: 9f8b890dcf65c59a66651343f0ccc1487efc2394
2020-06-02 19:17:53 -07:00
Stefan Filip
e44681e307 mononoke: add IdMap::get_last_entry
Summary: Useful for determining where an incremental building step left off.

Reviewed By: StanislavGlebik

Differential Revision: D21634698

fbshipit-source-id: e9b0473003c529d5c934754f1ece23df69c4be66
2020-05-26 07:37:11 -07:00
Stefan Filip
cafbbcd9c8 mononoke: add MemIdMap
Summary:
This structure has similar functionality to the IdMap that is backed by SQL.
It is probably going to be useful for caching in the case of batch operations.

Reviewed By: quark-zju

Differential Revision: D21601820

fbshipit-source-id: 9c3ebc3e9dc92a59ce0908fc241bd2b97da88dca
2020-05-21 17:19:16 -07:00
Stefan Filip
b9a93d49e5 mononoke: bulk construction of the segmented changelog Dag
Summary:
`Dag::build_all_graph` will load the whole graph for a given repository and
construct the segmented changelog from it.

Reviewed By: StanislavGlebik

Differential Revision: D21538029

fbshipit-source-id: b4ba846bb2870ba73257bed6128b8e198a0aab3e
2020-05-21 17:19:15 -07:00
Thomas Orozco
4852b9a9ff mononoke/segmented_changelog: remove a warning
Summary: What it says in the title

Reviewed By: StanislavGlebik

Differential Revision: D21549635

fbshipit-source-id: 75939ebbfb317a9beaa9acd1fc1a7c6f41b0f88f
2020-05-13 10:47:10 -07:00
Stefan Filip
aae5b96b8d segmented_changelog: add support for multiple repositories
Summary:
How is this Dag structure going to be used? This is probably the interesting
question for this diff.
On one side the structure could maintain a view of all the repositories and
manage the DAGs for all repositories in a central place. On the other side the
`Dag` is just an instance of a Changelog and Mononoke manages repositories that
each have a `Dag`. I went with the former pattern as it seems to me to be more
in line with the general architecture of Mononoke.

We can see the Dag being another part of the BlobRepo in the future. We will
want to avoid depending on the BlobRepo for actual functionality to avoid
cyclic dependencies. Currently the BlobRepo is used in construction for
convenience but that will have to change in the future.

Reviewed By: StanislavGlebik

Differential Revision: D21418367

fbshipit-source-id: 7c133eac0f38084615c2b9ba1466de626d2ffcbe
2020-05-11 09:12:08 -07:00
Stefan Filip
bbe605a47f Update Segmented Changelog IdMap storage to SQL
Summary:
The transformation is pretty direct. I didn't add additional functionality
to the IdMap and I did not update the construction algorithm yet. The querying
method on IdMap were updated to async and then there are the SQL interaction
details.

In follow up changes I want to update the construction algorithm and add support
for multiple repositories.

I am not happy with the names of the columns or naming in general in this code.
Open to suggestions. One idea could be matching the client nomenclature as much
as possible.

Reviewed By: StanislavGlebik

Differential Revision: D20929576

fbshipit-source-id: 12104892faa69f37c141e8baf54d5fb24fc5df6b
2020-05-08 07:35:16 -07:00
Stefan Filip
ea89b541e1 segmented_changelog: add Dag struct and location_to_name functionality
Summary:
The IdDag provides graph algorithms using Segments.
The IdMap allows converting from the SegmentedChangelogId domain to the
ChangesetId domain.
The Dag struct wraps IdDag and IdMap in order to provide graph algorithms using
the common application level identifiers for commits (ChangesetId).

The construction of the Dag is currently mocked with something that can only be
used in a test environment (unit tests but also integration tests).

This diff also implements a location_to_name function. This is the most
important new functionality that segmented changelog clients require. It
recovers the hash of a commit for which the client only has a segmented
changelog Id. The current assumption is that clients have identifiers for all
merge commit parents so the path to a known commit always follow a set
of first parents.

The IdMap queries will have to be changed to async in the future, but IdDag
queries we expect to stay sync.

Reviewed By: quark-zju

Differential Revision: D20635577

fbshipit-source-id: 4f9bd8dd4a5bd9b0de55f51086f3434ff507963c
2020-03-27 13:48:52 -07:00
Stefan Filip
a853c7a92b segmented_changelog: use [fbinit::compat_test] for idmap tests
Summary: Modernizing the codebase.

Reviewed By: krallin

Differential Revision: D20655252

fbshipit-source-id: c97fd46f1a224ca74606f4b42d5fa6b1a00c8ea8
2020-03-27 13:48:52 -07:00
Stefan Filip
c0019225b4 segmented_changelog: move idmap to its own file
Summary:
Making room to new components. Individual files will be easier to read than
all code in lib.rs.

Reviewed By: krallin

Differential Revision: D20635579

fbshipit-source-id: 3966b03658b039e9d46e400a00fc50416d60780b
2020-03-27 13:48:52 -07:00
Stefan Filip
031c6b2fb4 segmented_changelog: add dependency to scm/lib/dag
Summary:
It's going to be useful to share certain structures between client and server.
Looking ahead, the plan is to share the segment graph along with all the
algorithms implemented for it.

Reviewed By: StanislavGlebik

Differential Revision: D20550951

fbshipit-source-id: f498a6b0cba1bcdd35fc9720125b223d7e891a44
2020-03-24 13:58:07 -07:00
David Tolnay
e988a88be9 rust: Rename futures_preview:: to futures::
Summary:
Context: https://fb.workplace.com/groups/rust.language/permalink/3338940432821215/

This codemod replaces *all* dependencies on `//common/rust/renamed:futures-preview` with `fbsource//third-party/rust:futures-preview` and their uses in Rust code from `futures_preview::` to `futures::`.

This does not introduce any collisions with `futures::` meaning 0.1 futures because D20168958 previously renamed all of those to `futures_old::` in crates that depend on *both* 0.1 and 0.3 futures.

Codemod performed by:

```
rg \
    --files-with-matches \
    --type-add buck:TARGETS \
    --type buck \
    --glob '!/experimental' \
    --regexp '(_|\b)rust(_|\b)' \
| sed 's,TARGETS$,:,' \
| xargs \
    -x \
    buck query "labels(srcs, rdeps(%Ss, //common/rust/renamed:futures-preview, 1))" \
| xargs sed -i 's,\bfutures_preview::,futures::,'

rg \
    --files-with-matches \
    --type-add buck:TARGETS \
    --type buck \
    --glob '!/experimental' \
    --regexp '(_|\b)rust(_|\b)' \
| xargs sed -i 's,//common/rust/renamed:futures-preview,fbsource//third-party/rust:futures-preview,'
```

Reviewed By: k21

Differential Revision: D20213432

fbshipit-source-id: 07ee643d350c5817cda1f43684d55084f8ac68a6
2020-03-03 11:01:20 -08:00
David Tolnay
fe65402e46 rust: Move futures-old rdeps to renamed futures-old
Summary:
In targets that depend on *both* 0.1 and 0.3 futures, this codemod renames the 0.1 dependency to be exposed as futures_old::. This is in preparation for flipping the 0.3 dependencies from futures_preview:: to plain futures::.

rs changes performed by:

```
rg \
    --files-with-matches \
    --type-add buck:TARGETS \
    --type buck \
    --glob '!/experimental' \
    --regexp '(_|\b)rust(_|\b)' \
| sed 's,TARGETS$,:,' \
| xargs \
    -x \
    buck query "labels(srcs,
        rdeps(%Ss, fbsource//third-party/rust:futures-old, 1)
        intersect
        rdeps(%Ss, //common/rust/renamed:futures-preview, 1)
    )" \
| xargs sed -i 's/\bfutures::/futures_old::/'
```

Reviewed By: jsgf

Differential Revision: D20168958

fbshipit-source-id: d2c099f9170c427e542975bc22fd96138a7725b0
2020-03-02 21:02:50 -08:00
Thomas Orozco
16384599a8 mononoke (+ rust/shed/async_unit): update async_unit to expect async fn's
Summary:
This allows code that is being exercised under async_unit to call into code
that expects a Tokio 0.2 environment (e.g. 0.2 timers).

Unfortunately, this requires turning off LSAN for the async_unit tests, since
it looks like LSAN and Tokio 0.2 don't work very well together, resulting in
LSAN reporting leaked memory for some TLS structures that were initialized by
tokio-preview (regardless of whether the Runtime is being dropped):
https://fb.workplace.com/groups/rust.language/permalink/3249964938385432/

Considering async_unit is effectively only used in Mononoke, and Mononoke
already turns off LSAN in tests for precisely this reason ... it's probably
reasonable to do the same here.

The main body of changes here is also about updating the majority of our
changes to stop calling wait(), and use this new async unit everywhere. This is
effectively a pretty big batch conversion of all of our tests to use async fns
instead of the former approaches. I've also updated a substantial number of
utility functions to be async fns.

A few notable changes here:

- Some pushrebase tests were pretty flaky — the race they look for isn't
  deterministic. I added some actual waiting (using pushrebase hooks) to make
  it more deterministic.  This is kinda copy pasted from the globalrev hook
  (where I had introduced this first), but this will do for now.
- The multiplexblob tests don't work at all with new futures, because they call
  `poll()` all over the place. I've updated them to new futures, which required
  a bit of reworking.
- I took out a couple tests in async unit that were broken anyway.

Reviewed By: StanislavGlebik

Differential Revision: D19902539

fbshipit-source-id: 352b4a531ef5fa855114c1dd8bb4d70ed967dd55
2020-02-18 01:55:00 -08:00
Lukasz Piatkowski
542d1f93d3 Manual synchronization of fbcode/eden and facebookexperimental/eden
Summary:
This commit manually synchronizes the internal move of
fbcode/scm/mononoke under fbcode/eden/mononoke which couldn't be
performed by ShipIt automatically.

Reviewed By: StanislavGlebik

Differential Revision: D19722832

fbshipit-source-id: 52fbc8bc42a8940b39872dfb8b00ce9c0f6b0800
2020-02-11 11:42:43 +01:00
Lukasz Piatkowski
e8d62b64d5 mononoke: move the codebase under eden/ directory
fbshipit-source-id: 43a0252cb3ec42aa365f20d1b6faa4d24d74c9b8
2020-02-06 13:46:04 +01:00