-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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: add floyd #2347
feat: add floyd #2347
Conversation
std::unique_ptr<RedisZSets> zsets_db_; | ||
std::unique_ptr<RedisLists> lists_db_; | ||
std::atomic<bool> is_opened_ = false; | ||
std::vector<std::shared_ptr<Redis>> insts_; |
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.
容器里面一般使用 unique_ptr 就 ok 了
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.
个人觉得这个地方还是用shared_ptr比较好。insts_中的元素多个线程都会用到,unique_ptr不能拷贝,所以都是在使用unique_ptr的引用。如果坚持使用unique_ptr,那用户线程使用的inst建议直接用unique_ptr管理的裸指针。
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.
已修改。
SlotIndexer(uint32_t inst_num) : inst_num_(inst_num) {} | ||
~SlotIndexer() {} | ||
uint32_t GetInstanceID(int32_t slot_id) {return slot_id % inst_num_; } | ||
void ReshardSlots(const std::vector<uint32_t>& slots) {} |
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.
请问这个函数的作用是什么?
目前来看这个SlotIndexer只有GetInstanceID方法有用。个人感觉这个类有点鸡肋,保存的分片数量在storage类里也有(inst_.size()),完全可以放在storage里做一个方法。
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.
算哪个slot应该存在哪个rocskdb实例里。
拆出来原因:1. 当前的实现是直接求模,可能会导致每个rocksdb实例里的slot不均匀,后期期望有人提供其他的slot和rocskdb映射关系管理的实现。
2. storage类整体已经比较庞大了,独立的功能最好是拆个单独的类出来实现。
* floyd: refactor storage to support multi rocksdb instance && todis key format * fix compile error after rebase * fix compile error after rebase * fix by review comments * fix by review comments * fix by review comments * fix by lqx and panlei's review comments * fix by review comments * fix by review comments * fix by review comments * fix by review comments * rebase upstream code * rebase upstream code * fix storage construct error * change uint32_t ttl to uint64_t * change int() to static_cast * fix by xiaoshuai's review comments * fix compile error in debug mode * fix slot_indexer by review comments * fix by xiaoshuai's review comments * fix dynamic change ttl and periodic_seconds * define CRCU32 type * change uint64_t to int64_t to support nagative time ttl * fix cache list error in floyd * fix by yuge's review comments * change shared_ptr to unique_ptr to be consisten with pikiwidb --------- Co-authored-by: wangshaoyi <[email protected]>
* feat: add floyd (#2347) * floyd: refactor storage to support multi rocksdb instance && todis key format --------- Co-authored-by: wangshaoyi <[email protected]> * fix floyd keys (#2364) Co-authored-by: wuxianrong <[email protected]> * floyd rebase unstable branch * fix by review comments --------- Co-authored-by: wangshaoyi <[email protected]> Co-authored-by: Mixficsol <[email protected]> Co-authored-by: wuxianrong <[email protected]>
* feat: add floyd (OpenAtomFoundation#2347) * floyd: refactor storage to support multi rocksdb instance && todis key format --------- Co-authored-by: wangshaoyi <[email protected]> * fix floyd keys (OpenAtomFoundation#2364) Co-authored-by: wuxianrong <[email protected]> * floyd rebase unstable branch * fix by review comments --------- Co-authored-by: wangshaoyi <[email protected]> Co-authored-by: Mixficsol <[email protected]> Co-authored-by: wuxianrong <[email protected]>
* feat: add floyd (OpenAtomFoundation#2347) * floyd: refactor storage to support multi rocksdb instance && todis key format --------- Co-authored-by: wangshaoyi <[email protected]> * fix floyd keys (OpenAtomFoundation#2364) Co-authored-by: wuxianrong <[email protected]> * floyd rebase unstable branch * fix by review comments --------- Co-authored-by: wangshaoyi <[email protected]> Co-authored-by: Mixficsol <[email protected]> Co-authored-by: wuxianrong <[email protected]>
数据在rocksdb存储格式参考todis实现,增加了保留字段用于后续扩展。
与数据类型相关的,Compactionfilter,compactrange,comparator,key/value encode/decode逻辑的修改。
单个pika进程拆分多个rocksdb实例。
修改pika层代码,兼容storage层代码修改。