-
Notifications
You must be signed in to change notification settings - Fork 5k
avoid cpu occupied #33465
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
avoid cpu occupied #33465
Conversation
Summary of ChangesHello @yihaoDeng, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on improving the stability and resource management of character set conversion operations. It introduces a retry limit to prevent the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request aims to prevent high CPU usage in taosAcquireConv by introducing a retry limit to a busy-wait loop. While this is a good step, the change is incomplete. A second busy-wait loop in the same function remains, which can still lead to 100% CPU utilization under contention. I have raised a critical issue about this incomplete fix. I also have a minor suggestion to improve code maintainability by replacing a magic number with a named constant. The related change to increase the converter pool size in tconv.c seems appropriate.
source/os/src/osString.c
Outdated
| } | ||
|
|
||
| int32_t startId = taosGetSelfPthreadId() % info->gConvMaxNum[type]; | ||
| int32_t startId = (uint32_t)(taosGetSelfPthreadId()) % info->gConvMaxNum[type]; |
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.
While this pull request aims to prevent high CPU usage by adding a retry limit to the first while loop, the while (true) loop immediately following this line (starting on line 403) remains a busy-wait loop without any yielding mechanism or retry limit. If all converters happen to be in use, this loop will spin indefinitely and consume an entire CPU core, defeating the purpose of this PR.
To fully resolve the CPU occupation issue, this second loop must also be modified. A simple fix would be to add a sched_yield() call within the loop to prevent it from hogging the CPU, for instance after a full scan of all converters without finding a free one.
| return (iconv_t)NULL; | ||
| } | ||
|
|
||
| int32_t retryLimit = 100, i = 0; |
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.
Description
Please briefly describe the code changes in this pull request.
Checklist
Please check the items in the checklist if applicable.