Commit Graph

271 Commits

Author SHA1 Message Date
Jun Wu
5e451d07b1 nameset: DagSet
Summary:
Wraps SpanSet + IdMap so it only exposes commit names without ids.
There is no equivalent smartset in Mercurial.

Reviewed By: sfilipco

Differential Revision: D19912112

fbshipit-source-id: 0d257de11527dfa8836065ac94f652730a97a468
2020-02-28 16:35:20 -08:00
Jun Wu
e7e7a5b356 nameset: StaticSet
Summary: Similar to Mercurial's smartset.baseset. All names are statically known.

Reviewed By: sfilipco

Differential Revision: D19912105

fbshipit-source-id: e4fcf2d59291adb3ca01b3b90f1ac32c65ad7eaa
2020-02-28 16:35:20 -08:00
Jun Wu
349d1bc33e nameset: IntersectionSet
Summary: Similar to Mercurial's smartset.filterset.

Reviewed By: sfilipco

Differential Revision: D19912113

fbshipit-source-id: 7cf2101b2eb7ba34b542199293cdbfd3973ef72f
2020-02-28 16:35:19 -08:00
Jun Wu
c0a1a3ab22 nameset: DifferenceSet
Summary: Similar to Mercurial's smartset.filterset.

Reviewed By: sfilipco

Differential Revision: D19912107

fbshipit-source-id: a3187c94f8e0c64f6d92e924ba46e83ce74c3e19
2020-02-28 16:35:19 -08:00
Jun Wu
b6cea95ea5 dag: use Bytes to avoid some VertexName copies
Summary:
This is an example about how to use the new Bytes type. The performance change
is not obviously visible in benchmarks since the bottleneck is not at the bytes
copying.

Reviewed By: DurhamG

Differential Revision: D19818720

fbshipit-source-id: a431ae206cfa4fa08b2e162a48b3d7cbcd900f7f
2020-02-28 09:23:59 -08:00
Jun Wu
76ab726056 dag: switch from bytes to minibytes
Summary: The APIs are compatible so the switch is straightforward.

Reviewed By: DurhamG

Differential Revision: D19818713

fbshipit-source-id: 504e9149567c90eb661804e0dad20580a401aa76
2020-02-28 09:23:59 -08:00
Jun Wu
9e3920ca1c dag: fix benchmarks
Summary: D19559127 forgot those files.

Reviewed By: DurhamG

Differential Revision: D19818715

fbshipit-source-id: 92321492eae89ed9f748800b3bfcc306a54aab20
2020-02-28 09:23:59 -08:00
Jun Wu
c417232b1b mutationstore: update lag_threshold
Summary:
D20042045 changes the meaning of "lag_threshold". Update the value in mutation
store accordingly.

Reviewed By: DurhamG

Differential Revision: D20043116

fbshipit-source-id: 154e6dc2aa88ab0a9a9b21929ae5fa6163dcd403
2020-02-28 09:23:59 -08:00
Jun Wu
1962fd5f5b indexedlog: update lagging indexes at open time
Summary:
Previously indexes are only updated at `sync()` time. This diff makes it so
`open()` can also update lagging indexes. This should make index migration
(ex. D19851355) smoother - indexes are built in time and users suffer less from
the absent of indexes.

Reviewed By: DurhamG

Differential Revision: D20042046

fbshipit-source-id: 20412661a0ca4f5f67b671137c47b6373a42981d
2020-02-28 09:23:58 -08:00
Jun Wu
6da3bdadd2 indexedlog: extract logic writing indexes to disk to a method
Summary: The logic is currently only used by `sync()`. I'd like to reuse it at `open()`.

Reviewed By: DurhamG

Differential Revision: D20042044

fbshipit-source-id: 5c9734ff68bdcf8f8c8710c6a821b18d3afeaca0
2020-02-28 09:23:58 -08:00
Jun Wu
afb24f8a8a indexedlog: change IndexDef.lag_threshold from bytes to entries
Summary:
This is more friendly for indexedlog users - deciding lag_threshold by number
of entries is easier than by bytes.

Initially, I thought checking `bytes` is cheaper and checking `entries` is more
expensive. However, practically we will have to build indexes for `entires`
anyway. So we do know the number of entries lagging behind.

Reviewed By: DurhamG

Differential Revision: D20042045

fbshipit-source-id: 73042e406bd8b262d5ef9875e45a3fd5f29f78cf
2020-02-28 09:23:58 -08:00
Jun Wu
55363a78a7 indexedlog: add API to convert &[u8] to zero-copy Bytes
Summary:
This can be useful for users of indexedlog when they want `Bytes` (to get rid
of the lifetime parameter).

This might be useful for storage layer that wants to take the ownership of the
returned bytes.

Reviewed By: xavierd

Differential Revision: D19818714

fbshipit-source-id: cb2d4e7deff921915e07454fee15cb94a3d5c00d
2020-02-28 09:23:57 -08:00
Jun Wu
556850e715 indexedlog: remove unused mmap utility functions
Summary: Those utilities are no longer necessary since the new code uses Bytes.

Reviewed By: xavierd

Differential Revision: D19818717

fbshipit-source-id: 0b43af0f1eae1a4288e84d4170db058b27f80334
2020-02-28 09:23:57 -08:00
Jun Wu
aaf59c569d indexedlog: replace Mmap with Bytes in Log
Summary: This simplifies the code a bit and makes it cheaper to clone the Log.

Reviewed By: xavierd

Differential Revision: D19818716

fbshipit-source-id: bbf07b8b36009d53b63d8066ec422fc3c3796840
2020-02-28 09:23:57 -08:00
Jun Wu
90ee3cb05a indexedlog: remove ChecksumTable
Summary: It's no longer used since Index now has inlined its checksum logic.

Reviewed By: ikostia

Differential Revision: D19850744

fbshipit-source-id: eb134e4c1613573a2d238710b44ad8119c80a5ee
2020-02-28 09:23:56 -08:00
Jun Wu
a1601bfdd9 indexedlog: bump index filename
Summary:
Change index filename and metadata name. This makes sure the new format and old
format are separate so upgrading or downgrading won't have issues.

Reviewed By: DurhamG

Differential Revision: D19851355

fbshipit-source-id: 25dee018073a90040f5818b32b753a3f589c10e0
2020-02-28 09:23:56 -08:00
Jun Wu
6f4bf325d5 indexedlog: write Checksum inline with Log
Summary:
Enhance the index format: The Root entry can be followed by an optional
Checksum entry which replaces the need of ChecksumTable.

The format is backwards compatible since the old format will be just
treated as "there is no ChecksumTable", and the ChecksumTable will be built on
the next "flush".

This change is non-trivial. But the tests are pretty strong - the bitflip test
alone covered a lot of issues, and the dump of Index content helps a lot too.

For the index itself without ".sum", checksum, this change is bi-directional
compatible:
1. New code reading old file will just think the old file does not have the
   checksum entry, similar to new code having checksum disabled.
2. Old code will think the root+checksum slice is the "root" entry. Parsing
   the root entry is fine since it does not complain about unknown data at the
   end.

However, this change dropped the logic updating ".sum" files. That part is an
issue blocking old clients from reading new data.

Reviewed By: DurhamG

Differential Revision: D19850741

fbshipit-source-id: 551a45cd5422f1fb4c5b08e3b207a2ffe3d93dea
2020-02-28 09:23:55 -08:00
Jun Wu
b9e3046a8d indexedlog: add Checksum entry to Index
Summary:
To solve the soundness issue of ChecksumTable raised by the last diff.
I plan to move Checksum logic to Index. This has multiple benefits:
- Solve the soundness issue of ChecksumTable.
- Indexedlog no longer writes the ".sum" files. `atomic_write` can be quite
  slow (tens of milliseconds) on Windows. So this should help perf - with
  many indexes, it can save hundreds of milliseconds on Windows per
  indexedlog sync.

This diff adds the definition and serialization of the new Checksum entry.
The index format is not updated yet.

Reviewed By: markbt

Differential Revision: D19850742

fbshipit-source-id: df6e6ed12a12ef0d2a782dc9d6b4dc5dec3f4b46
2020-02-28 09:23:55 -08:00
Jun Wu
0f09413ed4 indexedlog: add a broken test showing checksum_table is racy
Summary:
With the last change, mmap cost is reduced, but ChecksumTable is unsound in a
corner case: the buffer to check is shorter than what ChecksumTable covers:

    checksum:  |----chunk----|----chunk----|----chunk--|
    buf:       |-------------------------------|       |
                                               ^       ^
                                        logic len     physical len

The checksum table will be unable to verify the last chunk, since it does not
have enough data in buf.

The issues is exposed by stress testing the multithread sync tests. It's not
always easy to reproduce, though.

Reviewed By: markbt

Differential Revision: D19850745

fbshipit-source-id: a1a96080163b7b9b56dcd6c1673d5d8d10e18a2b
2020-02-28 09:23:55 -08:00
Jun Wu
1e10527482 indexedlog: share Bytes between Index and ChecksumTable
Summary: This avoids some extra mmap syscalls by ChecksumTable.

Reviewed By: xavierd

Differential Revision: D19818721

fbshipit-source-id: dace55193f2b4b0f35e3868781faa2d2998d3b58
2020-02-28 09:23:54 -08:00
Jun Wu
1ece621c4d indexedlog: replace Mmap with Bytes in Index
Summary:
This simplifies the code a bit (no special cases about 0-sized mmap buffers)
and makes it cheaper to clone the index buffer (just an Arc::clone, without
another mmap syscall).

Reviewed By: xavierd

Differential Revision: D19818718

fbshipit-source-id: e96d42af74c7f0bb11703c5da31cdfbd5d76c372
2020-02-28 09:23:54 -08:00
Jun Wu
918672b106 tracing-collector: support owned strings in TreeSpans
Summary:
TreeSpans used to use `&str`, which adds a lifetime to the struct, making it
harder to be used in the Python land. Use a type parameter so TreeSpans<String>
can be used.

Reviewed By: DurhamG

Differential Revision: D19797708

fbshipit-source-id: c66429abfaf16d876151ca6f29da976bed91485d
2020-02-28 09:16:14 -08:00
Jun Wu
4cd7df6a01 tracing-collector: rename structs
Summary:
TreeSpan -> RawTreeSpan; TreeSpanWithMeta -> TreeSpanRef.

I'm going to add a non-reference version of TreeSpanRef.

Differential Revision: D19797701

fbshipit-source-id: 42b04c23d4d0ddbe821b94fa2ccb133ce9eafa05
2020-02-28 09:16:14 -08:00
Jun Wu
957617c8b8 tracing-collector: support filtering in TreeSpans
Summary:
The filtering interface allows callsite to select what they want. It's similar
to manifest walk with files or directory matchers in source control.

Reviewed By: DurhamG

Differential Revision: D19784467

fbshipit-source-id: 5cf6e4016d6fa1c90f8aeccc50809baccd4af5ab
2020-02-28 09:16:13 -08:00
Jun Wu
366e701239 tracing-collector: support Events in TreeSpans
Summary: The idea is that instants (events) can be a drop-in replacement for `ui.log`.

Reviewed By: DurhamG

Differential Revision: D19782897

fbshipit-source-id: 795bbba23d921e460f723f19ef529b203aea366a
2020-02-28 09:16:13 -08:00
Jun Wu
d205592d42 tracing-collector: extract logic finding parent span to a function
Summary: This function will be reused by the next diff.

Reviewed By: DurhamG

Differential Revision: D19782895

fbshipit-source-id: 1e636eabee9b0dffd287a1e6784a24ab2259f51f
2020-02-28 09:16:13 -08:00
Jun Wu
8b5fdc01fc tracing-collector: put treespans into a struct
Summary: This allows us to define methods on the treespans, such as filtering APIs.

Reviewed By: DurhamG

Differential Revision: D19782896

fbshipit-source-id: 2e7bd8344c0196e382728c26a8233abf944bbf29
2020-02-28 09:16:12 -08:00
David Tolnay
37a8401761 rust/thrift: Un-rename futures-preview dependency
Summary: The Thrift generated code depends only on futures 0.3, not 0.1. Thus it isn't necessary to depend on renamed:futures-preview and we can depend on futures-preview directly, which is exposed to Rust code as `futures::`.

Reviewed By: jsgf

Differential Revision: D20145921

fbshipit-source-id: 5cae94ec6747a374c2bf05f124ab237c798de005
2020-02-27 22:27:58 -08:00
Xavier Deguillard
6fac9ebad0 revisionstore: add a get_stripped method to ContentStore
Summary:
This new method returns the content of a blob without the copy-from metadata
header.

Reviewed By: DurhamG

Differential Revision: D20102889

fbshipit-source-id: e96f636b7d30460b59707a2cb700d667e616116a
2020-02-27 12:29:42 -08:00
Jun Wu
bce29c9562 nameset: UnionSet
Summary: Similar to Mercurial's smartset.addset.

Reviewed By: sfilipco

Differential Revision: D19912106

fbshipit-source-id: 0d0c8d0b71d2757259d26295eb4a564fea807dea
2020-02-27 07:34:57 -08:00
Jun Wu
c906a21ce1 nameset: initial NameSet abstraction
Summary:
The NameSet is something similar to SpanSet and Mercurial's smartset but speaks
VertexNames instead of Ids. The idea is, NameSet will be part of NameDag APIs,
and potentially replace Mercurial's smartset layer (just smartset the container
types, not the revset language), in a way that revision numbers are completely
hidden behind the scenes.

This diff adds some basic abstraction around iteration-related operations.
Other operations will be added later.

Reviewed By: sfilipco

Differential Revision: D19912109

fbshipit-source-id: 504a26c074282ec51f260535ca63e943124f688e
2020-02-27 07:34:57 -08:00
Adam Simpkins
0ffcf3e450 update the Rust print_status() function to take an IO parameter
Summary:
Update the `print_status()` function to take a `clidispatch::io::IO` object as
a parameter, instead of a simple output object.  This will allow us to also
print error messages from this function in a future diff.

Reviewed By: quark-zju

Differential Revision: D19958504

fbshipit-source-id: bf482fdc4420e1350363a730c6a539cd760aef25
2020-02-26 14:54:40 -08:00
Adam Simpkins
b22fc79e4b clean up PathRelativizer API usage of Path vs PathBuf
Summary:
Fix the PathRelativizer APIs to accept `Path` and even `str` arguments instead
of just `PathBuf`.  The old code required a `PathBuf`, which often forced
callers to make a copy of the path data.

Reviewed By: quark-zju

Differential Revision: D19958505

fbshipit-source-id: 6fa40dd4b75df4e3faf9ad2ae4f0e4e6595669f6
2020-02-24 15:38:36 -08:00
Xavier Deguillard
934b64397b convert to bytes 0.5
Summary:
The bytes 0.5 is a depencency of newer tokio, it's also newer, and thus better.
Staying on 0.4 means that copies between Bytes 0.4 and 0.5 need to be done,
this will be especially bad in the LFS code since 10+MB buffer will have to be
copied...

One main API change is for the configparser. The code used to take Into<Bytes>
for the keys, I switched it to AsRef<[u8]>.

For hg_memcache_client, an extra copy is performed to build a Delta, since this
code uses an old tokio, and is being replaced right now, the effort of
switching to a new tokio and new bytes was not deemed worth it, the copy will
do for now.

Reviewed By: dtolnay

Differential Revision: D20043137

fbshipit-source-id: 395bfc3749a3b1bdfea652262019ac6a086e61e0
2020-02-24 10:28:46 -08:00
Jun Wu
142937c2f8 cargo: bump serde_cbor to 0.11
Summary: Follow up of D20024491.

