sapling/eden/fs/store/BackingStore.h
Katie Mancini be0cd8da1e enable skipping Metadata prefetches during eden prefetches
Summary:
This is the plumbing to allow us to skip Metadata prefetching during eden
prefetches. These can trigger  a bunch of wasted network requests
when we are fetching files anyways. (These network requests are wasted since we
fetch the file contents and most of them are being throttled on sandcastle anyways.)

We won't necessarily want to skip metadata prefetching always, we will still want it
for the watchman queries, but for `eden prefetch` will probably want to skip it. This
is why we are making it an option in the GlobParams.

Reviewed By: chadaustin

Differential Revision: D24640754

fbshipit-source-id: 20db62d4c0e59fe17cb6535c86ac8f1e3877879c
2020-11-11 16:30:02 -08:00

90 lines
2.5 KiB
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
#pragma once
#include <folly/Range.h>
#include <folly/futures/Future.h>
#include <memory>
#include "eden/fs/store/ImportPriority.h"
#include "eden/fs/store/ObjectFetchContext.h"
namespace folly {
template <typename T>
class Future;
}
namespace facebook {
namespace eden {
class Blob;
class Hash;
class Tree;
/**
* Abstract interface for a BackingStore.
*
* A BackingStore fetches tree and blob information from an external
* authoritative data source.
*
* BackingStore implementations must be thread-safe, and perform their own
* internal locking.
*/
class BackingStore {
public:
BackingStore() {}
virtual ~BackingStore() {}
virtual folly::SemiFuture<std::unique_ptr<Tree>> getTree(
const Hash& id,
ObjectFetchContext& context) = 0;
virtual folly::SemiFuture<std::unique_ptr<Blob>> getBlob(
const Hash& id,
ObjectFetchContext& context) = 0;
virtual folly::SemiFuture<std::unique_ptr<Tree>> getTreeForCommit(
const Hash& commitID,
ObjectFetchContext& context) = 0;
virtual folly::SemiFuture<std::unique_ptr<Tree>> getTreeForManifest(
const Hash& commitID,
const Hash& manifestID,
ObjectFetchContext& context) = 0;
FOLLY_NODISCARD virtual folly::SemiFuture<folly::Unit> prefetchBlobs(
const std::vector<Hash>& /*ids*/,
ObjectFetchContext& /*context*/) {
return folly::unit;
}
virtual void periodicManagementTask() {}
/**
* Subclass of BackingStore will override these functions to record file paths
* fetched. By default, recordFetch() does nothing. After
* startRecordingFetch() is called, recordFetch() starts to records fetched
* file paths. stopRecordingFetch() will disable recordFetch()'s function and
* return the fetched files since startRecordingFetch() is called and clear
* the old records.
*
* Currently implemented in HgQueuedBackingStore.
*
* Note: Only stopRecordingFetch() clears old records. Calling
* startRecordingFetch() a second time has no effect.
*/
virtual void startRecordingFetch() {}
virtual void recordFetch(folly::StringPiece) {}
virtual std::unordered_set<std::string> stopRecordingFetch() {
return {};
}
private:
// Forbidden copy constructor and assignment operator
BackingStore(BackingStore const&) = delete;
BackingStore& operator=(BackingStore const&) = delete;
};
} // namespace eden
} // namespace facebook