Skip to content

Commit a925737

Browse files
Jaesoo Leefacebook-github-bot
authored andcommitted
KVReplayGenerator: parse GET_LEASE and SET_LEASE operations
Summary: Memcached's WSA logger will now emits GET_LEASE and SET_LEASE operations as well. This changes makes the cachebench treats those as GET and SET, respectively, for compatibility. Reviewed By: therealgymmy Differential Revision: D43336316 fbshipit-source-id: c9b842d567b9fb2128b822bd429f5dce30b378da
1 parent 6357906 commit a925737

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

cachelib/cachebench/workload/KVReplayGenerator.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,10 @@ inline bool KVReplayGenerator::parseRequest(const std::string& line,
230230

231231
// Set op
232232
const auto& op = fields[SampleFields::OP];
233-
// TODO only memcache optypes are supported
234-
if (!op.compare("GET")) {
233+
// TODO implement GET_LEASE and SET_LEASE emulations
234+
if (!op.compare("GET") || !op.compare("GET_LEASE")) {
235235
req->req_.setOp(OpType::kGet);
236-
} else if (!op.compare("SET")) {
236+
} else if (!op.compare("SET") || !op.compare("SET_LEASE")) {
237237
req->req_.setOp(OpType::kSet);
238238
} else if (!op.compare("DELETE")) {
239239
req->req_.setOp(OpType::kDel);

cachelib/cachebench/workload/tests/KVReplayGeneratorTest.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ struct TraceEntry {
5656
size_t expKeySize = std::max<size_t>(keySize_, reqKey.size());
5757
expKeySize = std::min<size_t>(expKeySize, 256);
5858
ASSERT_EQ(reqKey.size(), expKeySize);
59+
ASSERT_EQ(req.req_.getOp(), getOpType());
60+
}
61+
62+
OpType getOpType() {
63+
if (!op_.compare("GET") || !op_.compare("GET_LEASE")) {
64+
return OpType::kGet;
65+
} else if (!op_.compare("SET") || !op_.compare("SET_LEASE")) {
66+
return OpType::kSet;
67+
} else if (!op_.compare("DELETE")) {
68+
return OpType::kDel;
69+
}
70+
return OpType::kSize;
5971
}
6072

6173
std::string key_;
@@ -86,8 +98,11 @@ TEST(KVReplayGeneratorTest, BasicFormat) {
8698
// <key_size>,<op>,<size>,<op_count>,<ttl>,<valid>
8799
{7, "GET", 0, 2, std::nullopt, true},
88100
{7, "GET", 0, 2, 50, true},
101+
{7, "GET_LEASE", 0, 2, 50, true},
89102
{20, "SET", 100, 35, std::nullopt, true},
90103
{20, "SET", 100, 35, 3600, true},
104+
{20, "SAT", 100, 35, 3600, false}, // invalid op name
105+
{20, "SET_LEASE", 100, 35, 3600, true},
91106
{7, "GET", 0, 0, std::nullopt, false}, // invalid op count
92107
{7, "GET", 0, 0, 600, false}, // invalid op count
93108
{1024, "SET", 100, 35, 300, true}, // key truncated

0 commit comments

Comments
 (0)