-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: allow non-ascii values in dfly_bench #4751
Conversation
binary strings are supported by RESP protocol so we now generate commands using this protocol, so that we could pass binary strings. In addition, fixed "done" metric which did not account for number of shards cluster mode. Signed-off-by: Roman Gershman <roman@dragonflydb.io>
if (!cmd_parts_.empty()) { | ||
const string_view* cmd = get_if<string_view>(&cmd_parts_.front()); | ||
if (cmd) { | ||
might_hit_ = absl::EqualsIgnoreCase(*cmd, "get") || absl::StartsWithIgnoreCase(*cmd, "mget"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might_hit_ = absl::EqualsIgnoreCase(*cmd, "get") || absl::StartsWithIgnoreCase(*cmd, "mget"); | |
might_hit_ = absl::EqualsIgnoreCase(*cmd, "get") || absl::EqualsIgnoreCase(*cmd, "mget"); |
@@ -103,6 +102,11 @@ static string GetRandomHex(size_t len) { | |||
} | |||
} | |||
|
|||
if (!ascii) { | |||
for (size_t i = 0; i < len; i++) { | |||
res[i] += 80; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why +80? Plz explain 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hexadecimal characters with 0
padding start at ascii 0
which is 48. +80 moves the whole string to non-ascii range.
}; | ||
|
||
CommandGenerator::CommandGenerator(KeyGenerator* keygen) : keygen_(keygen) { | ||
command_ = GetFlag(FLAGS_command); | ||
value_ = string(GetFlag(FLAGS_d), 'a'); | ||
is_ascii_ = GetFlag(FLAGS_ascii); | ||
value_ = string(GetFlag(FLAGS_d), is_ascii_ ? 'a' : char(130)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
130 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nonascii
if (protocol == RESP) { | ||
return absl::StrCat("set ", key, " ", value_, "\r\n"); | ||
} | ||
absl::StrAppend(&res, "*3\r\n$3\r\nset\r\n$", key.size(), "\r\n", key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I blindly trust you with this 🤣
binary strings are supported by RESP protocol so we now generate commands using this protocol, so that we could pass binary strings.
In addition, fixed "done" metric which did not account for number of shards cluster mode.