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

perf: Reduce loops in when clean queue in BroadcastHub #1628

Merged
merged 1 commit into from
Dec 30, 2024

Conversation

He-Pin
Copy link
Member

@He-Pin He-Pin commented Dec 28, 2024

Motivation:
refs: #1627

Modification:
Reduce the loop count

Result:
Reduce the loop count

@andreaslochbihler-da cc as he is the origin reporter

@He-Pin He-Pin added the t:stream Pekko Streams label Dec 28, 2024
@He-Pin He-Pin added this to the 1.1.3 milestone Dec 28, 2024
@He-Pin He-Pin changed the title chore: Reduce loops in when clean queue in BroadcastHub perf: Reduce loops in when clean queue in BroadcastHub Dec 28, 2024
@He-Pin
Copy link
Member Author

He-Pin commented Dec 28, 2024

it's better not to change the code in unblockIfPossible to

        var upToOffset = head
        while (consumerWheel(upToOffset & WheelMask).isEmpty) {
          upToOffset += 1
          unblocked = true
        }
        if (upToOffset != head) {
          cleanQueueInRange(head, upToOffset)
          head = upToOffset
        }

@pjfanning
Copy link
Contributor

Can we keep this till v1.2.0? We've had a couple of breaks due to optimisations like this.

@pjfanning pjfanning modified the milestones: 1.1.3, 1.2.0 Dec 28, 2024
@He-Pin
Copy link
Member Author

He-Pin commented Dec 28, 2024

I'm not sure if this should be marked as a bug or not.

while (head != finalOffset) {
queue(head & Mask) = null
head += 1
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Which can loop many times

Copy link
Contributor

@pjfanning pjfanning left a comment

Choose a reason for hiding this comment

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

lgtm

@He-Pin
Copy link
Member Author

He-Pin commented Dec 30, 2024

@pjfanning I want to backport to 1.1.x too, wdyt

@He-Pin He-Pin merged commit 9596ea4 into apache:main Dec 30, 2024
8 checks passed
@He-Pin He-Pin deleted the broadcastHub branch December 30, 2024 05:05
He-Pin added a commit to He-Pin/incubator-pekko that referenced this pull request Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t:stream Pekko Streams
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants