Commit Graph

28 Commits

Author SHA1 Message Date
Xavier Deguillard
864ead9e24 glob: fix ** glob take 2
Summary:
In D29079762 (ea2e2f8bbd), globbing was fixed to not match the recursive glob (**) against
the entire path, as this would lead some paths to be matched while they
shouldn't. It however introduced another bug: in some cases, recursive globs
would no longer match paths that should be matched.

To fix both, a partial revert of the original diff is done with a small tweak:
the path that is matched against no longer starts at the root of the
repository. This will prevent `a/b/**/b/c.txt` to match `a/b/c.txt` as
`**/b/c.txt` would only be matched against `c.txt`, and not `a/b/c.txt` like it
was previously.

Reviewed By: fanzeyi

Differential Revision: D29175333

fbshipit-source-id: 1a4137d6f64f6cb77c4be09bd143f72630aa58d5
2021-06-23 14:11:32 -07:00
Xavier Deguillard
e0250f8c68 Back out "inodes: fix globbing bug with **"
Summary: The original commit broke globbing more than it fixed it. D29175333 will fully fix it, but in the meantime, let's revert the change to get a release out.

Reviewed By: singhsrb

Differential Revision: D29231954

fbshipit-source-id: 7a42e980c6fc4de09bee713a3a4141d52272b6d1
2021-06-18 17:27:27 -07:00
Xavier Deguillard
ea2e2f8bbd inodes: fix globbing bug with **
Summary:
When matching against the ** pattern, EdenFS would match against the full path
instead of against just the current entry. This means that what was matched by
the glob prior to ** will be rechecked against by the pattern that follows **,
which isn't what is expected.

As a bonus, the `candidateName` variable will be constructed less than before
leading to less memory allocations.

Reviewed By: chadaustin

Differential Revision: D29079762

fbshipit-source-id: af15ecf229ce7119100dd375df23269bb7cdb1c0
2021-06-14 17:03:27 -07:00
Chad Austin
bb1cccac89 introduce a variable-width RootId type that identifies the root of an EdenFS checkout's contents
Summary:
Backing stores differentiate between individual tree objects and the
root of a checkout. For example, Git and Mercurial roots are commit
hashes. Allow EdenFS to track variable-width roots to better support
arbitrary backing stores.

Reviewed By: genevievehelsel

Differential Revision: D28619584

fbshipit-source-id: d94f1ecd21a0c416c1b4933341c70deabf386496
2021-06-07 17:25:31 -07:00
Katie Mancini
ee923324d2 thread ObjectFetchContext lookup
Summary:
There are a few remaining holes where we are not passing a full fetch context.
We will need a full fetch context to do all data fetch logging needed for the
intern project. Additionally we generally should not be using these singletons
in our production code.

Most of lookup is already threaded. This finishes the threading for lookup.

Reviewed By: xavierd

Differential Revision: D23456910

fbshipit-source-id: fab7397caeee19f921d8fba1fb6528baa5cf2960
2021-06-03 16:33:35 -07:00
Chad Austin
894eaa9840 move root ID parsing and rendering into BackingStore
Summary:
The meaning of the root ID is defined by the BackingStore, so move
parsing and rendering into the BackingStore interface.

Reviewed By: xavierd

Differential Revision: D28560426

fbshipit-source-id: 7cfed4870d48016811b604348742754f6cdbd842
2021-06-03 11:07:14 -07:00
Xavier Deguillard
bb5731198b inodes: move checks for recursiveChildren_ in caller
Summary:
The evaluateRecursiveComponentImpl function calls itself recursively, but would
always check for every invocation whether the recursiveChildren_ was empty. We
know that if evaluateRecursiveComponentImpl was called that recursiveChildren_
wasn't empty, so we can remove the check and move it to its caller.

Reviewed By: chadaustin

Differential Revision: D28724574

fbshipit-source-id: b1e07393d2f1cdb605550eca5f0b0b01591a785d
2021-05-27 14:45:07 -07:00
Xavier Deguillard
95388f9d3a inodes: move InodePtr and shared_ptr instead of copying them
Summary:
Copying an InodePtr/shared_ptr adds 2 atomics: one for the copy, and one when
the copy is dropped. In the case where a move can be achieved, we can avoid
these atomics and make the code more efficient.

