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

server/book: automatic book reallocation #794

Merged
merged 1 commit into from Nov 9, 2020

Conversation

chappjc
Copy link
Member

@chappjc chappjc commented Oct 28, 2020

This hides the notion of capacity from Book consumers by creating a book with modestly-sized buy/sell priority queues instead of the mammoth defaults of before, and the underlying OrderPQs automatically reallocate into a larger queue when Inserts push the queue to capacity.

The queue increases by the larger of minCapIncrement (4096) or 1/8th of the current utilization (note that utilization is the same as capacity when realloc is triggered by Insert->Push).

The queue will also automatically reallocate to a smaller capacity when Extract*/Remove*/Pop reduces the utilization of the queue to a point where the ideal capacity is significantly below the current capacity, specifically savings > deallocThresh && savings > pq.capacity/3 where deallocThresh = 10 * minCapIncrement.

@chappjc chappjc added this to the 0.2.0 milestone Oct 29, 2020
Copy link
Member

@buck54321 buck54321 left a comment

Choose a reason for hiding this comment

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

Couple little questions, but looks good. Fewer levers and less duplication.

server/book/book.go Outdated Show resolved Hide resolved
server/book/book.go Show resolved Hide resolved
server/book/orderpq.go Show resolved Hide resolved
server/book/orderpq_test.go Show resolved Hide resolved
@chappjc chappjc merged commit 3750cce into decred:master Nov 9, 2020
@chappjc chappjc deleted the auto-realloc-order-pq branch November 9, 2020 15:10
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.

None yet

2 participants