Skip to content

Sort entry pointers in convertToBucketEntry. - #5291

Merged
graydon merged 1 commit into
stellar:masterfrom
dmkozh:entry_sort
May 30, 2026
Merged

graydon merged 1 commit into
stellar:masterfrom
dmkozh:entry_sort

Conversation

@dmkozh

@dmkozh dmkozh commented May 23, 2026

Copy link
Copy Markdown
Contributor

Description

Sort entry pointers in convertToBucketEntry.

This avoids O(n log n) swaps of potentially large structs.

Checklist

  • Reviewed the contributing document
  • Rebased on top of master (no merge commits)
  • Ran clang-format v8.0.0 (via make format or the Visual Studio extension)
  • Compiles
  • Ran all tests
  • If change impacts performance, include supporting evidence per the performance document

Copilot AI review requested due to automatic review settings May 23, 2026 00:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates LiveBucket::convertToBucketEntry to sort pointers to BucketEntry objects (rather than sorting the BucketEntry objects themselves), aiming to reduce the cost of std::sort swapping large structs during bucket creation in Stellar Core’s bucket subsystem.

Changes:

  • Build an unsorted entries vector of BucketEntry objects and a parallel vector of pointers to those objects.
  • Sort the pointer vector using the existing BucketEntryIdCmp<LiveBucket> comparator.
  • Materialize the final sorted bucket vector by moving elements in sorted pointer order.

Comment thread src/bucket/LiveBucket.cpp Resolved
This avoids O(n log n) swaps of potentially large structs.
@dmkozh
dmkozh requested a review from SirTyson May 29, 2026 17:12
@graydon
graydon added this pull request to the merge queue May 30, 2026
Merged via the queue into stellar:master with commit 2be407a May 30, 2026
54 checks passed
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.

3 participants