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

Support DISK Command #882

Merged
merged 50 commits into from
Oct 11, 2022
Merged

Conversation

tanruixiang
Copy link
Member

It closes #874

src/redis_disk.h Outdated Show resolved Hide resolved
src/redis_disk.cc Outdated Show resolved Hide resolved
src/redis_disk.cc Outdated Show resolved Hide resolved
src/redis_disk.cc Outdated Show resolved Hide resolved
src/redis_disk.cc Outdated Show resolved Hide resolved
tests/cppunit/disk_test.cc Outdated Show resolved Hide resolved
tests/cppunit/disk_test.cc Outdated Show resolved Hide resolved
tests/cppunit/disk_test.cc Outdated Show resolved Hide resolved
src/redis_disk.cc Outdated Show resolved Hide resolved
src/redis_disk.cc Outdated Show resolved Hide resolved
@tanruixiang
Copy link
Member Author

@PragmaTwice Hi. Do you have any more suggestions on reducing redundant code?

@tanruixiang
Copy link
Member Author

tanruixiang commented Sep 17, 2022

@PragmaTwice @git-hulk @torwig I noticed a problem. In the following tests. When we write a value with only one bit(like 'a'). Occasionally, the size of the key we get is 0. It occurs frequently when the value is very small. I guess the reason for this problem is that sync in writeoption defaults to false. Or because the GetApproximateSizes can only yield approximate values, which may be ignored for small values.

  std::vector<int> value_size{1, 1024};
  for(auto &p : value_size){
    EXPECT_TRUE(string->Set(key_, std::string(p, 'a')).ok());
    std::string got_value;
    EXPECT_TRUE(string->Get(key_,  &got_value).ok());
    EXPECT_EQ(got_value, std::string(p, 'a'));
    std::string value;
    string->Get(key_, &value);
    uint64_t result = 0;
    EXPECT_TRUE(disk->GetKeySize(key_, kRedisString, &result).ok());
    EXPECT_GE(result, p);
  }

Comment on lines +61 to +62
require.GreaterOrEqual(t, val, int(float64(approximateSize)*estimationFactor))
require.LessOrEqual(t, val, int(float64(approximateSize)/estimationFactor))
Copy link
Member

@PragmaTwice PragmaTwice Oct 5, 2022

Choose a reason for hiding this comment

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

I am wondering if this could be narrowed down a bit more. This range currently has a hundred times the gap between the upper and lower bound, which I think is still relatively large. But if we can confirm that the estimation accuracy of rocksdb can only be this at most, it is fine.

Copy link
Member Author

@tanruixiang tanruixiang Oct 5, 2022

Choose a reason for hiding this comment

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

I think it is theoretically possible, but we need to accurately calculate the key size constructed by kvrocks as the expected size. Also consider rocksdb's space compression for keys (such as prefix compression). In fact, the test of rocksdb is also a relatively large range. I personally don't think it makes much sense to do these jobs, because as long as there is no problem with the rocksdb we depend on, then there will be no problem with this function, If there is a change in the kvrocks level, the scope now is enough to test the problem. Of course, I can give it a try if you feel the need to.

Copy link
Member

Choose a reason for hiding this comment

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

I think it is fine if rocksdb also has a large range.

@tanruixiang
Copy link
Member Author

@git-hulk @torwig @caipengbo Hi. Do you have time to review?

@git-hulk
Copy link
Member

git-hulk commented Oct 7, 2022

@git-hulk @torwig @caipengbo Hi. Do you have time to review?

Sure, I have read through the implementation, and overall is good to me. I'm still wondering if we have a more general way to reduce duplicate codes, I will approve this PR soon if can't figure out a better way.

src/redis_cmd.cc Outdated Show resolved Hide resolved
@tanruixiang
Copy link
Member Author

Sure, I have read through the implementation, and overall is good to me. I'm still wondering if we have a more general way to reduce duplicate codes, I will approve this PR soon if can't figure out a better way.

Do you have any ideas? It seems like it should be impossible to reduce each type of custom operation.

@git-hulk
Copy link
Member

git-hulk commented Oct 8, 2022

Sure, I have read through the implementation, and overall is good to me. I'm still wondering if we have a more general way to reduce duplicate codes, I will approve this PR soon if can't figure out a better way.

Do you have any ideas? It seems like it should be impossible to reduce each type of custom operation.

The main issue is GetMetadata requires passing the type, so another way is to allow skipping type check in GetMetadata, but the current implementation is also fine to me. To see others have thoughts on this cc @ShooterIT @PragmaTwice @caipengbo @torwig

Copy link
Member

@git-hulk git-hulk left a comment

Choose a reason for hiding this comment

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

LGTM

@git-hulk git-hulk requested review from torwig and PragmaTwice October 8, 2022 14:44
@git-hulk
Copy link
Member

@PragmaTwice @caipengbo @torwig Do you have any suggestion on this PR? Or I will merge it if we have no further comment.

@caipengbo
Copy link
Contributor

LGTM

@git-hulk
Copy link
Member

Thanks for @tanruixiang contribution and patient, also thanks to everyone who reviewed this PR. Merging...

@git-hulk git-hulk merged commit 9dbc8c7 into apache:unstable Oct 11, 2022
@caipengbo
Copy link
Contributor

We also need to update our website :) @git-hulk

@git-hulk
Copy link
Member

Yes, @caipengbo you can help to update as well when you're free. https://github.com/apache/incubator-kvrocks-website/blob/main/docs/01-supported-commands.md

@caipengbo
Copy link
Contributor

caipengbo commented Oct 11, 2022

Yes, @caipengbo you can help to update as well when you're free. https://github.com/apache/incubator-kvrocks-website/blob/main/docs/01-supported-commands.md

If I update the repository, will the site automatically update?

@tanruixiang
Copy link
Member Author

We also need to update our website :) @git-hulk

Do you want to do it? If you don't have time, I can update the website later today.

@git-hulk
Copy link
Member

Yes, GitHub actions will deploy the update automatically.

@git-hulk
Copy link
Member

We also need to update our website :) @git-hulk

Do you want to do it? If you don't have time, I can update the website later today.

Cool, thanks. @tanruixiang

@caipengbo
Copy link
Contributor

Yes, you can do it :) @tanruixiang

@tanruixiang tanruixiang deleted the support_disk_command branch October 28, 2022 12:30
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.

The requirement of two commands for Kvrocks
5 participants