-
Notifications
You must be signed in to change notification settings - Fork 107
Fix high CPU usage #300
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
Fix high CPU usage #300
Conversation
@report_with_backoff(reporter_name='segment', init_wait=0.02) | ||
def __report_segment(self) -> bool: | ||
"""Returns True if the queue is not empty""" | ||
queue_not_empty_flag = not self.__segment_queue.empty() |
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.
reportOptionalMemberAccess: "empty" is not a known member of "None"
ℹ️ Expand to see all @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
Command | Usage |
---|---|
@sonatype-lift ignore |
Leave out the above finding from this PR |
@sonatype-lift ignoreall |
Leave out all the existing findings from this PR |
@sonatype-lift exclude <file|issue|path|tool> |
Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file |
Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Help us improve LIFT! (Sonatype LiftBot external survey)
Was this a good recommendation for you? Answering this survey will not impact your Lift settings.
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
LGTM! I will kick off a release tomorrow if no objections. |
@kezhenxu94 FYI, as you also encountered this problem in 1.0.0 |
Are you going to cherry pick patches to do 1.0.1? |
Yes, since its a patch version I will cherry pick them to do 1.0.1. Gonna figure out how to do that properly. |
You should create |
I see, will do! |
About high CPU usage bug discussed in issues#10672, my final solution was to set the
init_wait
parameter in the function decorator to 0.02 (20 ms). In addition, I also made additional changes to make the thread delay more reasonable and closer to the implementation of Java agent.For the segment/log reporting function, I added a return value of bool type, which is only used by the
@report_with_backoff
decorator to determine whether the queue is not empty. If the queue is not empty, the thread will report the data immediately without any waiting; otherwise, the thread will wait for 20ms to release the CPU usage.For other types of reporting functions, since their return value is always None, the function decorator still operates according to the original logic
I think the above changes balance the two solutions proposed by issues#10672 and make it more similar to the Java agent implementation
Fix
CHANGELOG.md
.