Defined a minimum read cost (a penalty) for empty read or read size smaller than it. Fixed several review comments.

This commit is contained in:
Xin Dong 2019-10-30 10:04:19 -07:00
parent f70000184e
commit 199a34b827
4 changed files with 12 additions and 14 deletions

View File

@ -454,7 +454,8 @@ ServerKnobs::ServerKnobs(bool randomize, ClientKnobs* clientKnobs) {
init( SPLIT_JITTER_AMOUNT, 0.05 ); if( randomize && BUGGIFY ) SPLIT_JITTER_AMOUNT = 0.2;
init( IOPS_UNITS_PER_SAMPLE, 10000 * 1000 / STORAGE_METRICS_AVERAGE_INTERVAL_PER_KSECONDS / 100 );
init( BANDWIDTH_UNITS_PER_SAMPLE, SHARD_MIN_BYTES_PER_KSEC / STORAGE_METRICS_AVERAGE_INTERVAL_PER_KSECONDS / 25 );
init( BYTES_READ_UNITS_PER_SAMPLE, 100000 );
init( BYTES_READ_UNITS_PER_SAMPLE, 100000 ); // 100K bytes
init( EMPTY_READ_PENALTY, 20 ); // 20 bytes
//Storage Server
init( STORAGE_LOGGING_DELAY, 5.0 );

View File

@ -392,6 +392,7 @@ public:
int64_t IOPS_UNITS_PER_SAMPLE;
int64_t BANDWIDTH_UNITS_PER_SAMPLE;
int64_t BYTES_READ_UNITS_PER_SAMPLE;
int64_t EMPTY_READ_PENALTY;
//Storage Server
double STORAGE_LOGGING_DELAY;

View File

@ -221,13 +221,9 @@ struct StorageServerMetrics {
notifyMetrics.bytesPerKSecond = bandwidthSample.addAndExpire( key, metrics.bytesPerKSecond, expire ) * SERVER_KNOBS->STORAGE_METRICS_AVERAGE_INTERVAL_PER_KSECONDS;
if (metrics.iosPerKSecond)
notifyMetrics.iosPerKSecond = iopsSample.addAndExpire( key, metrics.iosPerKSecond, expire ) * SERVER_KNOBS->STORAGE_METRICS_AVERAGE_INTERVAL_PER_KSECONDS;
if (metrics.bytesReadPerKSecond) {
if (metrics.bytesReadPerKSecond)
notifyMetrics.bytesReadPerKSecond = bytesReadSample.addAndExpire(key, metrics.bytesReadPerKSecond, expire) *
SERVER_KNOBS->STORAGE_METRICS_AVERAGE_INTERVAL_PER_KSECONDS;
if (deterministicRandom()->random01() < 0.01) {
TraceEvent("BytesReadSampleCountX100").detail("SampleCount", bytesReadSample.queue.size());
}
}
if (!notifyMetrics.allZero()) {
auto& v = waitMetricsMap[key];
for(int i=0; i<v.size(); i++) {

View File

@ -516,6 +516,8 @@ public:
specialCounter(cc, "VersionLag", [self](){ return self->versionLag; });
specialCounter(cc, "LocalRate", [self]{ return self->currentRate() * 100; });
specialCounter(cc, "BytesReadSampleCount", [self]() { return self->metrics.bytesReadSample.queue.size(); });
specialCounter(cc, "FetchKeysFetchActive", [self](){ return self->fetchKeysParallelismLock.activePermits(); });
specialCounter(cc, "FetchKeysWaiting", [self](){ return self->fetchKeysParallelismLock.waiters(); });
@ -892,8 +894,8 @@ ACTOR Future<Void> getValueQ( StorageServer* data, GetValueRequest req ) {
StorageMetrics metrics;
// If the read yields no value, randomly sample the empty read.
metrics.bytesReadPerKSecond =
v.present() ? (int64_t)(req.key.size() + v.get().size())
: deterministicRandom()->random01() > 0.95 ? SERVER_KNOBS->BYTES_READ_UNITS_PER_SAMPLE : 0;
v.present() ? std::max((int64_t)(req.key.size() + v.get().size()), SERVER_KNOBS->EMPTY_READ_PENALTY)
: SERVER_KNOBS->EMPTY_READ_PENALTY;
data->metrics.notify(req.key, metrics);
if( req.debugID.present() )
@ -1272,7 +1274,7 @@ ACTOR Future<GetKeyValuesReply> readRange( StorageServer* data, Version version,
result.more = limit == 0 || *pLimitBytes<=0; // FIXME: Does this have to be exact?
result.version = version;
StorageMetrics metrics;
metrics.bytesReadPerKSecond = readSize;
metrics.bytesReadPerKSecond = std::max(readSize, SERVER_KNOBS->EMPTY_READ_PENALTY);
data->metrics.notify(limit >= 0 ? range.begin : range.end, metrics);
return result;
}
@ -1328,15 +1330,13 @@ ACTOR Future<Key> findKey( StorageServer* data, KeySelectorRef sel, Version vers
*pOffset = 0;
StorageMetrics metrics;
metrics.bytesReadPerKSecond = (int64_t)rep.data[index].key.size();
metrics.bytesReadPerKSecond = std::max((int64_t)rep.data[index].key.size(), SERVER_KNOBS->EMPTY_READ_PENALTY);
data->metrics.notify(sel.getKey(), metrics);
return rep.data[ index ].key;
} else {
StorageMetrics metrics;
// Randomly sample an empty read
metrics.bytesReadPerKSecond =
deterministicRandom()->random01() > 0.95 ? SERVER_KNOBS->BYTES_READ_UNITS_PER_SAMPLE : 0;
metrics.bytesReadPerKSecond = SERVER_KNOBS->EMPTY_READ_PENALTY;
data->metrics.notify(sel.getKey(), metrics);
// FIXME: If range.begin=="" && !forward, return success?
@ -1468,7 +1468,7 @@ ACTOR Future<Void> getKeyValues( StorageServer* data, GetKeyValuesRequest req )
for (int i = 0; i < r.data.size(); i++) {
StorageMetrics m;
m.bytesReadPerKSecond = r.data[i].expectedSize();
m.bytesReadPerKSecond = std::max((int64_t)r.data[i].expectedSize(), SERVER_KNOBS->EMPTY_READ_PENALTY);
data->metrics.notify(r.data[i].key, m);
}