print blank for fetched source in start and queue events

Summary:
Now, the `SaplingBackingStore` know the source of each request. However, the sourced is available only for the finish event. The start and queue event doesn't know the source. In the last diff we used UNKNOW for these events. This diff changed the FetchedSource to a std::optional. Therefore for these events we don't need to populate it.
On the other hand, eden.thrift has a NOT_AVAILABLE_YET option. It chooses this option when the std::option doesn't have value.
The kFetchedSource map also update then if we have NOT_AVAILABLE_YET as the fetchedSource, it will give us a blank space character " " and the trace hg will print blank space char for start and queue events.

Reviewed By: kmancini

Differential Revision: D56942308

fbshipit-source-id: 732d5b4fd11cd2e9c5b8ff8e6dc1ec70bc262033
This commit is contained in:
Kaveh Ahmadi 2024-05-03 18:29:19 -07:00 committed by Facebook GitHub Bot
parent 4bd225fad8
commit 34ebf73eeb
5 changed files with 38 additions and 31 deletions

View File

@ -66,6 +66,8 @@ static const auto kRemoteFetchedEmoji =
reinterpret_cast<const char*>(u8"\U0001F310"); // 🌐
static const auto kUnknownFetchedEmoji =
reinterpret_cast<const char*>(u8"\U0001F937"); // 🤷
static const auto kNotAvailableYetFetchedEmoji = reinterpret_cast<const char*>(
u8"\U00000020\U00000020"); // double blank space " "
static const std::unordered_map<HgEventType, const char*> kHgEventTypes = {
{HgEventType::QUEUE, " "},
@ -111,6 +113,7 @@ static const std::unordered_map<FetchedSource, const char*> kFetchedSource = {
{FetchedSource::LOCAL, kLocalFetchedEmoji},
{FetchedSource::REMOTE, kRemoteFetchedEmoji},
{FetchedSource::UNKNOWN, kUnknownFetchedEmoji},
{FetchedSource::NOT_AVAILABLE_YET, kNotAvailableYetFetchedEmoji},
};
/**

View File

@ -1591,16 +1591,20 @@ void convertHgImportTraceEventToHgEvent(
break;
}
switch (event.fetchedSource) {
case ObjectFetchContext::FetchedSource::Local:
te.fetchedSource_ref() = FetchedSource::LOCAL;
break;
case ObjectFetchContext::FetchedSource::Remote:
te.fetchedSource_ref() = FetchedSource::REMOTE;
break;
case ObjectFetchContext::FetchedSource::Unknown:
te.fetchedSource_ref() = FetchedSource::UNKNOWN;
break;
if (event.fetchedSource.has_value()) {
switch (event.fetchedSource.value()) {
case ObjectFetchContext::FetchedSource::Local:
te.fetchedSource_ref() = FetchedSource::LOCAL;
break;
case ObjectFetchContext::FetchedSource::Remote:
te.fetchedSource_ref() = FetchedSource::REMOTE;
break;
case ObjectFetchContext::FetchedSource::Unknown:
te.fetchedSource_ref() = FetchedSource::UNKNOWN;
break;
}
} else {
te.fetchedSource_ref() = FetchedSource::NOT_AVAILABLE_YET;
}
te.unique_ref() = event.unique;

View File

@ -1056,7 +1056,15 @@ enum HgImportCause {
enum FetchedSource {
LOCAL = 0,
REMOTE = 1,
// The data is fetched. However, the fetch mode was AllowRemote
// and on the Eden side the source of the fetch is unknown.
// It could be local or remote
UNKNOWN = 2,
// The data is not fetched yet.
// We don't know the source on some of the Sapling events. For example,
// on the start events: before we fetch the data we don't know where
// we will be able to find it
NOT_AVAILABLE_YET = 3,
}
struct HgEvent {

View File

@ -211,7 +211,7 @@ HgImportTraceEvent::HgImportTraceEvent(
ImportPriority::Class priority,
ObjectFetchContext::Cause cause,
OptionalProcessId pid,
ObjectFetchContext::FetchedSource fetchedSource)
std::optional<ObjectFetchContext::FetchedSource> fetchedSource)
: unique{unique},
manifestNodeId{proxyHash.revHash()},
eventType{eventType},
@ -373,8 +373,7 @@ void SaplingBackingStore::processBlobImportRequests(
blobImport->proxyHash,
request->getPriority().getClass(),
request->getCause(),
request->getPid(),
ObjectFetchContext::FetchedSource::Unknown));
request->getPid()));
XLOGF(DBG4, "Processing blob request for {}", blobImport->hash);
}
@ -614,8 +613,7 @@ void SaplingBackingStore::processTreeImportRequests(
treeImport->proxyHash,
request->getPriority().getClass(),
request->getCause(),
request->getPid(),
ObjectFetchContext::FetchedSource::Unknown));
request->getPid()));
XLOGF(DBG4, "Processing tree request for {}", treeImport->hash);
}
@ -878,8 +876,7 @@ void SaplingBackingStore::processBlobMetaImportRequests(
blobMetaImport->proxyHash,
request->getPriority().getClass(),
request->getCause(),
request->getPid(),
ObjectFetchContext::FetchedSource::Unknown));
request->getPid()));
XLOGF(DBG4, "Processing blob meta request for {}", blobMetaImport->hash);
}
@ -1168,8 +1165,7 @@ SaplingBackingStore::getTreeEnqueue(
proxyHash,
context->getPriority().getClass(),
context->getCause(),
context->getClientPid(),
ObjectFetchContext::FetchedSource::Unknown));
context->getClientPid()));
return queue_.enqueueTree(std::move(request))
.ensure([this,
@ -1297,8 +1293,7 @@ ImmediateFuture<BackingStore::GetBlobResult> SaplingBackingStore::getBlobImpl(
proxyHash,
context->getPriority().getClass(),
context->getCause(),
context->getClientPid(),
ObjectFetchContext::FetchedSource::Unknown));
context->getClientPid()));
return queue_.enqueueBlob(std::move(request))
.ensure([this,
@ -1386,8 +1381,7 @@ SaplingBackingStore::getBlobMetadataImpl(
proxyHash,
context->getPriority().getClass(),
context->getCause(),
context->getClientPid(),
ObjectFetchContext::FetchedSource::Unknown));
context->getClientPid()));
return queue_.enqueueBlobMeta(std::move(request))
.ensure([this,

View File

@ -63,8 +63,7 @@ struct HgImportTraceEvent : TraceEventBase {
const HgProxyHash& proxyHash,
ImportPriority::Class priority,
ObjectFetchContext::Cause cause,
OptionalProcessId pid,
ObjectFetchContext::FetchedSource fetchedSource) {
OptionalProcessId pid) {
return HgImportTraceEvent{
unique,
QUEUE,
@ -73,7 +72,7 @@ struct HgImportTraceEvent : TraceEventBase {
priority,
cause,
pid,
fetchedSource};
std::nullopt};
}
static HgImportTraceEvent start(
@ -82,8 +81,7 @@ struct HgImportTraceEvent : TraceEventBase {
const HgProxyHash& proxyHash,
ImportPriority::Class priority,
ObjectFetchContext::Cause cause,
OptionalProcessId pid,
ObjectFetchContext::FetchedSource fetchedSource) {
OptionalProcessId pid) {
return HgImportTraceEvent{
unique,
START,
@ -92,7 +90,7 @@ struct HgImportTraceEvent : TraceEventBase {
priority,
cause,
pid,
fetchedSource};
std::nullopt};
}
static HgImportTraceEvent finish(
@ -122,7 +120,7 @@ struct HgImportTraceEvent : TraceEventBase {
ImportPriority::Class priority,
ObjectFetchContext::Cause cause,
OptionalProcessId pid,
ObjectFetchContext::FetchedSource fetchedSource);
std::optional<ObjectFetchContext::FetchedSource> fetchedSource);
// Simple accessor that hides the internal memory representation of paths.
std::string getPath() const {
@ -143,7 +141,7 @@ struct HgImportTraceEvent : TraceEventBase {
ImportPriority::Class importPriority;
ObjectFetchContext::Cause importCause;
OptionalProcessId pid;
ObjectFetchContext::FetchedSource fetchedSource;
std::optional<ObjectFetchContext::FetchedSource> fetchedSource;
};
/**