Reviewed By: sfilipco

Differential Revision: D20043585

fbshipit-source-id: f66896c8f41c3918fb37611d87fa26c39cdecef1
2020-02-21 14:08:43 -08:00
Xavier Deguillard
44c4f2f5d9 revisionstore: add copyfrom information to the LFS pointer
Summary:
Mercurial filenode hash is computed by including the copy information in the
blob header. Before computing the blob content hash, or returning it to the
upper layers, we need to either strip or reconstruct this header appropriately.

Reviewed By: DurhamG

Differential Revision: D19975887

fbshipit-source-id: 7555e7219e50f4d18ec677fdecc216ee705d7af4
2020-02-20 14:28:52 -08:00
Xavier Deguillard
7fb75ce4f0 lfs: move contenthash computation to the enum impl
Summary: This will make it easier to support more hash schemes in the future.

Reviewed By: DurhamG

Differential Revision: D19975888

fbshipit-source-id: 8b8ce3b20d72199bac3cd20a48475b5ab56bfc52
2020-02-20 14:28:52 -08:00
Xavier Deguillard
cd56a8b39a revisionstore: move Arc outside of the stores
Summary:
With the Arc embedded into the store themselves, this forces a second
allocation in order to use them as trait objects. Since in most cases, we do
not want the stores themselves to be cloneable, we can move the Arc outside and
thus reduce the number of pointer indirection.

Reviewed By: DurhamG

Differential Revision: D19867568

fbshipit-source-id: 9cd126831fe2b9ee715472ac3299b7a09df95fce
2020-02-20 14:28:52 -08:00
Xavier Deguillard
7c1a623d8a revisionstore: add the LfsStore to the ContentStore
Summary:
The ContentStore now can read LFS blobs from both the shared cache, and the
local store.

Reviewed By: DurhamG

Differential Revision: D19866249

fbshipit-source-id: a6fb3523495e9d3832613b56438f631cfa552b91
2020-02-20 14:28:51 -08:00
Xavier Deguillard
58d9d92e88 revisionstore: simplify ContentStore/MetadataStore initialization a bit
Summary:
With the LFS store being added, and the indexedlog being soon used for trees,
this simplification should help in formalizing the hierarchy of files/folders.

It will look like the following:
  <root dir>/lfs: for the lfs store
  <root dir>/indexedlog*: for the indexedlog
  <root dir>/foobar: for a hypothetical foobar store

For manifests, <root dir> will therefore be: <store dir>/manifests. The
unfortunate part is that the current tree data lives under
<store dir>/packs/manifests. As packfiles will be replaced, this small
discrepency is acceptable.

Reviewed By: DurhamG

Differential Revision: D19866248

fbshipit-source-id: 7ef59ef7df19149b19a529b4f4a45a479cc9d23b
2020-02-20 14:28:51 -08:00
Xavier Deguillard
f512b5658d revisionstore: add an LfsStore
Summary:
This is the first step in having a stronger integration between LFS blobs and
the ContentStore abstraction. The 2 main difference between the Python based
LFS implementation and this one are:
 - pointers are not stored alongside plain data,
 - blobs are split between local and shared blobs

As of now, no reclamation is being performed for shared blobs, blobs aren't
fetched or uploaded. This will come in future diffs.

Reviewed By: DurhamG

Differential Revision: D19859291

fbshipit-source-id: 45000fc574e6fbd6d3487f4966cad4f49dab731c
2020-02-20 14:28:51 -08:00
Adam Simpkins
5ffa268af2 use absolute includes for the native cext modules
Summary:
Update the C files under edenscm/mercurial/cext to use absolute includes from
the repository root.  Also update a few of the libraries in edenscm/mercurial
that the cext code depends on.

This makes these files easier to build with Buck in fbsource, and reduces the
number of places where we have to use deprecated Buck functionality to help
find these headers.  This also allows autodeps to work with the build targets
for these rules.

