Commit Graph

32 Commits

Author SHA1 Message Date
Wez Furlong
d623be956d pass ReloadableConfig down to HgBackingStore ctor
Summary:
This allows detecting changes to the edenrc configuration
and adjusting how we read data accordingly.

To avoid a huge gnarly diff with a lot of dependencies, this diff
introduces a little interface class that defines the method to obtain
a possibly reloaded EdenConfig instance.

This diff shouldn't change any functionality.

Reviewed By: chadaustin

Differential Revision: D12813051

fbshipit-source-id: 35390dc28671ba46a03d098c4f280e2f567dbdc9
2018-10-31 11:50:38 -07:00
Chad Austin
91b5d00d9a folly::Optional -> std::optional
Summary: Eden's on C++17 so fully cross the rubicon!

Reviewed By: strager

Differential Revision: D10498054

fbshipit-source-id: 18f0c0bd121b6c27f9bb1003ce4ae33bdd03a0c1
2018-10-23 17:05:11 -07:00
Chad Austin
742e1e34b8 add an in-memory LRU for blob metadata
Summary:
Because Mercurial blob IDs change without the contents changing, and
because files get unloaded upon checkout, rebasing across a large
distance in history can result in status fetching a lot of
metadata. Keep a smallish LRU cache for SHA-1 and size by blob ID.

Reviewed By: strager

Differential Revision: D10419965

fbshipit-source-id: 81499573814775471913db05f924767c3bab300e
2018-10-22 20:27:27 -07:00
Dan Schatzberg
3e0170774c Move datapack loads to HgBackingStore
Summary:
There's a lot of logic here that need not be offloaded to the
importer threads

Reviewed By: chadaustin

Differential Revision: D9539811

fbshipit-source-id: 1379eef390df6400291a61263d003b493a474b81
2018-09-25 11:21:51 -07:00
Matt Glazar
aa3beac504 Work around LSAN reports for hg_importer_helper
Summary: LSAN detects leaks for Python's and Hg's code. When running Eden's tests, whenever hg_importer_helper exits, LSAN prints lengthy leak reports. (Eden ignores hg_importer_helper's exit code, so LSAN's reports don't cause tests to fail.) Fix the log spam by disabling LSAN for hg_importer_helper.

Reviewed By: wez

Differential Revision: D9756053

fbshipit-source-id: 457404c46e1c81f52c2ad754ab67fd180d26935c
2018-09-11 11:36:21 -07:00
Adam Simpkins
841b81c934 increase the timeouts in HgPrefetchTest
Summary:
This test seems to fail frequently while waiting on the tree data for the
"src" tree (at line 182).  The code previously was using a 1s timeout for this
operation; this changes it to use a 10s timeout.

I'm not sure what would have changed that makes this take longer now.  It's
possible something changed with the treemanifest code on the mercurial side.
It is somewhat surprising to me that this would regularly take more than 1s
though since this is only computing data locally about a pretty small test
repository.

Reviewed By: wez

Differential Revision: D9583645

fbshipit-source-id: 24695cc1b940540ec32461e2d80c30a3fd87a3e3
2018-08-30 13:07:49 -07:00
Adam Simpkins
083ffc4e48 add tests for HgImporter error handling logic
Summary:
Add a new unit test that exercises HgImporter and HgBackingStore using an
alternate hg_import_helper.py script that can inject errors into the response
data stream.  This tests the behavior of HgImporter when there are
serialization errors with the data, as opposed to legitimately-serialized
error responses containing a python exception message.

Reviewed By: wez

Differential Revision: D9510568

fbshipit-source-id: ae86f69d5559701e9e8a9a18569986d64488eaf4
2018-08-28 12:52:38 -07:00
Adam Simpkins
0aef86d323 update HgImporter::importFileContents() to return a Blob
Summary:
Change HgImporter::importFileContents() to return a Blob object rather than
just the IOBuf.

This shouldn't have any behavior changes.  However, it might help track down
some of the cases where we have seen files get incorrectly imported with empty
contents in some rare cases.  We're not sure what is causing that, but
incorrectly using a moved-from IOBuf object would be one thing that might
produce this behavior.  By changing this code to a `unique_ptr<Blob>` will
will eliminate the possibility of seeing empty buffer contents if some code
path is somehow ever able to use one of these objects after they have been
moved away from.  (The code would end up with a null pointer in this case
rather than an empty buffer.  If this ever does occur in practice a null
pointer would make the problem more obvious than an empty buffer.)

Reviewed By: chadaustin

Differential Revision: D9494651

fbshipit-source-id: 799cc1b1d0e2ac32ae2013dc80c84ec17cc1c491
2018-08-24 15:52:23 -07:00
Chad Austin
5d54a799c9 Rename UnboundedQueueThreadPool to UnboundedQueueExecutor and add a ManualExecutor variant
Summary:
To improve the determinism of our C++ tests, I am planning to switch
TestMount to a ManualExecutor. This adds a ManualExecutor constructor
to UnboundedQueueExecutor.

In Rust, I'd use a trait, but a simple class with two constructors works fine.

Reviewed By: strager

Differential Revision: D8846553

fbshipit-source-id: c52752105255503d26f1e65494c32b3f62882e44
2018-08-03 13:21:59 -07:00
Adam Simpkins
a5f53c6e3a avoid blocking on HgProxyHash::getBatch() in hg importer threads
Summary:
D8065370 changed the HgImporter code to make a blocking `get()` call on a
future from the hg importer thread pool.  This caused deadlocks, since all of
the hg importer threads could become stuck waiting on these `get()` calls to
complete.  These would be waiting on RocksDbLocalStore threads which were in
turn all busy waiting to schedule operations on the HgImporter threads.

This fixes the code to use `Future::then()` rather than `Future::get()` to
avoid blocking the HgImporter threads on these operations.

Reviewed By: wez

Differential Revision: D8438777

fbshipit-source-id: a0d647b10ef5a182be2d19f636c2dbc24eab1b23
2018-06-14 22:02:38 -07:00
Adam Simpkins
8a1da142b1 fix UnicodeEncodeErrors thrown from eden prefetch code
Summary:
The `HgImporter::prefetchFiles()` method was previously sending the file
information to the `hg_import_helper.py` script as JSON.  This caused
problems since the python JSON code decodes the path names as Unicode strings.
These then get passed to the mercurial code that expects binary data.  It
tries encoding the unicode strings to ASCII, which can throw
UnicodeEncodeErrors.

This updates the code to use a simple binary encoding scheme, since we don't
really want to convert these pathnames from binary to unicode and back again.
The file names are not necessarily even guaranteed to be valid unicode data.

Reviewed By: chadaustin

Differential Revision: D8393757

fbshipit-source-id: 3ec4dcf2bea57e5400af94e9139d0636c446c1f0
2018-06-13 19:37:04 -07:00
Adam Simpkins
9b6b94f67d set HGRCPATH to the empty string in C++ tests that invoke hg
Summary:
Update the HgRepo class to set the `HGRCPATH` environment variable to the
empty string to ensure that we always use consistent settings, and are not
affected by the current system's hgrc files.

Reviewed By: chadaustin

Differential Revision: D8410265

fbshipit-source-id: 477a3721860c067f39fbef4bb7d3d14cae3a14b6
2018-06-13 19:37:03 -07:00
Chad Austin
74de9c13a8 recover from a commit2tree entry existing without the corresponding tree
Summary:
When testing D8108649 I accidentally deleted all of my trees
but didn't delete my commit2tree mapping. This diff allows Eden to
recover from that situation.

Reviewed By: wez

Differential Revision: D8108728

fbshipit-source-id: 94a9393294ca259303026c297683dac4b3ecfac4
2018-06-06 14:36:32 -07:00
Chad Austin
a45699a32e remove hg store test main.cpp
Summary:
Preparation for adding an HgBackingStore test.

Per @[1077184107:simpkins], use_hg_tree_manifest defaults on and folly::logging is automatically initialized now, so we can just remove main() entirely.

Reviewed By: wez

Differential Revision: D8226799

fbshipit-source-id: 5b5038bc311f62c1ef9ed943f57ce8f7d68bdc89
2018-06-01 15:48:07 -07:00
Chad Austin
5fa02fa46f make LocalStore::getTree return a Future
Summary:
Remove getTreeFuture and have getTree always return a Future. It's a
little unfortunate that this will always allocate, but it sounds like
we might decide to put all RocksDB access on a background thread to
increase CPU parallelism.

Reviewed By: bolinfest

Differential Revision: D8101430

fbshipit-source-id: e12b7ab07b3468114a58753768655c107265b8af
2018-05-31 21:19:40 -07:00
Chad Austin
cfdb61d3bc make LocalStore::getBlob return a Future
Summary:
Remove getBlobFuture and have getBlob always return a Future. It's a
little unfortunate that this will always allocate, but it sounds like
we might decide to put all RocksDB access on a background thread to
increase CPU parallelism.

Reviewed By: bolinfest

Differential Revision: D8101402

fbshipit-source-id: d6cbbd7fe4fe55bad661c9158297db2f03f7d352
2018-05-31 20:46:11 -07:00
Chad Austin
f4ebdce6c1 make HgImportTest a parameterized test
Reviewed By: wez

Differential Revision: D8216298

fbshipit-source-id: 4e68f4820db4311c402c59906cfff3d3744eab9d
2018-05-31 11:23:21 -07:00
Adam Simpkins
684fa29593 update folly::Init to call folly::initLogging()
Summary:
Update the folly::Init code to define a `--logging` command line flag, and call
`folly::initLoggingOrDie()` with the value of this command line during
initialization.

This is similar to the existing code that initializes the glog library.
(Programs can use both glog and folly logging together in the same program, and
I expect that many programs will do so as parts get converted to folly::logging
and parts remain using glog.)

Reviewed By: yfeldblum

Differential Revision: D7827344

fbshipit-source-id: 8aa239fbad43bc0b551cbe40cad7b92fa97fcdde
2018-05-15 12:38:01 -07:00
Chad Austin
72be488e3d add convenient operator literals for the various path piece types
Summary:
I got tired of typing PathComponentPiece{"..."} in tests so here are
some operator literals.

Reviewed By: simpkins

Differential Revision: D7956732

fbshipit-source-id: 85d9f3fd725853a54da9e70fc659bd7eb9e0862c
2018-05-11 14:52:07 -07:00
Adam Simpkins
8e3c09a99a move folly/experimental/logging to folly/logging/
Summary:
Promote the folly logging code out of the experimental subdirectory.
We have been using this for several months in a few projects and are pretty
happy with it so far.

After moving it out of the experimental/ subdirectory I plan to update
folly::Init() to automatically support configuring it via a `--logging` command
line flag (similar to the initialization it already does today for glog).

Reviewed By: yfeldblum, chadaustin

Differential Revision: D7755455

fbshipit-source-id: 052db34c97f7516728f7cbb1a5ad959def2f6efb
2018-04-30 21:29:29 -07:00
Adam Simpkins
21d2b6c46d Remove TARGETS files
Summary:
This removes the TARGETS files from the eden github repository.  The
open source buck build has been failing for several months, since buck
removed support for the thrift_library() rule.

I will potentially take a stab at adding CMake build support for Eden
at some point in the future.

Reviewed By: chadaustin

Differential Revision: D6893233

fbshipit-source-id: e6023094a807cf481ac49998c6f21b213be6c288
2018-02-20 19:57:45 -08:00
Chad Austin
622a5ecbc2 rename FileType to TreeEntryType
Summary:
This is the type of a tree entry, which may be another tree, so
FileType is not an accurate name.

Reviewed By: simpkins

Differential Revision: D6981168

fbshipit-source-id: 997eb8a27f599310ed678ce221c8083722db8bff
2018-02-16 15:57:39 -08:00
Chad Austin
895a0196d9 compute permission bits based on FileType in TreeEntry
Summary:
Our Model TreeEntry code was a bit too general - in reality, both git
and hg only support a handful of specific tree entries: regular files,
executable files, symlinks, and trees.  (git also supports
submodules.)  This diff delays the expansion of a TreeEntry's type
into a full mode_t.

Reviewed By: simpkins

Differential Revision: D6980003

fbshipit-source-id: 73729208000668078a180b728d7e0bb9169c6f3c
2018-02-15 14:46:33 -08:00
Wez Furlong
a0fb6d9d05 split RocksDbLocalStore out from LocalStore
Summary:
This enables dropping in alternative implementations
of LocalStore and adds a MemoryLocalStore implementation for
use in our tests.

This diff doesn't change the default storage option for the
eden server.  I'll look at adding such an option in a follow up diff.

Reviewed By: chadaustin

Differential Revision: D6910413

fbshipit-source-id: 018bf04e0bff101e1f0ab35e8580ca2a2622e5ef
2018-02-07 11:54:16 -08:00
Philip Jameson
8604b8f5b0 Migrate TARGETS files from @/ to //
Summary:
This is a codemod to change from using @/ to // in basic cases.
- TARGETS files with lines starting with @/ (but excluding @/third-party:
- autodeps lines in source and TARGETS files ( (dep|manual)=@/ ), excluding @/third-party
- Targets in string macros

The only thing left of the old format should be @/third-party:foo:bar

drop-conflicts

Reviewed By: ttsugriy

Differential Revision: D6605465

fbshipit-source-id: ae50de2e1edb3f97c0b839d4021f38d77b7ab64c
2017-12-20 16:57:41 -08:00
Adam Simpkins
1b86627d43 logging: update initialization code to use the new LogConfig logic
Summary:
Replace the initLoggingGlogStyle() function with a more generic initLogging()
function that accepts a log config string to be parsed with parseLogConfig().

Reviewed By: bolinfest, yfeldblum

Differential Revision: D6342086

fbshipit-source-id: fb1bffd11f190b70e03e2ccbf2b30be08d655242
2017-12-01 17:07:56 -08:00
Adam Simpkins
8352b88299 include the exception type name in hg_import_helper.py errors
Summary:
Update hg_import_helper.py to include the exception type name in error
responses.  Add a new HgImportPyError class in the C++ code to include both the
python exception type name and the message string.

In the future this will give us the ability to perform special handling based
on the python exception type, rather than just on the message contents.

Reviewed By: bolinfest

Differential Revision: D6333613

fbshipit-source-id: 1074bbf9fa25ee8b1abeadc38b1a4f569bc18d13
2017-11-15 13:31:58 -08:00
Adam Simpkins
c8c1ba5eab remove eden/fs/utils/test/TestChecks.h
Summary:
The gtest macros in this file were moved to folly/test/TestUtils.h
Update everything to just use folly/test/TestUtils.h directly.

Reviewed By: chadaustin

Differential Revision: D6301759

fbshipit-source-id: 7f2841c12d5bea15376f782fb3bf3bfef16039c7
2017-11-15 12:53:55 -08:00
Chad Austin
8b9261f2a1 run clang-format across all C++ files
Summary:
Per discussion with bolinfest, this brings Eden in line with clang-format.

This diff was generated with `find . \( -iname '*.cpp' -o -iname '*.h' \) -exec bash -c "yes | arc lint {}" \;`

Reviewed By: bolinfest

Differential Revision: D6232695

fbshipit-source-id: d54942bf1c69b5b0dcd4df629f1f2d5538c9e28c
2017-11-03 16:02:03 -07:00
Adam Simpkins
094810c520 clean up treemanifest initialization in HgImporter
Summary:
This refactors the treemanifest union store initialization code, and fixes a
crash introduced in D5560787 if --use_hg_tree_manifest is enabled but the
underlying repository does not support treemanifest.

This moves the treemanifest initialization code into a new importTreeManifest()
helper function, and separates it from parsing the CMD_STARTED response.  We
now only initialize unionStore_ if FLAGS_use_hg_tree_manifest is enabled and
the repository supports treemanifest.  Other places in the code now only check
if unionStore_ is non-null to see if they should try importing via
treemanifest.

Splitting importTreeManifest() from the CMD_STARTED response parsing will
potentially make things cleaner in the future for using multiple
hg_import_helper.py processes.  Even if we start multiple of these processes,
we only need one instance of the C++ union store, and we don't need to
re-initialize the treemanifest separately each time.

Reviewed By: bolinfest

Differential Revision: D5647203

fbshipit-source-id: 71e14156f1d0ebc0880dd819c5b041b7c1146818
2017-08-17 16:13:00 -07:00
Adam Simpkins
38100d0f08 fix some bugs in the treemanifest import code
Summary:
This adds unit tests for the treemanifest import code, and fixes a couple of
bugs triggered by the tests: directory permissions were being set incorrectly,
and trees were being stored in the LocalStore with the wrong hash, causing
lookup errors later.

The HgImportTest code previously used HgImporter::importManifest(), which ended
up exercising only the flatmanifest code.  This updates HgImporter to expose
separate importFlatManifest() and importTreeManifest() APIs, and updates the
tests to check both import mechanisms.

Reviewed By: wez

Differential Revision: D5365959

fbshipit-source-id: 3799ee3b937296e8025b666dd7176dbe7e268a31
2017-07-05 11:21:30 -07:00
Adam Simpkins
f7756af4c7 add unit tests for HgImporter
Summary: Add unit tests for HgImporter to better test this import logic.

Reviewed By: bolinfest

Differential Revision: D5309171

fbshipit-source-id: b5619d8271fef1cc31a0f642ec2fcbf9eccced54
2017-06-23 18:25:32 -07:00