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(connection): Support pipelining with Memcached #2648

Merged
merged 5 commits into from
Feb 23, 2024

Conversation

dranikpg
Copy link
Contributor

@dranikpg dranikpg commented Feb 22, 2024

Add support for pipelining to memcached connection interface
Update pytests to cover noreply dynamics more extensively

@@ -277,28 +277,6 @@ string_view Connection::PubMessage::Message() const {
return {buf.get() + channel_len, message_len};
}

struct Connection::DispatchOperations {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just moved it down because it was in an almost random place and all the definitions are actually 100 lines below

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
@dranikpg dranikpg marked this pull request as ready for review February 23, 2024 09:02
@dranikpg
Copy link
Contributor Author

Do we need any optimizations? Like the following:

  • message pooling
  • inlined backing storage

@@ -1397,7 +1397,7 @@ void Service::DispatchMC(const MemcacheParser::Command& cmd, std::string_view va
strcpy(cmd_name, "MGET");
break;
case MemcacheParser::FLUSHALL:
strcpy(cmd_name, "FLUSHDB");
strcpy(cmd_name, "FLUSHALL");
Copy link
Collaborator

Choose a reason for hiding this comment

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

why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, good catch, forgot to follow up on this 😅 FLUSHDB is broken for some reason, will look at this

DispatchCommand(consumed, tlh);
bool has_more = consumed < io_buf_.InputLen();

if (tl_traffic_logger.log_file) // Log command as soon as we receive it
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider keeping it for Memcache as well. Can be done later though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We didn't log anything for memcached before. It's also not a "one liner" because we have to serialize our parsed command back, including all the flags

Comment on lines 82 to 85
res->key = tokens[key_pos++];

if (key_pos < num_tokens && base::_in(res->type, {MP::STATS, MP::FLUSHALL}))
return MP::PARSE_ERROR; // we do not support additional arguments for now.
Copy link
Contributor Author

@dranikpg dranikpg Feb 23, 2024

Choose a reason for hiding this comment

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

The flow is broken, the line above conflicts with the if, we can't safely parse a key for STATS or FLUSHALL. I quick fixed it below

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
mi_heap_t* tlh = mi_heap_get_backing();

// Re-use connection local resources to reduce allocations
RespVec& parse_args = tmp_parse_args_;
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do you prefer aliasing these variables and then pass them by capture?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To possibly untie them later, maybe they can become thread locals instead, they look weird as connection members

@dranikpg dranikpg merged commit 5ee61db into dragonflydb:main Feb 23, 2024
7 checks passed
@dranikpg dranikpg deleted the mc-async-dispatch branch March 28, 2024 21:00
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