Skip to content

Commit c90dd1d

Browse files
Jaesoo Leefacebook-github-bot
authored andcommitted
WorkloadGenerator: fixed a bug in scaling key popularity distribution
Summary: There was a bug in scaling the number of keys in WorkloadGenerator. Particularly, even when user wants to scale the number of keys larger than the sum of the number of keys in the popDistFile, the generated key population is a lot less than specified, but only close to the sum in popDistFile. This is due to the bug in FastDiscreteDistribution. Specifically, when it initializes the popularity buckets and the weights, there was a bug not initializing the key offset of bucket correctly; it was not considering the scaling factor into account. This change fixes the bug. Reviewed By: therealgymmy Differential Revision: D44144006 fbshipit-source-id: 1391b63b319598ac9d3e1307a86ad22b550bc2eb
1 parent 8b98b6e commit c90dd1d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

cachelib/cachebench/workload/FastDiscrete.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,12 @@ class FastDiscreteDistribution final : public Distribution {
107107
sizes[i] -=
108108
facebook::cachelib::util::narrow_cast<size_t>(bucketPct * sizes[i]);
109109
probs[i] -= bucketPct * probs[i];
110-
buckets.push_back(static_cast<uint64_t>(objectsSeen * scalingFactor_));
110+
111+
auto scaledObjects =
112+
static_cast<uint64_t>(objectsSeen * scalingFactor_);
113+
buckets.push_back(scaledObjects);
111114
if (bucketOffsets_.size() > 0) {
112-
bucketOffsets_.push_back(bucketOffsets_.back() + objectsSeen);
115+
bucketOffsets_.push_back(bucketOffsets_.back() + scaledObjects);
113116
}
114117
weightSeen = 0.0;
115118
objectsSeen = 0;

0 commit comments

Comments
 (0)