chore: improve performance of mget operation (#2212)

Specifically, allocate only a single blob when returning multiple entries from a shard.
In addition, refactor and unify MGetResponse between string family code and ReplyBuilder code.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
Roman Gershman 2023-11-24 14:13:07 +02:00 committed by GitHub
parent dafdb9f4cf
commit 7d53d196aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 194 additions and 120 deletions

View file

@ -282,7 +282,7 @@ class InterpreterReplier : public RedisReplyBuilder {
void SendStored() final;
void SendSimpleString(std::string_view str) final;
void SendMGetResponse(absl::Span<const OptResp>) final;
void SendMGetResponse(MGetResponse resp) final;
void SendSimpleStrArr(StrSpan arr) final;
void SendNullArray() final;
@ -389,13 +389,13 @@ void InterpreterReplier::SendSimpleString(string_view str) {
PostItem();
}
void InterpreterReplier::SendMGetResponse(absl::Span<const OptResp> arr) {
void InterpreterReplier::SendMGetResponse(MGetResponse resp) {
DCHECK(array_len_.empty());
explr_->OnArrayStart(arr.size());
for (uint32_t i = 0; i < arr.size(); ++i) {
if (arr[i].has_value()) {
explr_->OnString(arr[i]->value);
explr_->OnArrayStart(resp.resp_arr.size());
for (uint32_t i = 0; i < resp.resp_arr.size(); ++i) {
if (resp.resp_arr[i].has_value()) {
explr_->OnString(resp.resp_arr[i]->value);
} else {
explr_->OnNil();
}