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

get and set counts #2944

Closed
wants to merge 0 commits into from
Closed

get and set counts #2944

wants to merge 0 commits into from

Conversation

shuaihehe
Copy link
Contributor

What problem does this PR solve?

Issue Number: #2841

Problem Summary: Get和Set方法会加到线程池,大量Get和Set的情况下线程池里的任务会大量堆积,这里使用bvar变量对线程池里的Get和Set进行计数。

What is changed and how it works?

What's Changed:
client_metric.h:结构体KVClientManagerMetric中增加了两个bvar变量(getQueueSize和setQueueSize)分别用来对Get和Set计数。
kvclient_manager.cpp:在类KVClientManager的Get和Set方法里改变bvar变量的值。

How it Works: 任务加入到线程池,对bvar变量进行+1操作,任务结束,bvar变量及时-1。

Side effects(Breaking backward compatibility? Performance regression?): 无

Check List

  • Relevant documentation/comments is changed or added
  • I acknowledge that all my contributions will be made under the project's license

@shuaihehe
Copy link
Contributor Author

curve01

@shuaihehe
Copy link
Contributor Author

shuaihehe commented Dec 5, 2023

通过以下步骤将指标增加:

  1. 根据client.yaml文件的配置创建文件系统并挂载到目录/root/filesyatem下
  2. 在目录/root/filesyatem下创建test.txt文件
  3. 使用python程序向test.txt文件中不断写入大量字符串,查看指标变化;停止python程序,使用tail命令查看test.txt文件中的内容,再次查看指标变化,指标变化如下图:
    11
    22

@Ziy1-Tan
Copy link
Contributor

Ziy1-Tan commented Dec 5, 2023

cicheck

@Ziy1-Tan Ziy1-Tan self-requested a review December 5, 2023 07:35
Copy link
Contributor

@Ziy1-Tan Ziy1-Tan left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -64,8 +64,10 @@ void KVClientManager::Uninit() {
void KVClientManager::Set(std::shared_ptr<SetKVCacheTask> task) {
threadPool_.Enqueue([task, this]() {
std::string error_log;
kvClientManagerMetric_->setQueueSize << 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

when enqueue, the setQueueSize should plus one. So the code kvClientManagerMetric_->setQueueSize << 1should be in front of threadPool_.Enqueue([task, this]() {}

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.

3 participants