Skip to content

perf: use slices instead of bubblesort#1179

Merged
andrinoff merged 1 commit intofloatpane:masterfrom
Haroka-74:fix/issue-1080
Apr 27, 2026
Merged

perf: use slices instead of bubblesort#1179
andrinoff merged 1 commit intofloatpane:masterfrom
Haroka-74:fix/issue-1080

Conversation

@Haroka-74
Copy link
Copy Markdown
Contributor

@Haroka-74 Haroka-74 commented Apr 27, 2026

What?

Replaced the manual nested loop sorting logic in fetcher/fetcher.go with sort.Slice using a descending UID comparator.

Why?

The previous implementation was quadratic O(n²) on every batch. While the default chunk size of 50 kept this impact minimal, it becomes a dominant cost of the fetch operation when larger limits are used. Moving to sort.Slice provides O(n × log n) performance.

Closes #1080

@Haroka-74 Haroka-74 requested a review from a team as a code owner April 27, 2026 13:15
Copy link
Copy Markdown
Member

@floatpanebot floatpanebot left a comment

Choose a reason for hiding this comment

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

Hi @Haroka-74! Please fix the following issues with your PR:

  • Title: Is too long (61 characters). The PR title must be strictly under 40 characters.

@Haroka-74 Haroka-74 changed the title refactor(fetcher): replace manual O(n^2) sort with sort.Slice refactor(fetcher): use sort.Slice Apr 27, 2026
@floatpanebot floatpanebot dismissed their stale review April 27, 2026 13:16

Formatting issues have been resolved. Thank you!

Copy link
Copy Markdown
Member

@andrinoff andrinoff left a comment

Choose a reason for hiding this comment

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

lgtm

@andrinoff andrinoff changed the title refactor(fetcher): use sort.Slice chore: use sort.Slice instead of bubblesort Apr 27, 2026
Copy link
Copy Markdown
Member

@floatpanebot floatpanebot left a comment

Choose a reason for hiding this comment

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

Hi @andrinoff! Please fix the following issues with your PR:

  • Title: Is too long (43 characters). The PR title must be strictly under 40 characters.

@andrinoff andrinoff changed the title chore: use sort.Slice instead of bubblesort perf: use slices instead of bubblesort Apr 27, 2026
@floatpanebot floatpanebot dismissed their stale review April 27, 2026 14:49

Formatting issues have been resolved. Thank you!

@andrinoff
Copy link
Copy Markdown
Member

/approve

Copy link
Copy Markdown
Member

@floatpanebot floatpanebot left a comment

Choose a reason for hiding this comment

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

Approved on behalf of @andrinoff via /approve command.

@andrinoff andrinoff merged commit 42f2417 into floatpane:master Apr 27, 2026
24 of 26 checks passed
@Haroka-74 Haroka-74 deleted the fix/issue-1080 branch April 27, 2026 16:06
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.

BUG: O(n²) bubble sort in fetcher batch ordering

3 participants