-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(snapshot): Replace sleeps with yield #5619
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
base: main
Are you sure you want to change the base?
Conversation
src/server/engine_shard.cc
Outdated
fb2::Fiber::Opts fb_opts{.priority = fb2::FiberPriority::BACKGROUND, .name = "heatbeat"}; | ||
fiber_heartbeat_periodic_ = | ||
MakeFiber([this, index = pb->GetPoolIndex(), period_ms, heartbeat]() mutable { | ||
fb2::Fiber(fb_opts, [this, index = pb->GetPoolIndex(), period_ms, heartbeat]() mutable { |
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.
- Heartbeat should be background
- If its background, it doesn't penalize other background fibers on idle
- We can split it into stages to increase simplicity and have dynamic load on it
src/server/snapshot.cc
Outdated
// Yield after possibly long cpu slice due to compression and serialization | ||
if (ThisFiber::Priority() == fb2::FiberPriority::BACKGROUND) | ||
ThisFiber::Yield(); | ||
// TODO: else Sleep() to provide write backpressure in advance? |
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.
Previously we yielded after the write, now we yield before because that's the end of the "CPU" slice (that the scheduler masures). There shoudn't be any difference as long as writes are not async (not sure why we didn't add that yet) 🤔
@@ -164,8 +164,11 @@ class SliceSnapshot : public journal::JournalConsumerInterface { | |||
|
|||
// Used for sanity checks. | |||
bool serialize_bucket_running_ = false; | |||
|
|||
std::string snapshot_fb_name_; |
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.
helio fiber stores a string view, previously it pointed just to a stack placed string 😳
Will fix heartbeat after romange/helio#449 |
6925b6d
to
e3946d5
Compare
Please rebase. Is it ready for review @dranikpg ? |
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
e3946d5
to
c96b31f
Compare
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
Blocked on new background fibers from helio romange/helio#402.
Background tasks should be as cooperative as possible to not increase the latency. We yield after each bucket traversal either by pushing to the channel or by yielding explicitly