Reviewed By: fanzeyi

Differential Revision: D28614769

fbshipit-source-id: 9c4be6ce335cc17eb889a5681aa9c13595a7909e
2021-05-21 21:41:02 -07:00
Xavier Deguillard
c633705652 inodes: move some path instead of copying them
Summary:
Looking at the glob code, I noticed that some paths were copied into lambda and
vectors, while they could have been moved.

Reviewed By: fanzeyi

Differential Revision: D28614211

fbshipit-source-id: 5662586bcc3d9a9c5ca899c59d29b40a4e590adc
2021-05-21 21:41:02 -07:00
Xavier Deguillard
b73674c009 inodes: speed up globbing by not copying vectors
Summary:
C++ is full of footguns, in this case, the lockContents method either returns a
const std::vector<TreeEntry>&, or an rlock RAII for a folly::Synchronized
object. When assigning the return value of that method to an `auto` variable, a
copy is made in both cases, which isn't exactly what is desired in the first
case. Instead using the reference as-is is what we want.

To achieve the right behavior, a `const auto&` needs to be used: it will either be
a const reference in the first case, or a copy in the second case.

During an `arc focus2` while the Buck parsing phase is ongoing, the copy shows
up at the top of the profiler as one of the most expensive operation. This
significantly reduce its cost.

Reviewed By: chadaustin

Differential Revision: D28591502

fbshipit-source-id: eac1e062ed94442c90ac549ec137d91b4cb42b9c
2021-05-21 19:26:46 -07:00
Shai Szulanski
dba656e44d Rename Try::throwIfFailed -> throwUnlessValue
Summary: Update name to match usage of Try as tri-state, since this method also throws if the Try is empty

Reviewed By: yfeldblum

Differential Revision: D25737810

fbshipit-source-id: a4166153362f07353d212216fbaf7105867eef2a
2021-01-11 13:05:17 -08:00
Chad Austin
4299003775 return a better error message if something includes . or .. in their glob
Summary:
We used to produce a confusing error message during glob evaluation
when . or .. was specified as a glob component. Instead, fail early,
with an error message that more directly explains the problem.

Reviewed By: genevievehelsel

Differential Revision: D24969096

fbshipit-source-id: fe70a8f4db1fdce8eec13890d20913b63a516518
2020-11-17 12:53:39 -08:00
Katie Mancini
f616872079 Allow specifying commits to match against and prefetch in globFiles
Summary:
We want to be able to fetch prefetch profiles on pull. That means we will need
to prefetch the contents of prefetch profiles for commits that we are not
currently on. Thus globFiles (the thrift endpoint used for prefetch profiles
fetching) needs to be able to take commit hashes to match and fetch against.

Why fetch prefetch profiles on pull? This would get the prefetch started earlier so
the files are hopefully fetched by the time the user needs them.

Reviewed By: chadaustin, genevievehelsel

Differential Revision: D23858659

fbshipit-source-id: 123e423d5117274b92405dbb5c2df690298a1c18
2020-10-29 13:34:06 -07:00
Lee Howes
f15fdeec84 collectX to collectUnsafe
Summary:
Migration from Future-returning executor-erasing collectX forms to
SemiFuture-returning forms, that are less risky in particular with coroutines.

Earlier diffs added SemiFuture and Unsafe versions. This codemod migrates
collect versions to the Unsafe versions to allow the basic collect versions to
be made safe.

Reviewed By: simpkins

Differential Revision: D20331206

fbshipit-source-id: efc8dff487d45f7d53ee55e8c4696bd3eed0e6da
2020-03-10 11:36:09 -07:00
Chad Austin
fc07c3b6e6 add an ObjectFetchContext interface
Summary:
Add a fetch context interface to ObjectStore that allows tracing cache
hits, backing store fetches, and fetch durations in the context of a
diff or checkout operation.

Reviewed By: simpkins

Differential Revision: D19135625

fbshipit-source-id: d0d8f134b1c89f7ba4971a404a46a69a1704ba5c
2020-02-05 13:15:01 -08: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
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
Adam Simpkins
1de7c09d61 fix a crash in GlobNode::evaluate()
Summary:
Fix `GlobNode::evaluate()` so that it only generates a result once all
processing is complete.  The glob evaluation walks down the inode tree in
parallel.  Previously if an error occurred while processing one TreeInode it
would return that exception to the caller immediately, even if work was still
being done to evaluate the glob on other parts of the inode tree.  This
behavior is problematic, since the caller may destroy the GlobNode immediately
once a result is generated, and the caller has no way to know that other
children GlobNodes may still be using some of the data.

