Skip to content
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

Merged
merged 1 commit into from
Mar 12, 2025
Merged

feat: allow non-ascii values in dfly_bench #4751

merged 1 commit into from
Mar 12, 2025

Conversation

romange
Copy link
Collaborator

@romange romange commented Mar 11, 2025

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.

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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why +80? Plz explain 😄

Copy link
Collaborator Author

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));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

130 ?

Copy link
Collaborator Author

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);
Copy link
Contributor

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 🤣

@romange romange merged commit 51dd6d1 into main Mar 12, 2025
10 checks passed
@romange romange deleted the Pr4 branch March 12, 2025 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants