redmine

Commented a dead-lock code and improved benchmarking

... ... @@ -253,7 +253,7 @@ typedef enum state_enum state_t;
struct ctx {
#ifndef LIBCLSYNC
state_t state;
volatile state_t state;
pid_t pid;
char pid_str[65];
size_t pid_str_len;
... ...
... ... @@ -33,8 +33,6 @@ int clsyncapi_sync(int n, api_eventinfo_t *ei) {
int clsyncapi_deinit() {
debug(1, "Goodbye cruel world!");
exit(0);
return 0;
}
... ...
... ... @@ -2,6 +2,7 @@
RUN_TIMES=27
configuration() {
git checkout -- configuration.h
for regex in "$@"; do
... ... @@ -10,11 +11,11 @@ configuration() {
}
configure() {
./configure -C $@ >/dev/null 2>/dev/null || ./configure $@
./configure -C $@ >/dev/null 2>/dev/null || ./configure $@ || exit -1
}
run() {
time ./clsync -Mso -S'doc/devel/thread-splitting/benchmark-synchandler.so' --have-recursive-sync --max-iterations 1 -W ~/clsync-test $@
time ./clsync -Mso -S'doc/devel/thread-splitting/benchmark-synchandler.so' --have-recursive-sync --max-iterations 1 -W ~/clsync-test $@ || exit -1
}
benchmark() {
... ... @@ -42,17 +43,17 @@ rm -f /tmp/hl_auto.bin.$$
else
hash="$hash|$HL_INITIAL"
fi
rm -f /tmp/benchmark.{,time}log-"$hash"
rm -f /tmp/benchmark.{,err}log-"$hash"
i=0
while [[ "$i" -lt "$RUN_TIMES" ]]; do
run -d1 $@ >>/tmp/benchmark.log-"$hash" 2>> /tmp/benchmark.timelog-"$hash"
run -d1 $@ >>/tmp/benchmark.log-"$hash" 2>> /tmp/benchmark.errlog-"$hash"
i=$[ $i + 1 ]
done
}
gcc -shared -o doc/devel/thread-splitting/benchmark-synchandler.so -fPIC -D_DEBUG_SUPPORT doc/devel/thread-splitting/benchmark-synchandler.c
configuration
configuration 's|SLEEP_SECONDS.*$|SLEEP_SECONDS 0|g'
for args in "" "--thread-splitting"; do
#for args in "--thread-splitting"; do
... ... @@ -69,9 +70,10 @@ done
configure --enable-highload-locks --enable-debug=yes
benchmark
configuration 's|SLEEP_SECONDS.*$|SLEEP_SECONDS 0|g' 's|#define HL_LOCK_TRIES_AUTO|//#define HL_LOCK_TRIES_AUTO|g' "s|HL_LOCK_TRIES_INITIAL.*$|HL_LOCK_TRIES_INITIAL $interval|g"
interval=1;
while [[ "$i" -le "2147483648" ]]; do
configuration 's|#define HL_LOCK_TRIES_AUTO|//#define HL_LOCK_TRIES_AUTO|g' "s|HL_LOCK_TRIES_INITIAL.*$|HL_LOCK_TRIES_INITIAL $interval|g"
benchmark --thread-splitting
interval=$[ $interval * 2 ]
done
... ...
... ... @@ -485,8 +485,8 @@ int thread_cleanup(ctx_t *ctx_p) {
return thread_info_unlock(0);
}
state_t *state_p = NULL;
int exitcode = 0;
volatile state_t *state_p = NULL;
volatile int exitcode = 0;
#define SHOULD_THREAD(ctx_p) ((ctx_p->flags[THREADING] != PM_OFF) && (ctx_p->flags[THREADING] != PM_SAFE || ctx_p->iteration_num))
int exec_argv(char **argv, int *child_pid) {
... ... @@ -3177,7 +3177,7 @@ int sync_tryforcecycle(pthread_t pthread_parent) {
if (pthread_cond_timedwait(pthread_cond_state, pthread_mutex_state, &time_timeout) != ETIMEDOUT)
return 0;
#else
sleep(1); // TODO: replace this with pthread_cond_timedwait()
sleep(SLEEP_SECONDS); // TODO: replace this with pthread_cond_timedwait()
#endif
return EINPROGRESS;
... ... @@ -3780,7 +3780,9 @@ int sync_run(ctx_t *ctx_p) {
debug(1, "killing sighandler");
// TODO: Do cleanup of watching points
pthread_kill(pthread_sighandler, SIGINT);
pthread_join(pthread_sighandler, NULL);
#ifdef VALGRIND
pthread_join(pthread_sighandler, NULL); // TODO: fix a deadlock
#endif
// Killing children
... ... @@ -3868,7 +3870,7 @@ int sync_run(ctx_t *ctx_p) {
#ifdef VERYPARANOID
// One second for another threads
sleep(1);
sleep(SLEEP_SECONDS);
#endif
if (ctx_p->flags[EXITHOOK]) {
... ...