Reviewed By: xavierd

Differential Revision: D19958221

fbshipit-source-id: e6e471583a795ba5773bae5f16ed582c9c5fd57e
2020-02-19 13:05:06 -08:00
Lukas Piatkowski
c4f0887fc2 eden/scm: cover xdiff with autocargo
Summary: Generate the Cargo.toml files inside xdiff with autocargo. This will enable Mononoke to depend on this code easily without sacrificing anything on eden/scm side.

Reviewed By: aslpavel

Differential Revision: D19948741

fbshipit-source-id: 905ff3d64b90830e5f075e4c6ed2b3de959e3f00
2020-02-19 05:15:17 -08:00
Xavier Deguillard
d8064b5e2a types: add a Sha256 type
Summary: This will be used in the LFS store.

Reviewed By: DurhamG

Differential Revision: D19895803

fbshipit-source-id: 4cf447987c10fed0b5c98904f20c841428965d89
2020-02-18 08:32:33 -08:00
Xavier Deguillard
17cc9ab5ab revisionstore: add a wrapper around IndexedLog/RotateLog
Summary:
In some cases, higher level stores may want to store data in either a plain
IndexedLog, or in a RotateLog, for local and shared data. Due to slight
difference between the 2, they can't easily be adapted into a common trait.

Instead let's just wrap both into an enum and implement the main functions that
the higher level stores need.

The first use of this will be the LfsStore, future use will include the
IndexedLogDataStore and the IndexedLogHistoryStores.

Reviewed By: DurhamG

Differential Revision: D19859292

fbshipit-source-id: 920572e0cf5f69bda4901a727a6b0dc0f08fc8d0
2020-02-18 08:32:32 -08:00
Durham Goode
f530333e06 edenfs: update eden thrift types
Summary:
When I run make local it's creating changes in our checked in thrift
types. I guess I need to check these in?

Reviewed By: quark-zju

Differential Revision: D19848706

fbshipit-source-id: 8a2e9a2617734eda41eade1f2645689362b1d75d
2020-02-17 14:52:29 -08:00
Xavier Deguillard
7bb3e384d8 remotefilelog: append the repo name to memcache key
Summary:
Up to now, this has been done in chef, and thus for repos that we do not list,
they may share the memcache keys, with potential unintended consequences. Let's
always add the repo name to the key, so we can simplify the code in chef.

One small negative effect of this change is that while it is being rolled out,
the cache hit rate will be impacted. This should resolve itself quickly.

Reviewed By: DurhamG

Differential Revision: D19885775

fbshipit-source-id: 0b59ce9e378b0ab70f696a39d19d27cd89921098
2020-02-14 14:10:48 -08:00
Xavier Deguillard
28564b228d backingstore: do not fail if memcache can't be initialized
Summary:
Failing means that we fallback to the Python importer. Let's simply warn about
it.

Reviewed By: fanzeyi

Differential Revision: D19897274

fbshipit-source-id: f9c63f5aa76015c28b31f00bba98244f5c86e923
2020-02-14 09:00:27 -08:00
Jun Wu
03baa31789 indexedlog: switch from bytes to minibytes
Summary:
This makes it possible to use `Bytes` for mmap buffers.

The changes are because `minibytes::Bytes` does not implement `From<&[u8]>`
with the intention to make slice copy explicit.

Reviewed By: xavierd

Differential Revision: D19818719

fbshipit-source-id: c34ee451bfd2dc7bcbbcebd52a76444b6c236849
2020-02-12 13:57:37 -08:00
Xavier Deguillard
49c953bc7e backingstore: plumb the MemcacheStore
Summary:
EdenFS will now be able to fetch blobs directly from memcache. This won't have
any big benefits as no blobs are in memcache right now, but over time, this
will significantly reduce the cost of fetching blobs.

Reviewed By: fanzeyi

Differential Revision: D19861643

fbshipit-source-id: c2e9d317bd30d4656bf0b3f8897794161697761a
2020-02-12 13:43:00 -08:00