Skip to content

rhythm: fair partition consumption#4655

Merged
javiermolinar merged 14 commits intografana:mainfrom
javiermolinar:rhythm-weighted-partition-fetching
Feb 21, 2025
Merged

rhythm: fair partition consumption#4655
javiermolinar merged 14 commits intografana:mainfrom
javiermolinar:rhythm-weighted-partition-fetching

Conversation

@javiermolinar
Copy link
Copy Markdown
Contributor

@javiermolinar javiermolinar commented Feb 3, 2025

What this PR does:

The current loop has two drawbacks. The first one is that it keeps consuming from a single partition while it has a record, neglecting the others. This is not a problem right now since every blockbuilder is in charge of a single partition. The second problem is the main run loop; after consuming a complete cycle (that can take much more than the consuming cycle due to the first drawback), it waits another fixed time, incrementing the lag.

This PR tries to tackle this by first prioritizing the partitions with more lag. For that, we get first the lag in time for every partition. We continue consuming from the laggiest partition until the lag is less than the cycle time.

The number of FetchOffsetsForTopics and ListEndOffsets requests has been reduced now to only one request per cycle instead of one request for every partition cycle

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@javiermolinar javiermolinar changed the title rhythm: weighted partition consumption rhythm: fair partition consumption Feb 5, 2025
@knylander-grafana
Copy link
Copy Markdown
Contributor

HI, Javi. You have the docs box checked in the description but I don't see any. Are you working on docs for this?

@javiermolinar
Copy link
Copy Markdown
Contributor Author

HI, Javi. You have the docs box checked in the description but I don't see any. Are you working on docs for this?

My bad, I clicked all of them

Comment thread modules/blockbuilder/blockbuilder.go Outdated
Comment thread modules/blockbuilder/blockbuilder.go Outdated
Comment thread modules/blockbuilder/blockbuilder.go Outdated
Copy link
Copy Markdown
Contributor

@mapno mapno left a comment

Choose a reason for hiding this comment

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

Good changes. I think the PR is going in the right direction 👍

Have some thoughts and nitpicks.

Comment thread modules/blockbuilder/blockbuilder.go Outdated
Comment thread modules/blockbuilder/blockbuilder.go
Comment thread modules/blockbuilder/blockbuilder.go Outdated
Comment thread modules/blockbuilder/blockbuilder.go Outdated
Comment thread modules/blockbuilder/blockbuilder.go
Copy link
Copy Markdown
Contributor

@mapno mapno left a comment

Choose a reason for hiding this comment

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

I'm ok with these changes. I'll approve when this discussion is resolved

Comment thread modules/blockbuilder/blockbuilder.go Outdated
Comment thread modules/blockbuilder/blockbuilder.go Outdated
@mdisibio
Copy link
Copy Markdown
Contributor

+1 changes lgtm but defer to the rest of the team for final approval.

@javiermolinar javiermolinar merged commit 50a9daf into grafana:main Feb 21, 2025
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.

4 participants