-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(tiering): Basic stash backpressure #5973
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e93c53e
fix(tiering): Basic stash backpressure
dranikpg 4f1283f
fixes
dranikpg a549dde
more fixes
dranikpg b5f7858
Merge branch 'main' into stash-backpressure
dranikpg d44bc8b
small fixes
dranikpg 622705d
Apply suggestion from @Copilot
romange 49d0a76
Apply suggestion from @Copilot
romange 0eda36e
Make timeout 5ms
dranikpg e9d1006
Merge branch 'main' into stash-backpressure
dranikpg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| #include "server/common.h" | ||
| #include "server/table.h" | ||
| #include "server/tiering/common.h" | ||
| #include "server/tiering/entry_map.h" | ||
| #include "server/tx_base.h" | ||
| #include "util/fibers/future.h" | ||
|
|
||
|
|
@@ -59,9 +60,10 @@ class TieredStorage { | |
| TResult<T> Modify(DbIndex dbid, std::string_view key, const PrimeValue& value, | ||
| std::function<T(std::string*)> modf); | ||
|
|
||
| // Stash value. Sets IO_PENDING flag and unsets it on error or when finished | ||
| // Returns true if item was scheduled for stashing. | ||
| bool TryStash(DbIndex dbid, std::string_view key, PrimeValue* value); | ||
| // Stash value. Sets IO_PENDING flag and unsets it on error or when finished. | ||
| // Returns optional future for backpressure if `provide_bp` is set and conditions are met. | ||
| std::optional<util::fb2::Future<bool>> TryStash(DbIndex dbid, std::string_view key, | ||
| PrimeValue* value, bool provide_bp = false); | ||
|
|
||
| // Delete value, must be offloaded (external type) | ||
| void Delete(DbIndex dbid, PrimeValue* value); | ||
|
|
@@ -105,6 +107,9 @@ class TieredStorage { | |
|
|
||
| PrimeTable::Cursor offloading_cursor_{}; // where RunOffloading left off | ||
|
|
||
| // Stash operations waiting for completion to throttle | ||
| tiering::EntryMap<::util::fb2::Future<bool>> stash_backpressure_; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Either a future or... a blocking counter? I don't see how we can easily use something more lightweight |
||
|
|
||
| std::unique_ptr<ShardOpManager> op_manager_; | ||
| std::unique_ptr<tiering::SmallBins> bins_; | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // Copyright 2025, DragonflyDB authors. All rights reserved. | ||
| // See LICENSE for licensing terms. | ||
| // | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <absl/container/flat_hash_map.h> | ||
|
|
||
| #include <string> | ||
|
|
||
| #include "server/tx_base.h" | ||
|
|
||
| namespace dfly::tiering { | ||
|
|
||
| namespace detail { | ||
| struct Hasher { | ||
| using is_transparent = void; | ||
| template <typename S> size_t operator()(const std::pair<DbIndex, S>& p) const { | ||
| return absl::HashOf(p); | ||
| } | ||
| }; | ||
|
|
||
| struct Eq { | ||
| using is_transparent = void; | ||
| template <typename S1, typename S2> | ||
| bool operator()(const std::pair<DbIndex, S1>& l, const std::pair<DbIndex, S2>& r) const { | ||
| const auto& [i1, s1] = l; | ||
| const auto& [i2, s2] = r; | ||
| return i1 == i2 && s1 == s2; | ||
| } | ||
| }; | ||
| } // namespace detail | ||
|
|
||
| // Map of key (db index, string key) -> T with heterogeneous lookup | ||
| template <typename T> | ||
| using EntryMap = | ||
| absl::flat_hash_map<std::pair<DbIndex, std::string>, T, detail::Hasher, detail::Eq>; | ||
|
|
||
| } // namespace dfly::tiering |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.