Commit Graph

1474 Commits

Author SHA1 Message Date
Adam Simpkins
f497a29d04 stop calling hg debugedenimporthelper with an extra repo argument
Summary:
This argument is unnecessary since D14222323, which should be deployed
everywhere by now.  Passing in the extra repo argument forces hg to open the
repository object twice, which is unnecessary.

We already set the current working directory to the repository when invoking
the import helper, so hg will find the repository correctly from that.

Reviewed By: pkaush

Differential Revision: D15179667

fbshipit-source-id: 838cbee91748c41c713731187608a9823b971a53
2019-05-02 20:42:35 -07:00
Adam Simpkins
f0b14c5139 use hg debugedenimporthelper by default
Summary:
Update HgImporter to use `hg debugedenimporthelper` instead of the separate
`hg_import_helper.py` script by default on all platforms now.  The
`debugedenimporthelper` subcommand has existed in our deployed versions of hg
for a while now.

Reviewed By: pkaush

Differential Revision: D15179668

fbshipit-source-id: 2fb8c4c9f92aed54c84899d6643f746baac73327
2019-05-02 20:42:35 -07:00
Zeyi (Rice) Fan
9d3a6a13ee improve thrift mononoke backing store implementation
Summary:
This diff tries to improve the Thrift Mononoke backing store implementation by:

* Re-creating thrift client for every request since thrift has builtin connection pooling
* Using Eden's CPU thread pool for processing data fetched from remote
* Calling thrift methods within correct executor

Reviewed By: wez

Differential Revision: D15170818

fbshipit-source-id: c8be70755a851f63fb62e4d4f36833703283565e
2019-05-02 18:21:49 -07:00
Chad Austin
2267e75bda require treemanifest support
Summary: We intend to break support for flatmanifest hg, so require that treemanifest is available in the build.

Reviewed By: wez

Differential Revision: D15057150

fbshipit-source-id: 449399cfb9d018f3b722598091eead1bd5d7c77d
2019-05-02 12:35:21 -07:00
Chad Austin
8ec4c11d3e remove flatmanifest fallback when importing trees fails
Summary: Flatmanifest is on its way out. Remove support for falling back to it if a tree import fails.

Reviewed By: pkaush

Differential Revision: D15056459

fbshipit-source-id: a4df820322ee354d77f50a0ec92e9705d0f152ec
2019-05-02 12:35:20 -07:00
Wez Furlong
7a35cb49da eden: on macos LOCAL_PEERCRED has SOL_LOCAL level
Summary:
Interestingly, the request doesn't fail, but does leave
our stack garbage intact.   Let's be sure to zero it out to make
it more obvious what is happening.

While we're in here, let's make sure that we get the same
results from both ends of the socket pair.

Reviewed By: simpkins

Differential Revision: D14994593

fbshipit-source-id: 9aec957dfcd80d88c3d8fbce6bf45480502ea812
2019-05-01 20:09:44 -07:00
Wez Furlong
0077748a32 eden: move test implementation to .cpp file to avoid ODR violation
Summary: this fixes linking the tests when building with cmake in D14993344

Reviewed By: chadaustin

Differential Revision: D15167223

fbshipit-source-id: 1dda3beed3b6ff3788f3992783c58b4b92f697f2
2019-05-01 16:10:23 -07:00
Wez Furlong
ea27d85e64 eden: fix cmake build for store library
Summary:
D15043209 missed fixing up the name of the variable
containing the list of sources.

The result is that we compile the `main` from `eden_store_util`
in to the tests and break gtest discovery in D14993344

Reviewed By: chadaustin

Differential Revision: D15167219

fbshipit-source-id: 95e9dc8ba74965f41bfebed1c1776605d8c9443a
2019-05-01 16:10:23 -07:00
Wez Furlong
01d5402485 eden: fixup sendmsg() macos portability problem in tests
Summary:
UnixSocketTest would block forever on macos if the message
size was larger than approx 1kb.  It turns out that MSG_DONTWAIT
isn't documented in the `sendmsg` man pages and apparently has
no effect at all.  Instead, the socket must be placed in non-blocking
mode.  This appears to be the case for the client side of the sockets
but I need to follow up for the server side.

Reviewed By: simpkins, strager

Differential Revision: D14994588

fbshipit-source-id: 2a0a1c26a7b45ece82f8f79c15fb7756844bc86f
2019-05-01 09:22:58 -07:00
Wez Furlong
5f656eefd0 eden: canonicalize makeTempDir results for macOS
Summary:
on macOS `/var/tmp` is a symlink to `/private/var/tmp`
which means that our tests for path canonicalization end up
trying to compare the non-canonical `/var/tmp` prefix of the
temporary paths generated by the tests with `/private/var/tmp`
and failing.

Reviewed By: simpkins

Differential Revision: D14994584

fbshipit-source-id: e69addca8e315855d3ca87feb576ca7c54567c31
2019-05-01 09:22:57 -07:00
Matt Glazar
a50418112f Optimize TLS lookup in HgImporter
Summary:
D14677339 added tracing to all HgImporter requests. Each trace loads a thread-local variable through EdenStats::getStatsForCurrentThread(). Each of these loads has a small but non-trivial cost.

Because each instance of HgImporter is used only on one thread, each getStatsForCurrentThread() call returns the same EdenThreadStats object. Avoid the thread-local-variable lookups by caching the result of getStatsForCurrentThread() in HgImporter.

This diff should not change behavior.

Reviewed By: simpkins

Differential Revision: D14794284

fbshipit-source-id: d1609a1720d44c680dc0ebaa2536779def2a6f37
2019-04-29 19:21:48 -07:00
Matt Glazar
bc6e11b9dc Fix glob with overlapping patterns
Summary:
If EdenFS' globFiles API is given two patterns, and one pattern is a prefix of the other, EdenFS effectively ignores the longer pattern. Given the patterns `project/src/*` and `project/src/*/*`, when EdenFS encounters `project/src/dir/`, it generates a result (because `project/src/dir/` matches the first pattern) but does not recurse into its children.

The problem caused by an incorrect understanding of the GlobNode::isLeaf_ flag. isLeaf_ means "this GlobNode should generate results", but GlobNode::evaluateImpl understands it to mean "this GlobNode should generate results, and this GlobNode has no children". Given the patterns `project/src/*` and `project/src/*/*`, the GlobNode representing `project/src/*` has isLeaf_=true but also has children.

Fix the bug by not using isLeaf_ for determining whether to recurse, and instead relying on the presence of child GlobNode-s.

Reviewed By: chadaustin

Differential Revision: D15078089

fbshipit-source-id: 1c480d11361f89193b35965266e6873c57181113
2019-04-26 14:26:32 -07:00
Matt Glazar
74d6086e58 Ensure glob does not load trees unnecessarily
Summary:
If globbing returns a directory, that directory doesn't need to be loaded. GlobNode::evaluateImpl is careful to only load directories/trees if necessary. When fixing a bug in GlobNode::evaluateImpl, I accidentally broke this optimization. No test failed, though.

Ensure this optimization works and doesn't regress by writing a simple test.

This diff should not change behavior.

Reviewed By: chadaustin

Differential Revision: D15090386

fbshipit-source-id: fe932e4a7ad517ff4c4523d58668f05fe8b0cafb
2019-04-26 14:26:32 -07:00
Matt Glazar
72a3cbf840 Factor duplicate recursion code in GlobNode
Summary:
In GlobNode::evaluateImpl, the logic for recursing into child GlobNode-s is duplicated token-for-token for hasSpecials_ and !hasSpecials_. While fixing a bug in GlobNode::evaluateImpl, I was forced to update both copies, which is prone to mistakes.

Fix the duplication by factoring the code into a function.

This diff should not change behavior.

Reviewed By: chadaustin

Differential Revision: D15090688

fbshipit-source-id: 65eec62214074139cb8af75026758b631eb89bb2
2019-04-26 14:26:32 -07:00
Matt Glazar
be4594ea21 Add GlobNode::debugDump
Summary:
gdb and lldb have a hard time printing recursive structures involving std::vector and std::unique_ptr. This makes debugging GlobNode a pain.

Add a function to print a GlobNode recursively to stderr. This makes it easier to debug GlobNode using printf.

Reviewed By: simpkins

Differential Revision: D15078111

fbshipit-source-id: 3ba211026c7c894676435ade278ae859e1b5d1f6
2019-04-26 14:26:32 -07:00
Matt Glazar
84fccd7148 Fix code coverage causing test failures
Summary:
Sandcastle's [1] code coverage builds compile EdenFS and Hg with Clang's -fprofile-generate flag (or a related flag). By default, running a program with with that flag creates a `default.profraw` file in the current directory. This causes some tests to fail, such as HgBackingStoreTest.getTreeForCommit_reimports_tree_if_it_was_deleted_after_import, because `default.profraw` is unintentionally committed to the test repo:

```
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from HgBackingStoreTest
[ RUN      ] HgBackingStoreTest.getTreeForCommit_reimports_tree_if_it_was_deleted_after_import
eden/fs/store/hg/test/HgBackingStoreTest.cpp:64: Failure
Value of: tree1->getEntryNames()
Expected: has 2 elements where
element #0 is equal to foo,
element #1 is equal to src
  Actual: { default.profraw, foo, src }, which has 3 elements
[  FAILED  ] HgBackingStoreTest.getTreeForCommit_reimports_tree_if_it_was_deleted_after_import (1563 ms)
[----------] 1 test from HgBackingStoreTest (1563 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (1563 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] HgBackingStoreTest.getTreeForCommit_reimports_tree_if_it_was_deleted_after_import
```

When Sandcastle runs the tests, it sets the `LLVM_PROFILE_FILE` environment variable, which configures the path to `default.profraw`. EdenFS' HgRepo class is stripping this variable when invoking hg, so hg uses the default path and not the configured path.

Make HgRepo pass `LLVM_PROFILE_FILE` through to hg. This fixes some of EdenFS' tests when run by Sandcastle for code coverage purposes. (This does *not* fix running the tests manually (without setting `LLVM_PROFILE_FILE`), though.)

[1] Sandcastle is Facebook's continuous integration system.

Reviewed By: simpkins

Differential Revision: D15104832

fbshipit-source-id: 3929b9b0ab0904f2552ace7d8e4e4f4a4221192c
2019-04-26 14:11:36 -07:00
Victor Zverovich
1a562484b1 Migrate to optional_field_ref Thrift API
Summary:
Migrate the code from accessing optional Thrift fields directly to a safer
`optional_field_ref` API. See https://fburl.com/safe for more details.

The output of this codemod has been reviewed in D13259011.

To preserve semantics, each unchecked access is replaced with an explicit call
to `value_unchecked()`. If you are sure that accessing a field is safe (the
field is marked as set), you can later replace `value_unchecked()` with
`value()` or dereferencing (`operator *`):

```
  ThriftStruct s = ...
- auto foo = s.foo_ref().value_unchecked();
+ auto foo = *s.foo_ref(); // will throw if s.foo is unset
```

Reviewed By: fanzeyi

Differential Revision: D15078040

fbshipit-source-id: 8ef270e8c687535e9d4aa2208beff4517e121814
2019-04-25 09:24:22 -07:00
Adam Simpkins
4e756e7a08 add a "repair" subcommand to eden_store_util
Summary:
Add a command to force a call to RepairDB() on the local store.

This is similar to using `ldb repair`, but invokes `RepairDB()` with the same
set of column family options as normally used by edenfs.

Reviewed By: chadaustin

Differential Revision: D15043210

fbshipit-source-id: 2c4c0e2d3410a50cb1e523611f569f1701604ae6
2019-04-24 20:03:57 -07:00
Adam Simpkins
d128becee7 add a few additional operations to eden_store_util
Summary:
Change eden_store_util to take a subcommand argument, and define 3 separate
subcommands: "gc", "clear", and "compact"

The "gc" was the old default behavior.  The "clear" and "compact" subcommands
simply clear cached entries and compact the storage, respectively.
This also adds a `--keySpace` argument.  If this argument is specified the
command will process only this single key space, instead of all key spaces.

Reviewed By: chadaustin

Differential Revision: D15043207

fbshipit-source-id: 7e76bc89862d9647edde631ed3d82c9afda09f41
2019-04-24 20:03:57 -07:00
Adam Simpkins
2faa637da5 move some logic from RocksHandles to RocksDbLocalStore
Summary:
This moves some logic from the RocksHandles class up to RocksDbLocalStore.
The main thing moved here is the logic to automatically try and repair the DB
if opening fails.  This will make it easier in a subsequent diff to make the
repair logic a bit smarter and more aware of our column family semantics.

This keeps RocksHandles a pretty dumb wrapper around the RocksDB object and
column family handles, whose only purpose is to manage destroying these two
things in the correct order.

Reviewed By: chadaustin

Differential Revision: D15043208

fbshipit-source-id: ee2d5619ac7781a892e1ba151712eee9e3ebfb14
2019-04-24 20:03:57 -07:00
Adam Simpkins
256422737d rename eden_gc to eden_store_util
Summary:
Move this utility from eden/fs/service to eden/fs/store, and rename it to
`eden_store_util`.

I originally put it in the `service` subdirectory since it depends on library
code from `service/`, and most of the other code in `store/` shouldn't depend
on code in `service/`.  However logically it makes sense to be in the `store/`
directory.

I plan to update in the future to be able to perform some additionally utility
operations besides just garbage collection, so rename it to the more generic
`eden_store_util` name.

Reviewed By: chadaustin

Differential Revision: D15043209

fbshipit-source-id: e6c4a874ddd05bd1576ea2e8a6c6156ccdf4628f
2019-04-24 20:03:57 -07:00
Chad Austin
c12e7284e9 stat time portability for tests
Summary:
On macOS, the atime, mtime, and ctime fields are named st_atimespec,
etc. Add some portability functions so the inode tests compile on
macOS.

Reviewed By: simpkins

Differential Revision: D15048758

fbshipit-source-id: 6f85b8eb7f7da2f9bd21c9034296cde96b68f740
2019-04-24 14:15:08 -07:00
Chad Austin
bd0816b608 add missing includes required on mac
Summary: Add some includes that are required on macOS.

Reviewed By: simpkins

Differential Revision: D15048681

fbshipit-source-id: d8642dc0977dc8cd8aadc83fc750400a8f917b7a
2019-04-23 13:42:31 -07:00
Zeyi Fan
02dcf44bd0 add curl verbose logging
Summary: Logging curl verbose messages to DBG9 for debugging purposes.

Reviewed By: simpkins

Differential Revision: D15038271

fbshipit-source-id: 578bdd3eba4bc89a056c8f3441f4efee0a1a6721
2019-04-22 18:47:29 -07:00
Adam Simpkins
a366d63a72 add a standalone eden_gc utility
Summary:
Add a standalone program that can be used to garbage collect the local store
data when edenfs is not currently running.

Reviewed By: wez

Differential Revision: D14910392

fbshipit-source-id: 1cf8f959e5967cfbb797752653cc72223c87134f
2019-04-22 12:45:07 -07:00
Chad Austin
149b3879e2 build several targets on mac and run 5 test suites
Summary:
Let's catch more Xcode and upstream regressions by enabling more
builds and tests on macOS.

Reviewed By: simpkins

Differential Revision: D15003839

fbshipit-source-id: 257086d578f28198c7718906e1ec06395a55896e
2019-04-18 19:36:20 -07:00
Chad Austin
ca7bc2f0f7 split rocksdb store tests into a separate target
Summary:
Build the store tests on mode/mac. RocksDB doesn't build yet (and we
will likely move away from it anyway) so split it into its own target.

Reviewed By: simpkins

Differential Revision: D15002840

fbshipit-source-id: fa0fea1d52df06526032a6fd585e2da7273910ef
2019-04-18 19:36:19 -07:00
Chad Austin
ca3c6cc3a7 build testharness on mac
Summary:
The hg store implementation depends on Rust code that doesn't build on
mode/mac yet, but TestMount's dependency on hg was false anyway.

Reviewed By: simpkins

Differential Revision: D15001077

fbshipit-source-id: 840fdf565093ad7a6eb95e001a74ae95eecbf1db
2019-04-18 19:36:19 -07:00
Wez Furlong
1480c1d043 eden: apple/clang compiler portability fixes
Summary: These allow more tests to compile

Reviewed By: chadaustin

Differential Revision: D14994582

fbshipit-source-id: 6b2a0b276fda64c7f27e28ea9e6d548aaaa1db7c
2019-04-18 10:37:57 -07:00
Wez Furlong
22fb6614e9 eden: speculative fix for accidental copy
Summary:
Seeing this on one of our linux CI hosts:

```
FAILED: eden/fs/store/hg/CMakeFiles/eden_store_hg.dir/HgBackingStore.cpp.o
/usr/bin/c++  -DFOLLY_XLOG_STRIP_PREFIXES=\"/var/sandcastle/temp/fbcode_builder_getdeps/shipit/eden:/var/sandcastle/temp/fbcode_builder_getdeps/build/eden-13470f\" -DGFLAGS_IS_A_DLL=0 -DGOOGLE_GLOG_DLL_DECL="" -DGOOGLE_GLOG_DLL_DECL_FOR_UNITTESTS="" -I. -I/var/sandcastle/temp/fbcode_builder_getdeps/shipit/eden -I/var/sandcastle/temp/fbcode_builder_getdeps/installed/googletest-520b8c/include -I/var/sandcastle/temp/fbcode_builder_getdeps/installed/libgit2-c32720/include -I/var/sandcastle/temp/fbcode_builder_getdeps/installed/fb-mercurial-53e1c8 -I/var/sandcastle/temp/fbcode_builder_getdeps/installed/sqlite3-998248/include -I/var/sandcastle/temp/fbcode_builder_getdeps/installed/lz4-9c269f/include -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/gflags-425c30/include -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/folly-074709/include -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/fizz-680c3e/include -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/wangle-7a56ae/include -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/thrift-3c4bca/include -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/boost-864c2c/include -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/double-conversion-3e811f/include -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/glog-81244a/include -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/libevent-ff5d17/include -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/zstd-f1c315/include -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/snappy-d394bb/include -isystem /usr/include/libdwarf -isystem /usr/include/libiberty -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/libsodium-9066a8/include -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/rsocket-cpp-e998e5/include -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/rocksdb-88d1cb/include -O2 -g -DNDEBUG   -pthread -std=gnu++1z -MD -MT eden/fs/store/hg/CMakeFiles/eden_store_hg.dir/HgBackingStore.cpp.o -MF eden/fs/store/hg/CMakeFiles/eden_store_hg.dir/HgBackingStore.cpp.o.d -o eden/fs/store/hg/CMakeFiles/eden_store_hg.dir/HgBackingStore.cpp.o -c /var/sandcastle/temp/fbcode_builder_getdeps/shipit/eden/eden/fs/store/hg/HgBackingStore.cpp
In file included from /var/sandcastle/temp/fbcode_builder_getdeps/installed/folly-074709/include/folly/futures/Future.h:28:0,
                 from /var/sandcastle/temp/fbcode_builder_getdeps/shipit/eden/eden/fs/store/BackingStore.h:12,
                 from /var/sandcastle/temp/fbcode_builder_getdeps/shipit/eden/eden/fs/store/hg/HgBackingStore.h:14,
                 from /var/sandcastle/temp/fbcode_builder_getdeps/shipit/eden/eden/fs/store/hg/HgBackingStore.cpp:10:
/var/sandcastle/temp/fbcode_builder_getdeps/installed/folly-074709/include/folly/Try.h: In instantiation of ‘folly::Try<T>::Try(const T&) [with T = std::unique_ptr<facebook::eden::Tree>]’:
/var/sandcastle/temp/fbcode_builder_getdeps/installed/folly-074709/include/folly/futures/Future-inl.h:148:24:   required from ‘folly::futures::detail::FutureBase<T>::FutureBase(T2&&) [with T2 = std::unique_ptr<facebook::eden::Tree>&; <template-parameter-2-2> = void; T = std::unique_ptr<facebook::eden::Tree>]’
/var/sandcastle/temp/fbcode_builder_getdeps/installed/folly-074709/include/folly/futures/Future.h:958:63:   required from ‘folly::Future<T>::Future(T2&&) [with T2 = std::unique_ptr<facebook::eden::Tree>&; <template-parameter-2-2> = void; T = std::unique_ptr<facebook::eden::Tree>]’
/var/sandcastle/temp/fbcode_builder_getdeps/shipit/eden/eden/fs/store/hg/HgBackingStore.cpp:526:12:   required from here
/var/sandcastle/temp/fbcode_builder_getdeps/installed/folly-074709/include/folly/Try.h:80:45: error: use of deleted function ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = facebook::eden::Tree; _Dp = std::default_delete<facebook::eden::Tree>]’
       : contains_(Contains::VALUE), value_(v) {}
                                             ^
In file included from /usr/include/c++/7/memory:80:0,
                 from /var/sandcastle/temp/fbcode_builder_getdeps/installed/folly-074709/include/folly/dynamic.h:56,
                 from /var/sandcastle/temp/fbcode_builder_getdeps/shipit/eden/eden/fs/config/EdenConfig.h:12,
                 from /var/sandcastle/temp/fbcode_builder_getdeps/shipit/eden/eden/fs/store/hg/HgBackingStore.h:12,
                 from /var/sandcastle/temp/fbcode_builder_getdeps/shipit/eden/eden/fs/store/hg/HgBackingStore.cpp:10:
/usr/include/c++/7/bits/unique_ptr.h:388:7: note: declared here
       unique_ptr(const unique_ptr&) = delete;
       ^~~~~~~~~~
```

Reviewed By: fanzeyi

Differential Revision: D14987986

fbshipit-source-id: cbfe83619591d385cf9acb385254bb028aec1b4c
2019-04-17 21:03:54 -07:00
Zeyi Fan
a8c149437a add stats collecting for hg & mononoke backing store
Summary: This diff add four metrics to the stats we are collecting in Eden. Both time cost on calling `get_tree` and `get_blob` from hg and mononoke backing store.

Reviewed By: chadaustin

Differential Revision: D14780349

fbshipit-source-id: f0e902c7f7523fac2ae576a67f0c85555064e26c
2019-04-17 13:10:21 -07:00
Wez Furlong
b5b76236e0 eden: adjust volume name on macos
Summary:
The Finder shows the volume name instead of the directory
name when it renders the directory containing a mount, and the default
name of `OSXFuse Volume X` makes it hard to distinguish between multiple
mounts in the same folder.

This changes the volume name to be the basename of the mounted path so
that the finder renders things more reasonably.

Reviewed By: chadaustin

Differential Revision: D14969807

fbshipit-source-id: de9d8469360712828598fed124ed02ee5d6dd44a
2019-04-17 12:54:51 -07:00
Wez Furlong
0f2d07002a eden: allow apple double
Summary:
Unfortunately, some node modules packages include `.DS_Store` files
and since we disable apple double, the kext refuses to allow them to be
unpacked in the repo.  Ideally they wouldn't be in the repo, but we need to
unblock that workflow.

Reviewed By: chadaustin

Differential Revision: D14969808

fbshipit-source-id: f9262294a223fd5cc7929a2b324f2401e1fed083
2019-04-17 12:54:51 -07:00
Lee Howes
9c5c50a389 Replace Future::onError with Future::thenError
Summary:
Replace Future::onError with Future::thenError:
 * to remove ambiguous typing
 * to ensure that the executor is not lost and the returned Future is still bound to an executor

See:
https://fb.workplace.com/groups/fbcode/permalink/2002251863144976/
for details.

Reviewed By: Orvid

Differential Revision: D14975808

fbshipit-source-id: b7790bf0e8965c9ffb3e63901bcdaf108480d4ca
2019-04-17 11:59:13 -07:00
Adam Simpkins
81260b6085 add a removeRecursively() helper function
Summary:
Add a helper function to recursively remove a directory from the local
filesystem, given an `AbsolutePath`.

Reviewed By: wez

Differential Revision: D14954737

fbshipit-source-id: a3f6b60e610c18eabea2a7c507661a43502a2554
2019-04-16 22:10:05 -07:00
Adam Simpkins
982f1da1d8 add a new EdenStateDir class
Summary:
Add a new class to manage access to the .eden state directory, and move some
logic for managing this director from the `EdenServer` class and into this new
class.

This is largely just a first step.  In the future I think we should move
additional functionality into this class.  For instance, logic to determine
the correct local store type and logic to load the checkout map from
config.json.  In the future it probably also make sense to move this class
from the `service` library into a slightly lower-level library (perhaps
`config` or `store`).

Reviewed By: chadaustin

Differential Revision: D14889617

fbshipit-source-id: 15cb7daa9b97500124152d016bfdd686d3039771
2019-04-16 21:17:10 -07:00
Adam Simpkins
336d41616f refactor some of the argument parsing and config setup logic
Summary:
Move some of the argument parsing and config setup code out into a new
EdenInit.h header file.  This makes it possible to re-use this logic for other
standalone utilities that want to be able to find the Eden state directory and
config information.

For now I have updated the `fake_edenfs` helper tool used by the integration
tests to use this.  This may also be useful for writing standalone tools that
can perform garbage collection of the LocalStore or checking of the overlay
state.

Reviewed By: chadaustin

Differential Revision: D14889616

fbshipit-source-id: b0b193a42cb2f52177d0c44592426b42e27242aa
2019-04-16 21:17:10 -07:00
Adam Simpkins
e6475d7693 remove the code that flushes all RocksDB columns on startup
Summary:
This effectively reverts D14452214, which caused Eden to write an `id` entry
to each RocksDB column family and then flush the column family each time
edenfs started.

There was relatively little benefit to this in practice.  It only matters in
cases where the RocksDB column families never had enough data written to them
to get flushed automatically and then a repair is required.

On the other hand it does have some material downsides: it flushing the column
families can be fairly expensive, and can require a substantial amount of free
disk space.  This flush caused some users to not be able to start up edenfs
when they did not have enough free disk space.

Reviewed By: chadaustin

Differential Revision: D14947235

fbshipit-source-id: a29f98163fa87185b028bb47945b6fab75700fd6
2019-04-16 11:01:25 -07:00
Chad Austin
eb8b6db58b remove unnecessary include
Summary: Fallout from another diff that never got landed.

Reviewed By: simpkins

Differential Revision: D14938191

fbshipit-source-id: 980728ca6a1d4c4f90fea46aac9525a03d9809e5
2019-04-15 13:47:56 -07:00
Adam Simpkins
07902b6a3c improve the "gc" implementation for RocksDB
Summary:
Change the `eden gc` implementation to use RocksDB's `DeleteFilesInRange()`
function, as well as its new-ish `DeleteRange()` method.

This makes the garbage collection much faster, and also require much less free
disk space than previously.

`DeleteFilesInRange()` asks RocksDB to simply delete all SST files from disk
if they only contain keys in the specified range.  Since the range we specify
should include all keys in the DB this should simply drop all SST files for
this column family.

We also call `DeleteRange()` after this, just in case.  This API is relatively
recent, and writes a single tombstone saying that the specified range has been
deleted.

Reviewed By: wez

Differential Revision: D14910345

fbshipit-source-id: c76bdc1c8e07cb2def66673ea892e7f455c9dc7a
2019-04-15 12:33:09 -07:00
Matt Glazar
1057039562 Encapsulate EdenStats
Summary:
EdenStats is currently an alias for ThreadLocal<EdenThreadStats>. I want to split EdenThreadStats into two structs which are allocated independently, but EdenStats's interface makes this impossible.

Refactor EdenStats from an alias to a class and encapsulate the underlying ThreadLocal<EdenThreadStats> member.

This diff should not change behavior.

Reviewed By: simpkins

Differential Revision: D14822272

fbshipit-source-id: 691f4731aa22ecbdcd3535ee0bb0b99c816ffc3d
2019-04-14 20:45:16 -07:00
Matt Glazar
11195c2b0b Rename ThreadLocalEdenStats to EdenStats
Summary:
I'm confused by the naming of EdenThreadStats and ThreadLocalEdenStats. For example, when I see "ThreadLocalEdenStats", I think that such objects can only be accessed by one thread. That's definitely not what "ThreadLocalEdenStats" means!

I think the following naming scheme makes more sense:

* **EdenThreadStats**: Statistics which are updated by one thread. Currently called EdenThreadStats.
* **EdenStats**: Statistics for all threads. Provides access to EdenThreadStats. Currently called ThreadLocalEdenStats.

Implement my preferred scheme: rename ThreadLocalEdenStats to EdenStats.

This diff should not change behavior.

Note: Prior to D14822274, EdenThreadStats was called EdenStats.

Reviewed By: simpkins

Differential Revision: D14822271

fbshipit-source-id: bd20179b1010588e3fc16dc9ed0657d458606f16
2019-04-14 20:45:16 -07:00
Matt Glazar
8bfb4fe9cb Rename EdenStats to EdenThreadStats
Summary:
I'm confused by the naming of EdenStats and ThreadLocalEdenStats. For example, when I see "ThreadLocalEdenStats", I think that such objects can only be accessed by one thread. That's definitely not what "ThreadLocalEdenStats" means!

I think the following naming scheme makes more sense:

* **EdenThreadStats**: Statistics which are updated by one thread. Currently called EdenStats.
* **EdenStats**: Statistics for all threads. Provides access to EdenThreadStats. Currently called ThreadLocalEdenStats.

Implement half of my preferred scheme: rename EdenStats to EdenThreadStats. (Make this diff easier to read by renaming ThreadLocalEdenStats to EdenStats in a separate diff.) In effect, implement the following naming scheme:

* **EdenThreadStats**: Statistics which are updated by one thread. (was EdenStats)
* **ThreadLocalEdenStats**: Statistics for all threads. Provides access to EdenThreadStats. (no change)

This diff should not change behavior.

Reviewed By: simpkins

Differential Revision: D14822274

fbshipit-source-id: 236cd9878cd249a06d14e124050ee01329667a18
2019-04-14 20:45:16 -07:00
Zeyi Fan
34762da68d use ServiceAddress in curl implementation
Summary: This diff makes `MononokeCurlBackingStore` uses `ServiceAddress` for getting address of Mononoke service.

Reviewed By: chadaustin

Differential Revision: D14864675

fbshipit-source-id: 5c3d5e82a3bd6b55ff722427b3f44d20a3544a1d
2019-04-12 11:22:25 -07:00
Zeyi Fan
700d298136 use ServiceAddress in proxygen implementation
Summary: This diff makes `MononokeHttpBackingStore` uses `ServiceAddress` to manage remote address of the Mononoke API Server.

Reviewed By: chadaustin

Differential Revision: D14855661

fbshipit-source-id: 1c102f7b2c547dc6a5b5c2cba65a513313d90bdc
2019-04-12 11:22:25 -07:00
Zeyi Fan
13da025c6c Add ServiceAddress to utils
Summary: This diff adds `ServiceAddress` to utils. This is a class that encapsulates an address of a service that could be a traditional hostname & port pair as well as an SMC tier name. This eliminates the needs of the manually resolving network address for remote services.

Reviewed By: chadaustin

Differential Revision: D14845257

fbshipit-source-id: 9fe9847cca4bba0170be94b9c209247342708574
2019-04-12 11:22:25 -07:00
Matt Glazar
37a993bf42 Track how many HgImporter requests are made
Summary:
Sometimes, EdenFS goes bonkers and talks to 'hg debugedenimporthelper' a lot for seemingly no reason.

Make these situations easier to debug by counting how many requests EdenFS makes to 'hg debugedenimporthelper'. These counters let us answer questions such as the following:

* When performance sucks, is EdenFS is making a lot of requests or only a few requests? I.e. is Hg slow at responding or is EdenFS very demanding?
* Does a recent performance issue correlate with EdenFS communicating with 'hg debugedenimporthelper'?
* Which engineers are outliers having orders of magnitude more 'hg debugedenimporthelper' requests than p50 engineers?

We could get fancier with these counters and include the number of bytes received, the duration of the request, etc. For now, just having a request count is useful.

Reviewed By: simpkins

Differential Revision: D14677339

fbshipit-source-id: 7f8f394fb0096aef65d6a8a45d7da5936db539a0
2019-04-10 19:58:16 -07:00
Adam Simpkins
cedc6820f7 fix a size_t format specifier to snprintf()
Summary:
D8559702 changed `folly::IOBuf::computeChainDataLength()` to return a `size_t`
Update our format specifier to match to avoid compiler warnings on Mac.

Reviewed By: chadaustin

Differential Revision: D14878220

fbshipit-source-id: 19e96bea07c57bb542a848b3688d65143db51d13
2019-04-10 15:41:35 -07:00
Orvid King
736f47d917 AsyncServerSocket::AcceptCallback::connectionAccepted to NetworkSocket (attempt #2)
Summary:
The file descriptor API here needs to go away, so switch this API to NetworkSocket

It is expected that this commit will cause a number of Open Source projects to temporarily show up as broken. This is due to the fact that not all projects get synced to Github at the exact same time, so the builds may temporarily be fetching an older version of it's dependencies than it needs to :) It should fix itself quickly.

Reviewed By: yfeldblum

Differential Revision: D14673328

fbshipit-source-id: c5842fa5dc383d50043e0d8228e35d03b10a1c6b
2019-04-10 15:01:32 -07:00
Adam Simpkins
544a5939df fix a deadlock in TreeInode::createImpl()
Summary:
Ensure that the `TreeInode::createImpl()` code always releases the contents
lock at the end of the scope that was intended to signify the critical
section.  Previously this was only unlocked when returning from this scope
successfully.

In particular, the old behavior could deadlock:
- We first created the new child inode.
- If saveOverlayDir() failed, we would throw an exception, causing us to not
  release the directory lock yet.
- As we returned in the exception case, the local `inode` variable would be
  destroyed before the `contents` argument, causing us to release the child
  InodePtr's refcount before releasing the parent directory's lock.  Because
  we were the only user of the child inode we would end up needing to acquire
  the parent inode's content's lock to check if it was unlinked.

This fixes the code to ensure that we always release the tree's contents lock
before the child inode becomes unreferenced.

Reviewed By: chadaustin

Differential Revision: D14848807

fbshipit-source-id: 28dcde842072b9ee1e7c63d54456d849e31af8fe
2019-04-10 13:59:25 -07:00