Skip to content

Commit

Permalink
Merge pull request #9 from OrderLab/perf_optimization
Browse files Browse the repository at this point in the history
Perf optimization
  • Loading branch information
yigonghu authored Jul 26, 2023
2 parents 1693b46 + c171225 commit c52f47e
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion tests/activate_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ int main() {
}


printf("average time for activate psandbox %lu ns\n", total_time/NUMBER);
printf("activate, %lu\n", total_time/NUMBER);
release_psandbox(id);
return 0;
}
2 changes: 1 addition & 1 deletion tests/bind_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int main() {

freeze_psandbox(id);

printf("average time for bind psandbox %lu ns\n", total_time/NUMBER);
printf("bind, %lu\n", total_time/NUMBER);
release_psandbox(id);
return 0;
}
2 changes: 1 addition & 1 deletion tests/freeze_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int main() {
total_time -= time;
}

printf("average time for freeze psandbox %lu ns\n", total_time/NUMBER);
printf("freeze, %lu\n", total_time/NUMBER);
release_psandbox(id);
return 0;
}
2 changes: 1 addition & 1 deletion tests/get_pid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ int main() {



printf("average time for getpid %lu ns\n", total_time/NUMBER);
printf("getpid, %lu\n", total_time/NUMBER);
return 0;
}
2 changes: 1 addition & 1 deletion tests/pthread_create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ int main() {
long time = time2ns(timeDiff(start,stop));
total_time += time;

printf("average time for pthread create %lu ns\n", total_time/NUMBER);
printf("pthread_create, %lu\n", total_time/NUMBER);
return 0;
}
4 changes: 2 additions & 2 deletions tests/release_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ int main() {
release_psandbox(ids[i]);
DBUG_TRACE(&stop);
time = time2ns(timeDiff(start,stop));
total_time += time;
total_time += time/2;
}

for (i = 0; i < NUMBER; i++) {
Expand All @@ -42,7 +42,7 @@ int main() {
total_time -= time;
}

printf("average time for release call is %lu ns\n", total_time/NUMBER);
printf("release, %lu\n", total_time/NUMBER);
return 0;

}
2 changes: 1 addition & 1 deletion tests/unbind_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int main() {
total_time -= time;
}

printf("average time for unbind psandbox %lu ns\n", total_time/NUMBER);
printf("unbind, %lu\n", total_time/NUMBER);
release_psandbox(id);
return 0;
}
2 changes: 1 addition & 1 deletion tests/update_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ int main() {
total_time += time;
freeze_psandbox(id);

printf("average time for update psandbox %lu ns\n", total_time/(4*NUMBER));
printf("update1 (no interf.), %lu\n", total_time/(4*NUMBER));
release_psandbox(id);
return 0;
}
16 changes: 9 additions & 7 deletions tests/update_heavy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "psandbox.h"

#define NUMBER 10000000
#define THREAD 20
#define THREAD 10

void* do_handle_one_connection(void* arg) {
int i,id;
Expand All @@ -20,31 +20,32 @@ void* do_handle_one_connection(void* arg) {
rule.priority = 0;
rule.isolation_level = 50;
rule.type = RELATIVE;

id = create_psandbox(rule);
activate_psandbox(id);
if (j == 19) {
if (j == THREAD -1 ) {
DBUG_TRACE(&start);
}

for (i = 0; i < NUMBER; i++) {
update_psandbox(key,PREPARE);
update_psandbox(key,ENTER);
update_psandbox(key,HOLD);
if(j != 19) {
if(j != THREAD -1) {
usleep(100);
}
update_psandbox(key,UNHOLD);
}
if (j == 19) {
if (j == THREAD - 1) {
DBUG_TRACE(&stop);
long time = time2ns(timeDiff(start,stop));
total_time += time;
}


freeze_psandbox(id);
if (j == 19) {
printf("average time for update psandbox %lu ns\n", total_time/(4*NUMBER));
if (j == THREAD - 1) {
printf("update2 (w/ interf.), %lu\n", total_time/(4*NUMBER));
}

release_psandbox(id);
Expand All @@ -63,9 +64,10 @@ int main() {

for (i = 0; i < THREAD; i++) {
pthread_create(&threads[i], NULL, do_handle_one_connection, &arg[i]);
usleep(100);
}

pthread_join (threads[19], NULL);
pthread_join (threads[THREAD - 1], NULL);
for (i = 0; i < THREAD; i++) {
pthread_cancel(threads[i]);
}
Expand Down

0 comments on commit c52f47e

Please sign in to comment.