Skip to content
This repository has been archived by the owner on Aug 10, 2019. It is now read-only.

Added Heavy Hitter Sketch #91

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open

Conversation

saurav-c
Copy link
Member

No description provided.

@codecov
Copy link

codecov bot commented Apr 13, 2019

Codecov Report

Merging #91 into master will increase coverage by 0.32%.
The diff coverage is 82.43%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
kvs/include/metadata.hpp 53.84% <ø> (ø) ⬆️
kvs/include/kvs_common.hpp 100% <ø> (ø) ⬆️
kvs/src/kvs/replication_response_handler.cpp 2.87% <0%> (-0.07%) ⬇️
kvs/src/kvs/user_request_handler.cpp 63.15% <100%> (+0.49%) ⬆️
kvs/tests/kvs/test_user_request_handler.hpp 100% <100%> (ø) ⬆️
kvs/include/adaptive_heavy_hitters.hpp 77.45% <77.45%> (ø)
kvs/include/heavy_hitters.hpp 96.66% <96.66%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4d1120a...c679386. Read the comment docs.

@saurav-c saurav-c reopened this Apr 30, 2019

for (const auto& key_count : access.keys()) {
Key key = key_count.key();
hot_key_access_frequency[key]
Copy link
Contributor

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?

Copy link
Member

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented out code?

Copy link
Member

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
Copy link
Contributor

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.

Copy link
Member

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++) {
Copy link
Contributor

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>
Copy link
Member

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
Copy link
Member

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;
Copy link
Member

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-typedefed. It's in includes/types.hpp, I think.

class AdaptiveThresholdHeavyHitters {
protected:
HeavyHittersSketch* hh_sketch;
float threshold_percent = 0.01;
Copy link
Member

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;
Copy link
Member

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++) {
Copy link
Member

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
Copy link
Member

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) {
Copy link
Member

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]
Copy link
Member

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) {
Copy link
Member

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants