-
Notifications
You must be signed in to change notification settings - Fork 35
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
Compact definitions during runtime #571
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
src/lavinmq/vhost.cr
Outdated
@@ -19,6 +19,8 @@ module LavinMQ | |||
include SortableJSON | |||
include Stats | |||
|
|||
DEFINITIONS_DIRT_COMPACT_THREASHOLD = 10_000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's make it a config variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and call it deletes_compacts_definitions
? as in "100 'delete' operations compacts the definition file"
src/lavinmq/vhost.cr
Outdated
# By doing equality comparision we'll only start one fiber | ||
# without having to keep track if it's started or not | ||
if @definitions_dirt_counter == DEFINITIONS_DIRT_COMPACT_THREASHOLD | ||
spawn(name: "VHost #{name} definitions compact") { compact! } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why in a separate fiber? makes it potentially thread unsafe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think one reason was that store_definition
is called from a @definitions_lock.synchronize
context, and that compact!
also want the lock, and the other was to not block the current fiber with this (even though it's probably fast, and it will block by holding the lock).
With high churns (e.g. tons of shortlived queues) the definitions file can grow indefinitely. This will add compactation every 10000th "delete" frame. (10k was chosen completley arbitrary.)
d955928
to
9a03fa4
Compare
WHAT is this pull request doing?
With high churns (e.g. tons of short-lived queues) the definitions file can grow indefinitely. This will add compaction every 10000th "delete" frame. (10k was chosen completely arbitrary.)
HOW can this pull request be tested?
Run specs, or launch lavinmq and create and delete a queue more than 10k times.