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

Reduce unnecessary loop in removeIf if map is empty #3512

Merged

Conversation

Shawyeok
Copy link
Contributor

Motivation

After unload all bundles of a heavy pulsar broker, cpu usage is still above 50%, here is a cpu profile and a heapdump
image
image

It looks like there's a schedule task executing BookieClientImpl#monitorPendingOperations.

Most of completionObjects in PerChannelBookieClient are empty.

IMO, it's worth to check whether a section is empty or not in loop predication.

Changes

Add size > 0 into Section#removeIf loop predication.

Copy link
Contributor

@StevenLuMT StevenLuMT left a comment

Choose a reason for hiding this comment

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

LGTM

@StevenLuMT
Copy link
Contributor

rerun failure checks

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

LGTM

@zymap zymap assigned Shawyeok and unassigned zymap Oct 8, 2022
@zymap zymap added this to the 4.16.0 milestone Oct 8, 2022
@StevenLuMT StevenLuMT merged commit bc87bfb into apache:master Oct 8, 2022
zymap pushed a commit that referenced this pull request Oct 26, 2022
Reduce unnecessary loop in removeIf if section is empty

(cherry picked from commit bc87bfb)
hangc0276 pushed a commit to hangc0276/bookkeeper that referenced this pull request Nov 7, 2022
Reduce unnecessary loop in removeIf if section is empty

(cherry picked from commit bc87bfb)
hangc0276 pushed a commit to hangc0276/bookkeeper that referenced this pull request Nov 7, 2022
Reduce unnecessary loop in removeIf if section is empty

(cherry picked from commit bc87bfb)
nicoloboschi pushed a commit to datastax/bookkeeper that referenced this pull request Jan 11, 2023
Reduce unnecessary loop in removeIf if section is empty

(cherry picked from commit bc87bfb)
(cherry picked from commit b60c677)
Ghatage pushed a commit to sijie/bookkeeper that referenced this pull request Jul 12, 2024
Reduce unnecessary loop in removeIf if section is empty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants