Add metric to track the ratio of empty messages to tlogs

This metric is to understand the impact of batching on empty commit messages.
If the ratio is high, it means proxy sends many empty commit messages, which
can potentially be optimized for better performance. If the ratio is low, which
means the spread factor is large, thus we need to optimize the proxy to reduce
such a factor.
This commit is contained in:
Jingyu Zhou 2021-06-24 21:20:21 -07:00
parent 4b56cf26be
commit 66a97b76f1
3 changed files with 29 additions and 1 deletions

View File

@ -1186,6 +1186,9 @@ ACTOR Future<Void> postResolution(CommitBatchContext* self) {
span.context,
self->debugID);
float ratio = self->toCommit.getEmptyLocationRatio();
pProxyCommitData->stats.commitBatchingEmptyMessageRatio.addMeasurement(ratio);
if (!self->forceRecovery) {
ASSERT(pProxyCommitData->latestLocalCommitBatchLogging.get() == self->localBatchNumber - 1);
pProxyCommitData->latestLocalCommitBatchLogging.set(self->localBatchNumber);

View File

@ -970,6 +970,7 @@ struct LogPushData : NonCopyable {
}
}
}
written = std::vector<bool>(messagesWriter.size(), false);
}
void addTxsTag() {
@ -1087,13 +1088,30 @@ struct LogPushData : NonCopyable {
next_message_tags.clear();
}
Standalone<StringRef> getMessages(int loc) { return messagesWriter[loc].toValue(); }
Standalone<StringRef> getMessages(int loc) {
// Update written here because this is called less frequently.
Standalone<StringRef> value = messagesWriter[loc].toValue();
if (!written[loc]) {
BinaryWriter w(AssumeVersion(g_network->protocolVersion()));
Standalone<StringRef> v = w.toValue();
if (value.size() > v.size()) {
written[loc] = true;
}
}
return value;
}
float getEmptyLocationRatio() const {
auto count = std::count(written.begin(), written.end(), false);
return 1.0 * count / written.size();
}
private:
Reference<ILogSystem> logSystem;
std::vector<Tag> next_message_tags;
std::vector<Tag> prev_tags;
std::vector<BinaryWriter> messagesWriter;
std::vector<bool> written; // if messagesWriter has written anything
std::vector<int> msg_locations;
// Stores message locations that have had span information written to them
// for the current transaction. Adding transaction info will reset this

View File

@ -64,6 +64,9 @@ struct ProxyStats {
LatencySample commitLatencySample;
LatencyBands commitLatencyBands;
// Ratio of tlogs receiving empty commit messages.
LatencySample commitBatchingEmptyMessageRatio;
LatencySample commitBatchingWindowSize;
Future<Void> logger;
@ -102,6 +105,10 @@ struct ProxyStats {
SERVER_KNOBS->LATENCY_METRICS_LOGGING_INTERVAL,
SERVER_KNOBS->LATENCY_SAMPLE_SIZE),
commitLatencyBands("CommitLatencyMetrics", id, SERVER_KNOBS->STORAGE_LOGGING_DELAY),
commitBatchingEmptyMessageRatio("CommitBatchingEmptyMessageRatio",
id,
SERVER_KNOBS->LATENCY_METRICS_LOGGING_INTERVAL,
SERVER_KNOBS->LATENCY_SAMPLE_SIZE),
commitBatchingWindowSize("CommitBatchingWindowSize",
id,
SERVER_KNOBS->LATENCY_METRICS_LOGGING_INTERVAL,