Commit Graph

160 Commits

Author SHA1 Message Date
Katie Mancini
76df592222 allow multiple prefixes for paths to be logged
Summary:
Currently we use a single path prefix to configure data fetch logging in eden
(i.e if the path of a file which we fetch is an extension of our configured
path, then we log that data fetch. )

There is some interest in extending this to multiple path prefixes, so that we
can log separate parts repo.

Reviewed By: StanislavGlebik

Differential Revision: D22877942

fbshipit-source-id: f6eb3dcb4fa460b4acab09677e972caf9421ddff
2020-09-02 22:54:23 -07:00
Xavier Deguillard
f4f159537f utils: add a platform independent FileUtils
Summary:
Up to now, Windows had to have its own version of folly::{readFile, writeFile,
writeFileAtomic} as these only operate on `char *` path, which can only
represent ascii paths on Windows. Since the Windows version is slightly
different from folly, this forced the code to either ifdef _WIN32, or use the
folly version pretending that it would be OK. The Windows version was also
behaving slightly differently from folly. For instance, where folly would
return a boolean to indicate success, on Windows we would throw an exception.

To simplify our code, add type safety and unify both, we can implement our own
wrappers on top of either folly or Windows APIs.

We still have some code that uses folly::readFile but these should only be
dealing with filedescriptors. As a following step, we may want to have our own
File class that wraps a file descriptor/HANDLE so we can completely remove all
uses of folly::readFile.

Reviewed By: wez

Differential Revision: D23037325

fbshipit-source-id: 2b9a026f3ee6220ef55097abe649b23e38d9fe91
2020-08-14 18:56:33 -07:00
Xavier Deguillard
76ea3054de win: conditionally enable negative path caching
Summary:
From a quick experiment, this greatly cuts down on the amount requests to
nonexistent files. For instance, the .hg directory in folders is now only
looked up once and no longer afterwards.

Reviewed By: wez

Differential Revision: D23112343

fbshipit-source-id: 223134ca591054ae9ac2e839033bbd1b714443da
2020-08-14 17:35:50 -07:00
Ailin Zhang
58561f9df2 use Eden native import in prefetchBlobs
Summary: Previously we use HgImporter prefetch request in `prefetchBlobs()`, but using `getBlob()` can give us more control over the prefetch process later. So now `getBlob()` is used in `prefetchBlobs()` when `useEdenNativePrefetch` is configured as true.

Reviewed By: kmancini

Differential Revision: D22984848

fbshipit-source-id: 0bd0b1c5b50bb16da36f188915904d0223827dc3
2020-08-13 21:09:09 -07:00
Katie Mancini
58d012d8b4 enable metadata fetching by manifest id
Summary:
Previously we fetched metadata by commit hash and path. We knew this would be a
little extra expensive, but turns out this is a lot extra expensive.

Wait why is it expensive?
In short: lots of extra lookups that are not satisfied by cache :(
In long:
1. Each piece of the path would require a read to fetch the fsnode for that tree.
So this means asking for the metadata of a/b/c/d/e means 5 reads.
2. Normally these reads could be cached, but often we would make these requests
with a commit hash for a draft commit. On the server side this info is not
cached for a draft commit, this means a lot of database reads and recalculating.
(Most of the real uses of metadata prefetching is when an engineer is working
on a local commit. We just use the commit hash of the commit the user was on
when fetching metadata for a tree, even if that tree hasn't changed since a public
commit. so this means lots of requests with draft commit hashes).

Fetching by manifest id we are able to bypass this sequential path look up.
(and even if we are on a draft commit, if the tree has not locally changed
since a public commit, the manifest id will be the same as the public commit
avoiding this whole draft commit issue).

This allows us to query scs with a manifest id for a tree.

Reviewed By: wez

Differential Revision: D22990687

fbshipit-source-id: aa81d67de1f1d04a14d174774ee216f5ac6be5ba
2020-08-10 23:53:10 -07:00
Victor Zverovich
e3f4a56f6b Migrate to field_ref Thrift API
Summary:
We are unifying C++ APIs for accessing optional and unqualified fields:
https://fb.workplace.com/groups/1730279463893632/permalink/2541675446087359/.

This diff migrates code from accessing data members generated from unqualified
Thrift fields directly to the `field_ref` API, i.e. replacing

```
thrift_obj.field
```

with

```
*thrift_obj.field_ref()
```

The `_ref` suffixes will be removed in the future once data members are private
and names can be reclaimed.

The output of this codemod has been reviewed in D20039637.

The new API is documented in
https://our.intern.facebook.com/intern/wiki/Thrift/FieldAccess/.

drop-conflicts

Reviewed By: yfeldblum

Differential Revision: D22631599

fbshipit-source-id: 9bfcaeb636f34a32fd871c7cd6a2db4a7ace30bf
2020-07-21 11:23:35 -07:00
Katie Mancini
d2b4855372 introduce scs metadata importer
Summary:
Prefetching metadata for the entries in a tree when we fetch it saves us
an extra round trip to the server to fetch a blob when only the metadata
for that blob is fetched. (This can happen often while parsing targets in
builds)

This implements a custom metadata fetcher to fetch this data when we
fetch a tree from the server.

Reviewed By: chadaustin

Differential Revision: D22086639

fbshipit-source-id: 5fe31d375bf6f7376eb67496d553d6b4540fc0c9
2020-07-10 16:03:32 -07:00
Katie Mancini
550400364d introduce tree metadata storage in local store
Summary:
This introduces a class to manipulate the metadata for all the entries in a
tree. This adds serialization and deserialization to this class so that it can
be written to the local store.

Why do we need this? We need some way to easily check when we have already
fetched metadata for a tree and do not need to refetch this from the server to
avoid expensive network requests. Later diffs add functionally to store the metadata
for tree entries in the local store under the tree hash using this class.

Reviewed By: chadaustin

Differential Revision: D21959015

fbshipit-source-id: 0c0e8750737f3076c1f9604d0319cab7f2658656
2020-07-10 16:03:32 -07:00
Ailin Zhang
7c603e51f8 make fetch heavy threshold configurable
Summary: This diff made fetch threshold configurable, so we can change it later as repository size grows.

Reviewed By: fanzeyi

Differential Revision: D22337850

fbshipit-source-id: 4b46420cb4e7164a3f1080279d67fa5f90549cd8
2020-07-02 08:44:02 -07:00
Katie Mancini
1876c4e77b adding logging for selective paths
Summary:
Eden can sometimes unexpectedly fetch files from the server, and we want
to know why this is happening. This adds logging for the source of
data fetching in edens backing store to help obviate why these fetches
are happening.

This temporarily adds the logging in the HgQueuedBacking store to get a naive
version of logging rolled out sooner. Follow up changes will move this logging
closer to the data fetching itself if possible (in HgDatapackStore and HgImporter).

Reviewed By: chadaustin

Differential Revision: D22012572

fbshipit-source-id: b1b012ce4ee133fbacecd586b7365c3c5a5386df
2020-06-23 10:02:41 -07:00
Chad Austin
e2d26877d6 enable py3 thrift language
Summary:
The old `py` Thrift language support doesn't correctly handle string
vs. bytes, which causes an exception to be thrown when deserializing
paths or blobs that aren't UTF-8.

We will eventually want to migrate to the py3 language implementation,
which supports streaming.

Reviewed By: genevievehelsel

Differential Revision: D21693082

fbshipit-source-id: 0ea10fd3960f5acba353bccb83b5cf539e7eeffb
2020-06-10 19:29:17 -07:00
Zeyi (Rice) Fan
d2facf6118 always use hgcache for data fetching
Summary: Reading from hgcache directly has been rolled out for quite a while now. Let's remove the configuration and make it default behavior.

Reviewed By: chadaustin

Differential Revision: D21585482

fbshipit-source-id: 7f30e262642adf58388a0580aa5a63595fa89155
2020-05-21 16:32:41 -07:00
Xavier Deguillard
1d10a0e1a0 config: add the TomlConfigTest.cpp to CMake
Summary: All the tests are passing.

Reviewed By: wez

Differential Revision: D21319018

fbshipit-source-id: 26335f39d39bdc379c00e65942c2cc7c6853089b
2020-05-09 08:46:36 -07:00
Xavier Deguillard
8220cac785 config: add FileChangeMonitorTest to the CMake build
Summary:
The disabled tests are due to the st_mtime stored in the struct stat only
having a second granularity (as expected), but the tests are changing these
files faster than that, causing them to fail. I'll attempt to fix the file
change detection mechanism on a later diff.

Reviewed By: wez

Differential Revision: D21319025

fbshipit-source-id: a3f2d62a3ce56fea37a62bfad73306ac1556f772
2020-05-09 08:46:35 -07:00
Xavier Deguillard
dd9ec5dffd config: add EdenConfigTest.cpp to CMake
Summary:
Same as the previous one, paths are different on Windows, and thus we need to
test against a different path.

Reviewed By: wez

Differential Revision: D21319021

fbshipit-source-id: 849c86574e69c3f638ea180c3b594aaeae2970ad
2020-05-09 08:46:35 -07:00
Xavier Deguillard
255b6777f9 config: add ConfigSettingTest to CMake
Summary:
The use of realpath is needed to resolve a unix-style path to a Windows style
one. This helps keep the test generic with no `#ifdef _WIN32`

Reviewed By: wez

Differential Revision: D21319019

fbshipit-source-id: b8cdd81f0afdd135849a5b850d854399cef8cef8
2020-05-09 08:46:35 -07:00
Adam Simpkins
1cf24c15b5 enable log rotation in edenfs_monitor
Summary:
Add new fields to EdenConfig to control log rotation settings, and update
edenfs_monitor to set up the log rotation strategy using these settings.

Reviewed By: chadaustin

Differential Revision: D20427271

fbshipit-source-id: 9960bdb6f4d077a4e21fb4a6209aa02ab21ad653
2020-05-07 20:05:46 -07:00
Xavier Deguillard
28091f0517 config: add CheckoutConfigTest to CMake build
Summary: They all pass.

Reviewed By: wez

Differential Revision: D21319024

fbshipit-source-id: 1d35490b9361347751b317796fe158635c03caca
2020-05-07 16:38:05 -07:00
Xavier Deguillard
241162beaa config: add CachedParsedFileMonitorTest to CMake build
Summary:
The disabled tests are due to the precision of st_mtime on Windows only being
a second, but the tests are changing the config faster than that.

Reviewed By: wez

Differential Revision: D21319023

fbshipit-source-id: bcdce24f70ce99984cabb290338ac94a2459e9de
2020-05-07 16:38:05 -07:00
Xavier Deguillard
8f872412e6 config: restrict stat comparison on Windows
Summary:
On Windows, the following pseudo code:

  int fd = open("file");
  struct stat st;
  fstat(fd, &st);

Will have a different st_dev than the following code:

  struct stat st;
  stat("file", &st);

Since the FileChangeMonitor uses st_dev as a way to compare if a file
changed, the config is always reloaded.

For our use case, the filesize and its mtime should be enough to know if the
configuration changed, so let's only use these 2 on Windows.

Reviewed By: wez

Differential Revision: D21312679

fbshipit-source-id: f08b3eb7d6037f5d88ece82efe3a5437b1954ba2
2020-05-05 18:14:55 -07:00
Xavier Deguillard
6d4a55a3ea win: change the argument order for writeFile
Summary:
This brings it closer to folly::writeFile which should help in avoiding ifdef
whenever we want to use it.

Reviewed By: wez

Differential Revision: D21319020

fbshipit-source-id: 80fbf7fba671b18b5ef68375910e1a2a8869f590
2020-05-05 18:14:54 -07:00
Chad Austin
61e738cd84 use enumValue instead of static_cast<int>
Summary:
Where appropriate, replace uses of `static_cast<int>` with
`enumValue`.

Reviewed By: simpkins

Differential Revision: D20975196

fbshipit-source-id: 581643366ea7eda5d1961238b0693cf45c4eec94
2020-04-28 18:59:34 -07:00
Puneet Kaushik
16bd8c5baf Use getFileContent() on Windows
Reviewed By: simpkins

Differential Revision: D20995872

fbshipit-source-id: ab089a4a94eac4844d173397f24c1cdbb2d06205
2020-04-24 12:46:18 -07:00
Adam Simpkins
34275429fe remove all CLI code dealing with the old legacy bind-mounts config
Summary:
The bind-mounts configuration has been ignored by EdenFS since D17236366.
This removes all CLI code for dealing with this config section.

Reviewed By: wez

Differential Revision: D20876460

fbshipit-source-id: 6b3f3552de25ee28fc0418a6aaec14446520203c
2020-04-09 17:31:03 -07:00
Adam Simpkins
92825c4863 exit if the EdenFS lock file ever becomes invalid
Summary:
In rare situations users end up manually deleting or removing their `.eden`
state directory without ever killing their running `edenfs` process.  This can
leave this old process running indefinitely despite the fact that it's state
directory is no longer present (or has perhaps even been replaced with new
data).

This updates edenfs to periodically check if its lock file is still valid, and
quit if it isn't.  This will help prevent old `edenfs` processes from running
indefinitely after their state directory is no longer valid.

Reviewed By: wez

Differential Revision: D20613841

fbshipit-source-id: d9a3a1e7e9b05806e086e794ebbc36e1cc71831a
2020-03-26 20:17:12 -07:00
Zeyi (Rice) Fan
d58863bde2 make hgcache direct read as default
Summary: It seems to be stable and not causing issues. Let's make it default everywhere.

Reviewed By: wez

Differential Revision: D19896738

fbshipit-source-id: cf6abe8f536e570017742b3a0674213a932a6a4d
2020-02-20 16:58:10 -08:00
Wez Furlong
28f7b4a0b0 eden: show desktop notification for blob/tree fetch errors
Summary:
This commit causes a desktop notification to be shown if we generate
EIO or ETIMEDOUT responses via fuse; the prompt is intended to make it obvious
to the user that they need to connect to the VPN.

The commit by itself doesn't show a notification, it allows configuring a
command that can be run to do something to show a notification.

The test plan includes one such configuration for our corp environment.

* It doesn't trigger for thrift-originated downloads (eg: prefetch), only for
  VFS operations through FUSE.
* Ideally we'd know exactly when we have a network related error in the store
  code and use that to trigger the notification.  However, we have a rather
  convoluted set of importers and fallbacks today, one of which is interpreting
  a generic response returned from a pipe, so it is not especially clear
  exactly where we should locate the logic

Reviewed By: chadaustin

Differential Revision: D17513364

fbshipit-source-id: 45134f3672679cb5580cb0c1bc12a0d6e38525ca
2020-02-10 08:28:49 -08:00
Chad Austin
80b1296a05 add helper for setting default values in toml tables
Summary:
cpptoml has traversal functionality for table reads, but not for
writes. Add a helper function for reading a config value and updating
the TOML table if it's unset.

Reviewed By: fanzeyi

Differential Revision: D19671264

fbshipit-source-id: e2b78d338af35d51fddaa258b7f45f8966d00a26
2020-02-05 11:20:26 -08:00
Chad Austin
daaeb5012a replace some uses of memset
Summary: Easier to zero initialize structs with braces, which defines that even padding is zeroed.

Reviewed By: wez

Differential Revision: D19655675

fbshipit-source-id: 2fd12383324029646707e93008cf9ad34e9f1dce
2020-01-31 10:50:48 -08:00
Chad Austin
3199c553fa remove the legacy bind mount code from CheckoutConfig
Summary: This code is no longer used now that `eden redirect` exists.

Reviewed By: wez

Differential Revision: D19565010

fbshipit-source-id: 4703bc39a024c4c491a83ef5a6e85711a8f7e4d8
2020-01-24 18:11:36 -08:00
Chad Austin
f7491f7741 add independent cache size limits per object type
Summary:
Instead of clearing every single cached object when the total size
exceeds the ephemeral storage limit, keep a limit per object type and
only clear those that exceed their quota.

Reviewed By: simpkins

Differential Revision: D19358312

fbshipit-source-id: 6918d6f4cc2931aed79a9025d0e0f357ede515e0
2020-01-21 19:41:47 -08:00
Adam Simpkins
983f454135 limit the number of tree prefetch operations that can run in parallel
Summary:
Add a config option to restrict the number of tree prefetches that can run in
parallel.  Without this applications that recursively walk a checkout tree can
end up spawning a huge number of asynchronous prefetch operations.  These
prefetch operations are quite expensive today, as we currently have to fetch
the full file contents in order to retrieve the file sizes.  A recursive
directory walk can end up building up a huge backlog of in-progress tree
prefetches.  This will slow down the directory walk, and it can take tens of
minutes to finish processing the prefetch backlog even after the directory
walk is aborted.

Reviewed By: chadaustin

Differential Revision: D19136685

fbshipit-source-id: cdc7a570d016fd7ca81a639cef83380b197acdfc
2019-12-20 16:14:19 -08:00
Zeyi (Rice) Fan
ae1dae6b96 eden: add experimental:use-edenapi for optionally turn on EdenApi importing
Summary:
Add an option `experimental:use-edenapi` to `EdenConfig`.

See the next diff for usage.

Reviewed By: chadaustin

Differential Revision: D18605549

fbshipit-source-id: 2786c21bb38a76229078662cc5c1ddf906d1be4a
2019-12-10 13:40:55 -08:00
Zeyi (Rice) Fan
ed9e7abca2 eden: add FakeEdenConfig for testing
Summary:
I think we need to make `EdenConfig` available for testing as more things are using `EdenConfig` to configure behaviors.

Right now it does not do much things other than just construct an `EdenConfig` instance without manually providing these parameters.

Reviewed By: chadaustin

Differential Revision: D18798484

fbshipit-source-id: b4a85d966a9b4f425c547bef9eb6e7570d7e2170
2019-12-10 13:40:55 -08:00
Chad Austin
f930a40434 make PathComponentPiece and RelativePathPiece constexpr
Summary: Allow creation of PathComponentPiece and RelativePathPiece values at compile-time.

Reviewed By: wez

Differential Revision: D18642594

fbshipit-source-id: 209e5c27e8fab1e877ccee8558fa757b68078e66
2019-12-04 13:30:18 -08:00
Adam Simpkins
e07f8bd7b6 refactor the EDEN_BUG() macro
Summary:
This splits `EDEN_BUG()` into three separate version.  All three crash in
debug mode builds, but in release builds they behave differently:

- `EDEN_BUG()` throws an exception
- `EDEN_BUG_FUTURE(Type)` returns a `folly::Future<Type>` that has been
  fulfilled with an exception.
- `EDEN_BUG_EXCEPTION()` returns a `folly::exception_wrapper`.

The main advantage of this is that this allows the compiler to detect that
`EDEN_BUG()` can never return.  Previously `EDEN_BUG()` was used for all 3 of
these different cases, and its behavior depended on whether `toException()`
was ever called.  As a result we could not easily get the compiler to identify
code paths where we know at compile time that it will never return.

Reviewed By: chadaustin

Differential Revision: D18652103

fbshipit-source-id: 070107c7520f51b05696905fa243de5f8df15958
2019-11-22 15:38:33 -08:00
Zeyi (Rice) Fan
dee0478903 eden: add experimental:enable-blob-caching
Summary: Adding an experimental option to EdenFS so we can disable blob caching if we need.

Reviewed By: chadaustin

Differential Revision: D18441665

fbshipit-source-id: 56751c0199d6658bfbf7ec3865f746a7279324ab
2019-11-21 12:05:29 -08:00
Genevieve Helsel
3807e751ca make enforceParents configurable for getScmStatusV2
Summary: This reads `enforceParents` from a config instead of always assuming true for `getScmStatusV2()`. This will allow a easy kill switch in case throwing errors from this thrift call causes issues with something that calls hg status

Reviewed By: simpkins

Differential Revision: D18258164

fbshipit-source-id: 1ae421a941c01a678d25d5453c771262b03558d0
2019-11-20 17:51:21 -08:00
Chad Austin
8bf6a06bfa fail with a more sensible error if a SNAPSHOT file is missing
Summary:
If a checkout's SNAPSHOT file disappeared, the mount error given would
be that a Hash had an invalid size. Instead, throw a file not found
error on mount.

Reviewed By: genevievehelsel

Differential Revision: D18381074

fbshipit-source-id: 35282e0990189d4084a2a64330a5733561cf88c2
2019-11-07 17:26:09 -08:00
Zeyi (Rice) Fan
a625522cb4 rename hg:use-datapack so old code doesn't get enabled
Summary:
Background: https://fb.workplace.com/groups/sourcecontrolteam/permalink/2440123159442349/?comment_id=2443624539092211

This may or may not be the root cause but this is definitely gonna be causing issues.

Between D17468473 and D17866320, turning on this option will make EdenFS to use the old Rust code that does not strip copyrev data.

Reviewed By: wez

Differential Revision: D18250237

fbshipit-source-id: b3816bd08b8dc3b2a90931829c368a58731c7843
2019-10-31 16:34:19 -07:00
Chad Austin
cfaea9c9d0 warn on unused exception parameter
Summary:
The Windows build spews a great many warnings. Address some of them by
enabling the unused-exception-parameter warning on Clang/Linux too.

Reviewed By: yfeldblum

Differential Revision: D18178930

fbshipit-source-id: efecb605b84d4f06c8c8411a23d17904bbdff746
2019-10-28 17:49:23 -07:00
Chad Austin
ca37294995 introduce a StructuredLogger
Summary:
Introduce a framework that allows recording structured log events
which are encoded as JSON and piped to a configured command line
program.

Reviewed By: pkaush

Differential Revision: D18025183

fbshipit-source-id: ab6b4d510a905a30252f2cff85d107a0d32d149e
2019-10-25 19:29:01 -07:00
Chad Austin
714e96f8aa config refactoring
Summary: While reading the config code, I made some minor, behavior-changing improvements.

Reviewed By: genevievehelsel

Differential Revision: D17918029

fbshipit-source-id: e40bce099a9555559c028c701f6fb75a6a4fc6be
2019-10-14 19:18:04 -07:00
Chad Austin
daaa423489 add knob to opt out of custom thrift permission checking
Summary:
Add a configuration knob that allows environments to opt out of Eden's
custom permission checks on the unix domain socket, instead using the
standard unix domain socket permission rules for the host OS.

Reviewed By: wez

Differential Revision: D17863456

fbshipit-source-id: c60c52891e49cc8027832bd42029cfd52752547b
2019-10-11 17:55:19 -07:00
Chad Austin
4b47257165 remove EdenConfig accessors
Summary:
Instead of having accessors for every config setting in EdenConfig,
just expose the ConfigSettings directly.

Reviewed By: fanzeyi

Differential Revision: D17847805

fbshipit-source-id: 8c6c1010c010113cf859677449797ea916f2a2a5
2019-10-11 17:55:19 -07:00
Chad Austin
8cac2bfe6a Remove dead includes in eden
Reviewed By: wez

Differential Revision: D17877514

fbshipit-source-id: e7f8ed8364bdb7a77f293cbdf4b48e8f15e64c30
2019-10-11 16:45:01 -07:00
Chad Austin
a461b694ef refactor EdenConfig to use private inheritance
Summary:
I plan to simplify access to EdenConfig by making ConfigSettings
public rather than writing accessors for each setting. To avoid
exposing implementation details, switch to private inheritance.

Reviewed By: wez

Differential Revision: D17847752

fbshipit-source-id: 02ef7afe96f09cc29a54b21bfafbef9234e6f74d
2019-10-11 11:01:49 -07:00
Chad Austin
b0765887fc optimize and simplify ReloadableConfig
Summary:
I found the logic for whether the config should be reloaded
unnecessarily complicated, so reduce it to deciding whether to reload
or not. This removes the need to acquire a write lock in autoreload's
common case.

Reviewed By: wez

Differential Revision: D17847699

fbshipit-source-id: 50fee1aac15cc8f896333c93459fea6510646600
2019-10-11 10:42:36 -07:00
Andres Suarez
fbdb46f5cb Tidy up license headers
Reviewed By: chadaustin

Differential Revision: D17872966

fbshipit-source-id: cd60a364a2146f0dadbeca693b1d4a5d7c97ff63
2019-10-11 05:28:23 -07:00
Zeyi (Rice) Fan
56525d88b6 add hg:use-datapack config option to gate datapack related behaivor
Summary: This allows us to test the datapack code easier without rebuilding Eden.

Reviewed By: wez

Differential Revision: D17468473

fbshipit-source-id: a6807b4d6e747ae8557ae51fdf798de2a54fd4f1
2019-10-02 12:58:29 -07:00