-
Notifications
You must be signed in to change notification settings - Fork 39
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
Votes cache #1852
Votes cache #1852
Conversation
} | ||
votes_cache_.put(msg); | ||
|
||
if (not info.has_value() or not info->set_id.has_value() |
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.
Copy of line 953. Need to remove it
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.
At least info is used before the definition
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.
No problem, in the line 952 it might be rewritten.
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.
It got here accidentally. Fixed now
@@ -295,6 +296,8 @@ namespace kagome::consensus::grandpa { | |||
*/ | |||
void loadMissingBlocks(GrandpaContext &&grandpa_context); | |||
|
|||
const size_t kVotesCacheSize |
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.
Where is the value? What it equals to? Where is a semicolon at least?
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.
Looks malformed
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.
Fixed
} | ||
return false; | ||
} | ||
} // namespace kagome::consensus::grandpa |
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.
No line break at the end. Please add
private: | ||
LruCache<RoundNumber, std::unordered_set<VotesCacheItem>> lru_cache_; | ||
}; | ||
} // namespace kagome::consensus::grandpa |
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.
No line break at the end. Please add
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.
Look at another solution: use
std::set<std::tuple<set_id, round_number, hash<Vote>, hash<Vote>>
instead LRU
if (cache.size() > threshold) {
pop(begin());
}
@@ -295,6 +296,8 @@ namespace kagome::consensus::grandpa { | |||
*/ | |||
void loadMissingBlocks(GrandpaContext &&grandpa_context); | |||
|
|||
const size_t kVotesCacheSize |
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.
Looks malformed
std::size_t operator()( | ||
const kagome::consensus::grandpa::VotesCacheItem &item) const { | ||
return std::hash<size_t>()(item.type) | ||
^ std::hash<kagome::consensus::grandpa::Id>()(item.id) |
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.
Please, use boost::hash_combine
instead xor
Id id; | ||
primitives::BlockHash block_hash; | ||
|
||
bool operator==(const VotesCacheItem &rhs) const { |
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.
auto operator<=>(const VotesCacheItem &rhs) const = default;
would be enough
bdc508b
to
800debc
Compare
# Conflicts: # core/consensus/grandpa/impl/grandpa_impl.cpp
|
||
void put(const VoteMessage &msg); | ||
|
||
bool contains(VoteMessage msg); |
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.
It seems the argument could be const&
.
[[relaychain.nodes]] | ||
name = "two" | ||
|
||
#[[parachains]] |
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.
Please either add a comment explaining when and how to use the disabled config or remove it.
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.
oops, sorry. Committed accidentally
9f9eb4b
to
1e61de7
Compare
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.
Rejecting changes to prevent auto merge before confirming the changes in peer_manager_impl.cpp
.
const auto &peer_id = peers_list.back().second; | ||
disconnectFromPeer(peer_id); | ||
} | ||
// for (; !peers_list.empty() |
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.
Most likely this is unintended change.
86f2dc5
to
1e61de7
Compare
Referenced issues
None
Description of the Change
Introduces vote message cache to avoid processing of the same vote twice.
Benefits
Cache hit rate 94%
Possible Drawbacks
None