-
Notifications
You must be signed in to change notification settings - Fork 172
Added Heavy Hitter Sketch #91
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #91 +/- ##
==========================================
+ Coverage 72.69% 73.01% +0.32%
==========================================
Files 68 70 +2
Lines 3065 3202 +137
==========================================
+ Hits 2228 2338 +110
- Misses 837 864 +27
Continue to review full report at Codecov.
|
|
||
for (const auto& key_count : access.keys()) { | ||
Key key = key_count.key(); | ||
hot_key_access_frequency[key] |
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.
Could this be extracted into a method with the cold_key_access_frequency or hoy_key_access_frequency be passed in?
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.
+1
|
||
void reset() { set_values(); }; | ||
|
||
// static void reset_threshold_percent(float new_threshold) { |
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.
commented out code?
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.
+1
// keep track of the keys' access summary | ||
map<Key, unsigned> key_access_summary; | ||
// keep track of the hot keys' access summary |
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.
These comments don't add any value - they state what the code does not why or how etc.
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.
+1
unsigned long hash_key(Key key) { | ||
unsigned long hash = 5381; | ||
int char_int = 0; | ||
for (unsigned i = 0; i < key.length(); i++) { |
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.
can you use the for (key: key type syntax rather than int index
|
||
#include <stdbool.h> | ||
#include <stdio.h> | ||
#include <chrono> |
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.
What are these imports for? Some of them seem unrelated to what you're doing here.
#include <utility> | ||
#include "heavy_hitters.hpp" | ||
|
||
#define alpha 0.2 |
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 is this defined outside of the class and gamma
and epsilon
inside?
|
||
#define alpha 0.2 | ||
|
||
typedef std::string Key; |
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.
This should not be re-typedef
ed. It's in includes/types.hpp
, I think.
class AdaptiveThresholdHeavyHitters { | ||
protected: | ||
HeavyHittersSketch* hh_sketch; | ||
float threshold_percent = 0.01; |
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.
Comments should explain the role of these variables.
std::unordered_map<Key, int> reset_hot_map; | ||
std::unordered_map<Key, int> reset_cold_map; | ||
|
||
total_set = reset_total_set; |
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.
Is this meant to clear the collection? There are methods for doing that.
@@ -76,7 +78,13 @@ void membership_handler( | |||
memory_occupancy.erase(new_server_private_ip); | |||
|
|||
// NOTE: No const here because we are calling erase | |||
for (auto& key_access_pair : key_access_frequency) { | |||
for (auto& key_access_pair : hot_key_access_frequency) { | |||
for (unsigned i = 0; i < kMemoryThreadCount; i++) { |
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 are we only iterating over the hot and cold keys here?
// keep track of the keys' access summary | ||
map<Key, unsigned> key_access_summary; | ||
// keep track of the hot keys' access summary |
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.
+1
// collect external statistics | ||
collect_external_stats(user_latency, user_throughput, ss, log); | ||
|
||
// initialize replication factor for new keys | ||
for (const auto &key_access_pair : key_access_summary) { | ||
for (const auto &key_access_pair : hot_key_access_summary) { |
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.
Again, why are we only iterating over the hot and cold keys here?
|
||
for (const auto& key_count : access.keys()) { | ||
Key key = key_count.key(); | ||
hot_key_access_frequency[key] |
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.
+1
|
||
hot_key_access_summary[key] = access_count; | ||
|
||
if (access_count > 0) { |
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.
Explain this code? Not clear what is happening.
No description provided.