This fixes the code to wait until all evaluation sub-futures have completed
processing even on error, so that we know it is safe to destroy the GlobNode
before we generate a result.

Reviewed By: wez

Differential Revision: D17434327

fbshipit-source-id: ef70dc82281eeb3540840202ec5e704afe2d29eb
2019-09-17 16:23:56 -07:00
Adam Simpkins
aa5e6c7295 update license headers in C++ files
Summary:
Update the copyright & license headers in C++ files to reflect the
relicensing to GPLv2

Reviewed By: wez

Differential Revision: D15487078

fbshipit-source-id: 19f24c933a64ecad0d3a692d0f8d2a38b4194b1d
2019-06-19 17:02:45 -07:00
Chad Austin
42dcf78aad clang-format
Summary: Small parts of our code have diverged from our clang-format rules.

Reviewed By: strager

Differential Revision: D15380260

fbshipit-source-id: f668ac22d6c0c5f2468549f2a94dd1c9bb22ce3d
2019-05-17 10:19:02 -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
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
Wez Furlong
8847a7a061 add dtype as an optional return value from glob
Summary:
This diff adds the dtype field to the glob results;
this will help to reduce the cost of some watchman queries by avoiding a
getFileInformation call that instantiates inodes.

As part of this, I added a bunch of unit test coverage.

Reviewed By: strager

Differential Revision: D8779149

fbshipit-source-id: 3064a3e42be55ec576fed9e0f7112edef426f32d
2019-02-19 11:26:26 -08:00
Adam Simpkins
dacc8787f3 convert some deprecated Future::then() calls
Summary:
Convert deprecated `folly::Future::then()` calls to `thenTry()` or
`thenValue()` as appropriate.

Reviewed By: chadaustin

Differential Revision: D10503906

fbshipit-source-id: abc0f6f588ad7edd0dd2576544875f4ad0263b83
2018-10-23 13:42:12 -07:00
Lee Howes
e8e25257cf Future<T>::then Future<T>::then() -> Future<T>::thenValue or thenTry.
Summary:
Part of the larger project to modify Future<T>::then to be r-value qualified and use Future<T>::thenTry or Future<T>::thenValue.

The goal is to disambiguate folly::Future and to improve type and lifetime safety of Future and its methods.

Codemod:
  future<T>.then(callable with operator()(not-a-try)) to future<T>.thenValue(callable with operator()(not-a-try)).
  future<T>.then(callable with operator()()) to future<T>.thenValue(callable with operator()(auto&&)).
  future<T>.then(callable with operator()(auto)) to future<T>.thenValue(callable with operator()(auto)).
  future<T>.then(callable with operator()(folly::Try<T>)) to future<T>.thenTry(callable)

Reviewed By: Orvid

Differential Revision: D9819578

fbshipit-source-id: f9e31f47354c041ecbf0a90953cbe50ebfda6adc
2018-09-14 17:10:57 -07:00
Wez Furlong
eda02cdfab fix logic bug in glob prefetching
Summary:
We should only kick off prefetching for the files
that matched the glob.  We were prefetching files that
didn't match the glob.

facepalms

Reviewed By: strager

Differential Revision: D8846994

fbshipit-source-id: 593e85d843ffa1cc0707ed1dc86f1385262821f5
2018-07-16 11:38:15 -07:00
Wez Furlong
2e43c3b76d move GlobNode -> inodes dir
Summary:
This makes it easier to add some test coverage.

There's no real functional change in this diff; the only code change is to
throw a system_error instead of a thrift eden error wrapper class from the core
globbing code.  There's a little bit of code to restore this exception type in
the callers in EdenServiceHandler; this is covered by existing integration
tests, but I've also expanded that coverage to cover both variants of the glob
thrift calls.

Reviewed By: strager

Differential Revision: D8776767

fbshipit-source-id: 3ea4ea642ae5108aa4b0153541bd3604f010b54c
2018-07-13 11:22:19 -07:00