Skip to content
Snippets Groups Projects
Commit c534f2c7 authored by Jonathan Mace's avatar Jonathan Mace
Browse files

Repository cleanup - remove dead legacy code

parent 0f1232aa
Branches main
No related tags found
No related merge requests found
...@@ -143,8 +143,6 @@ char* hindsight_serialize(); ...@@ -143,8 +143,6 @@ char* hindsight_serialize();
void hindsight_deserialize(char* baggage); void hindsight_deserialize(char* baggage);
int hindsight_payload();
float hindsight_retroactive_sampling_percentage(); float hindsight_retroactive_sampling_percentage();
float hindsight_head_sampling_probability(); float hindsight_head_sampling_probability();
......
...@@ -43,19 +43,6 @@ void tracestate_begin(TraceState* trace, BufManager* mgr, uint64_t trace_id) { ...@@ -43,19 +43,6 @@ void tracestate_begin(TraceState* trace, BufManager* mgr, uint64_t trace_id) {
tracestate_begin_with_sampling(trace, mgr, trace_id, 0, UINT64_MAX); tracestate_begin_with_sampling(trace, mgr, trace_id, 0, UINT64_MAX);
} }
// TODO: Merge this with tracestate_begin_with_sampling
void tracestate_begin_sampling(TraceState* trace,
BufManager* mgr,
uint64_t trace_id,
int sample_rate) {
if(trace_id % 10000000 > 10000000 / sample_rate) {
trace->active = false;
trace->header.trace_id = trace_id;
return;
}
tracestate_begin(trace, mgr, trace_id);
}
void tracestate_begin_with_sampling(TraceState* trace, BufManager* mgr, uint64_t trace_id, uint64_t head_sampling_threshold, uint64_t retroactive_sampling_threshold) { void tracestate_begin_with_sampling(TraceState* trace, BufManager* mgr, uint64_t trace_id, uint64_t head_sampling_threshold, uint64_t retroactive_sampling_threshold) {
if (trace->active) { if (trace->active) {
// If the trace ID is the same, ignore this call // If the trace ID is the same, ignore this call
...@@ -186,4 +173,4 @@ bool tracestate_try_write(TraceState* trace, ...@@ -186,4 +173,4 @@ bool tracestate_try_write(TraceState* trace,
char* buf, char* buf,
size_t buf_size) { size_t buf_size) {
return trace->recording && buffer_try_write_all(&trace->buffer, buf, buf_size); return trace->recording && buffer_try_write_all(&trace->buffer, buf, buf_size);
} }
\ No newline at end of file
...@@ -35,9 +35,6 @@ TraceState tracestate_create(); ...@@ -35,9 +35,6 @@ TraceState tracestate_create();
// This call will always enable retroactive sampling, and will never apply head-sampling // This call will always enable retroactive sampling, and will never apply head-sampling
void tracestate_begin(TraceState* trace, BufManager* mgr, uint64_t trace_id); void tracestate_begin(TraceState* trace, BufManager* mgr, uint64_t trace_id);
// TODO: Merge this with tracestate_begin_with_sampling
void tracestate_begin_sampling(TraceState* trace, BufManager* mgr, uint64_t trace_id, int sample_rate);
// Version of tracestate_begin that will potentially not sample the trace if retroactive_sampling_percentage is set // Version of tracestate_begin that will potentially not sample the trace if retroactive_sampling_percentage is set
// This call will only start a trace if trace_id <= retroactive_sampling_threshold // This call will only start a trace if trace_id <= retroactive_sampling_threshold
void tracestate_begin_with_sampling(TraceState* trace, BufManager* mgr, uint64_t trace_id, uint64_t head_sampling_threshold, uint64_t retroactive_sampling_threshold); void tracestate_begin_with_sampling(TraceState* trace, BufManager* mgr, uint64_t trace_id, uint64_t head_sampling_threshold, uint64_t retroactive_sampling_threshold);
...@@ -66,4 +63,4 @@ bool tracestate_try_write(TraceState* trace, ...@@ -66,4 +63,4 @@ bool tracestate_try_write(TraceState* trace,
#endif // _HINDSIGHT_TRACESTATE_H_ #endif // _HINDSIGHT_TRACESTATE_H_
\ No newline at end of file
...@@ -26,132 +26,4 @@ Triggers triggers_init_existing(const char* name) { ...@@ -26,132 +26,4 @@ Triggers triggers_init_existing(const char* name) {
void triggers_fire(Triggers* t, int trigger_id, uint64_t base_trace_id, uint64_t trace_id) { void triggers_fire(Triggers* t, int trigger_id, uint64_t base_trace_id, uint64_t trace_id) {
Trigger trigger = {trigger_id, base_trace_id, trace_id}; Trigger trigger = {trigger_id, base_trace_id, trace_id};
queue_put_nonblocking(&t->queue, (char*) &trigger); queue_put_nonblocking(&t->queue, (char*) &trigger);
}
TailCounter* tail;
void tail_init(int p) {
tail = malloc(sizeof(TailCounter));
tail->thres = (100-p)*10;
for (int i=0; i<1000; i++) {
tail->queue[i] = 0;
if (i<tail->thres) tail->p[i] = 0;
}
tail->pos = 999;
tail->p_curr = 0;
return;
}
void tail_inject() {
if (rand() % 100 < 10) {
usleep(1000 * (20 + rand() % 10));
printf("Latency injected\n");
}
return;
}
bool tail_latency(uint64_t req_id, int64_t latency) {
// printf("P%d receiving latency %d\n", tail->thres, latency);
tail->pos = (tail->pos+1) % 1000;
int64_t evict = tail->queue[tail->pos];
tail->queue[tail->pos] = latency;
tail->pos++;
// check evict, latency, and p_curr
if (latency <= tail->p_curr) {
if (evict > tail->p_curr) {
int64_t max = 0;
for (int i=0; i<1000; i++) {
if (tail->queue[i] < tail->p_curr && tail->queue[i] > max) max = tail->queue[i];
}
for (int i=0; i<tail->thres; i++)
if (tail->p[i] == evict) {
tail->p[i] = max;
break;
}
tail->p_curr = tail->p[0];
for (int i=0; i<tail->thres; i++) {
if (tail->p_curr > tail->p[i]) tail->p_curr = tail->p[i];
}
}
return false;
} else {
int rep_value = evict > tail->p_curr? evict : tail->p_curr;
for(int i=0; i<tail->thres; i++)
if (tail->p[i] == rep_value) {
tail->p[i] = latency;
break;
}
tail->p_curr = tail->p[0];
for (int i=0; i<tail->thres; i++)
if (tail->p_curr > tail->p[i]) tail->p_curr = tail->p[i];
printf("[TAIL LATENCY] Req: %ld Latency: %ld\n", req_id, latency);
return true;
}
}
void tail_print() {
printf("Curr P%d latency: %ld, pos: %d\n", tail->thres, tail->p_curr, tail->pos);
for (int i=0; i<tail->thres; i++) printf("%ld ", tail->p[i]);
printf("\n");
}
ExceptionHelper* exception;
void exception_init() {
exception = malloc(sizeof(ExceptionHelper));
exception->error_rate = 1;
exception->stage = 0;
exception->request_count = 0;
exception->sampled_count = 0;
exception->last_step = 0;
}
void exception_rate() {
if (exception->last_step == 0) {
exception->last_step = nanos();
exception->stage = 1;
return;
}
// if (exception->active == false) return;
uint64_t dur = nanos() - exception->last_step;
if (dur > 30000000000) {
if (exception->error_rate < 10 && exception->stage < 10)
exception->error_rate++;
else if (exception->stage == 14 || exception->stage == 15)
exception->error_rate = 10;
else
exception->error_rate = 1;
exception->stage ++;
exception->last_step = nanos();
exception->request_count = 0;
exception->sampled_count = 0;
printf("Exception Rate Changed to %d\n", exception->error_rate);
}
return;
}
bool exception_throw(uint64_t req_id) {
exception_rate();
exception->request_count++;
if (rand() % 100 < exception->error_rate) {
printf("[EXCEPTION THROWN] Req %ld\n", req_id);
return true;
}
return false;
}
bool exception_rate_limit() {
if (exception->sampled_count * 100 < exception->request_count) {
exception->sampled_count++;
return true;
}
return false;
} }
\ No newline at end of file
...@@ -29,45 +29,4 @@ Triggers triggers_init_existing(const char* name); ...@@ -29,45 +29,4 @@ Triggers triggers_init_existing(const char* name);
// For now, we are just sen // For now, we are just sen
void triggers_fire(Triggers* t, int trigger_id, uint64_t base_trace_id, uint64_t trace_id); void triggers_fire(Triggers* t, int trigger_id, uint64_t base_trace_id, uint64_t trace_id);
typedef struct TailCounter {
int64_t queue[1000]; // An even lazy way is to only keep 100 items
int pos;
int thres;
int64_t p[100];
int64_t p_curr;
} TailCounter;
// Only create one tail counter now for testing
extern TailCounter* tail;
// Init tail latency counter. Only support >P90 now
void tail_init(int p);
void tail_inject();
bool tail_latency(uint64_t req_id, int64_t latency);
void tail_print();
typedef struct ExceptionHelper {
int error_rate;
bool active;
int request_count;
int sampled_count;
int stage;
uint64_t last_step;
} ExceptionHelper;
extern ExceptionHelper* exception;
// Init exception injector for step up error rate
void exception_init();
void exception_rate();
bool exception_throw(uint64_t req_id);
bool exception_rate_limit();
#endif // _HINDSIGHT_CLIENT_TRIGGER_H_ #endif // _HINDSIGHT_CLIENT_TRIGGER_H_
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment