Merge pull request #3761 from sfc-gh-tclinkenbeard/document-watchbytes-overhead

Add comments for WATCH_OVERHEAD_BYTES
This commit is contained in:
Trevor Clinkenbeard 2020-09-26 20:39:27 -07:00 committed by GitHub
commit c613fc6dee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -1011,6 +1011,11 @@ ACTOR Future<Void> getValueQ( StorageServer* data, GetValueRequest req ) {
return Void(); return Void();
}; };
// Pessimistic estimate the number of overhead bytes used by each
// watch. Watch key references are stored in an AsyncMap<Key,bool>, and actors
// must be kept alive until the watch is finished.
static constexpr size_t WATCH_OVERHEAD_BYTES = 1000;
ACTOR Future<Void> watchValue_impl( StorageServer* data, WatchValueRequest req ) { ACTOR Future<Void> watchValue_impl( StorageServer* data, WatchValueRequest req ) {
try { try {
++data->counters.watchQueries; ++data->counters.watchQueries;
@ -1058,7 +1063,7 @@ ACTOR Future<Void> watchValue_impl( StorageServer* data, WatchValueRequest req )
} }
++data->numWatches; ++data->numWatches;
data->watchBytes += ( req.key.expectedSize() + req.value.expectedSize() + 1000 ); data->watchBytes += (req.key.expectedSize() + req.value.expectedSize() + WATCH_OVERHEAD_BYTES);
try { try {
if(latest < minVersion) { if(latest < minVersion) {
// If the version we read is less than minVersion, then we may fail to be notified of any changes that occur up to or including minVersion // If the version we read is less than minVersion, then we may fail to be notified of any changes that occur up to or including minVersion
@ -1071,10 +1076,10 @@ ACTOR Future<Void> watchValue_impl( StorageServer* data, WatchValueRequest req )
} }
wait(watchFuture); wait(watchFuture);
--data->numWatches; --data->numWatches;
data->watchBytes -= ( req.key.expectedSize() + req.value.expectedSize() + 1000 ); data->watchBytes -= (req.key.expectedSize() + req.value.expectedSize() + WATCH_OVERHEAD_BYTES);
} catch( Error &e ) { } catch( Error &e ) {
--data->numWatches; --data->numWatches;
data->watchBytes -= ( req.key.expectedSize() + req.value.expectedSize() + 1000 ); data->watchBytes -= (req.key.expectedSize() + req.value.expectedSize() + WATCH_OVERHEAD_BYTES);
throw; throw;
} }
} catch( Error &e ) { } catch( Error &e ) {