Skip to content

Conversation

@dingxiaoshuai123
Copy link
Collaborator

@dingxiaoshuai123 dingxiaoshuai123 commented Nov 24, 2023

issue : #2085
issue : #2174

1 separation of fast and slow commands
2 modify the codis proxy & pika
3 add slow command queue and slow command thread pool in pika

@dingxiaoshuai123 dingxiaoshuai123 force-pushed the split_fast_slow_cmd_codis branch from 1aeb603 to daa8a12 Compare November 24, 2023 04:57
@dingxiaoshuai123 dingxiaoshuai123 changed the title separation of fast and slow commands feat : separation of fast and slow commands Nov 24, 2023
@dingxiaoshuai123 dingxiaoshuai123 changed the title feat : separation of fast and slow commands feat:separation of fast and slow commands Nov 24, 2023
@github-actions github-actions bot added the ✏️ Feature New feature or request label Nov 24, 2023
@dingxiaoshuai123 dingxiaoshuai123 force-pushed the split_fast_slow_cmd_codis branch from daa8a12 to f9ed848 Compare November 24, 2023 05:16
type sharedBackendConnPool struct {
config *Config
parallel int
quick int
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

补充注释

backend_primary_parallel = 1
backend_replica_parallel = 1
backend_primary_parallel = 2
backend_primary_quick = 1
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

补充注释

opTable[r.Name] = r
}

if cmdlist == "" {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

调用len判断字符串为空

conf/pika.conf Outdated

# Size of the low level thread pool, The threads within this pool
# are dedicated to handling slow user requests.
low-level-thread-pool-size : 4
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

改为slowcmdthreadpool

} else if (set_item == "slow-cmd-list") {
g_pika_conf->SetSlowCmd(value);
ret = "+OK\r\n";
}else if (set_item == "max-cache-files") {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

空格

@AlexStocks
Copy link
Contributor

todo:
1 seperate the read and write command;
2 elastic the slow command thread pool

@dingxiaoshuai123 dingxiaoshuai123 force-pushed the split_fast_slow_cmd_codis branch from 1958837 to 859ea43 Compare November 29, 2023 04:55
int d2string(char* buf, size_t len, double value);
int string2d(const char* s, size_t slen, double* dval);
std::vector<std::string>& StringSplit(const std::string& s, char delim, std::vector<std::string>& elems);
void StringSplit2Set(const std::string&s, char delim, std::unordered_set<std::string>& elems);
Copy link
Collaborator

Choose a reason for hiding this comment

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

elems这个换成 * 把,一般需要修改的值的用引用+const修饰,需要修改值的用 *

int d2string(char* buf, size_t len, double value);
int string2d(const char* s, size_t slen, double* dval);
std::vector<std::string>& StringSplit(const std::string& s, char delim, std::vector<std::string>& elems);
void StringSplit2Set(const std::string&s, char delim, std::unordered_set<std::string>& elems);
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个delim也尽量不要值传递把,看下用指针还是引用

Mixficsol
Mixficsol previously approved these changes Dec 4, 2023
// Print the current low level queue size if it exceeds QUEUE_SIZE_THRESHOLD_PERCENTAGE/100 of the maximum queue size.
size_t low_level_queue_cur_size = LowLevelThreadPoolCurQueueSize();
size_t low_level_queue_max_size = LowLevelThreadPoolMaxQueueSize();
size_t low_level_queue_thread_hold = (low_level_queue_max_size / 100) * QUEUE_SIZE_THRESHOLD_PERCENTAGE;
Copy link
Collaborator

Choose a reason for hiding this comment

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

变量名是想写low_level_queue_thresh_hold?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

这里的名字都要改成slow_cmd相关,下次提交的时候改

if quick := s.owner.quick; quick > 0 {
if isQuick {
i = seed % uint(quick)
if bc := parallel[i]; bc.IsConnected() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个地方,原来是在一个循环里,如果一个bc无效会继续找下一个,这里是不是也该加一下。

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

这里传入的seed是用key做的hash,为了保证pipeline中相同key的有序,所以没有找下一个连接。之前不知道为什么是进行了遍历,所以新添加的代码没有进行循环找conn

FlagMasterOnly
FlagMayWrite
FlagNotAllow
FlagQuick
Copy link
Collaborator

Choose a reason for hiding this comment

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

Quick和Slow不是互斥的吗?需要两个都定义吗?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

理论上只需要FlagSlow即可,但是为了简化一些逻辑就加了个FlagQuick,这样在一些打印快慢列表的函数中逻辑更清晰点,不需要的话删除也行

@AlexStocks
Copy link
Contributor

继续改进下,解决下文件冲突

@dingxiaoshuai123 dingxiaoshuai123 force-pushed the split_fast_slow_cmd_codis branch 4 times, most recently from 62d84fa to 8df24fc Compare December 21, 2023 07:30
@github-actions github-actions bot added the 📒 Documentation Improvements or additions to documentation label Dec 21, 2023
@dingxiaoshuai123 dingxiaoshuai123 force-pushed the split_fast_slow_cmd_codis branch from 8df24fc to ceb4cff Compare December 21, 2023 07:36
@dingxiaoshuai123 dingxiaoshuai123 force-pushed the split_fast_slow_cmd_codis branch 4 times, most recently from bb78f5f to 719192d Compare December 21, 2023 08:25
@dingxiaoshuai123 dingxiaoshuai123 force-pushed the split_fast_slow_cmd_codis branch from 719192d to c44ba2d Compare December 21, 2023 08:26
}
}
return s.backend.bc.BackendConn(database, seed, true)
// fix:https://github.com/OpenAtomFoundation/pika/issues/2174
Copy link
Collaborator

Choose a reason for hiding this comment

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

这行去掉吧 可以放在comment中

flagString := "FlagQuick"
if flag&FlagSlow != 0 {
reverseFlag = FlagQuick
flagString = "FlagSlow"
Copy link
Collaborator

Choose a reason for hiding this comment

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

为啥FlagQuick 没有引号 FlagSlow有引号 这是有什么特殊的考虑吗

@AlexStocks AlexStocks merged commit c1917c7 into OpenAtomFoundation:unstable Jan 18, 2024
bigdaronlee163 pushed a commit to bigdaronlee163/pika that referenced this pull request Jun 8, 2024
* split fast and slow cmd in codis

* separation of fast and slow commands

* Resolve formatting issues.

* use the unordered_set instead of unordered_map

* fix:disorderly execution of the same key when using pipeline

* update go 1.18 to go 1.21

* change proxy.go & mapper.go
cheniujh pushed a commit to cheniujh/pika that referenced this pull request Sep 24, 2024
* split fast and slow cmd in codis

* separation of fast and slow commands

* Resolve formatting issues.

* use the unordered_set instead of unordered_map

* fix:disorderly execution of the same key when using pipeline

* update go 1.18 to go 1.21

* change proxy.go & mapper.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.5.3 📒 Documentation Improvements or additions to documentation enhancement ✏️ Feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants