summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/test/thread
diff options
context:
space:
mode:
Diffstat (limited to 'src/third_party/wiredtiger/test/thread')
-rw-r--r--src/third_party/wiredtiger/test/thread/file.c114
-rw-r--r--src/third_party/wiredtiger/test/thread/rw.c482
-rw-r--r--src/third_party/wiredtiger/test/thread/stats.c65
-rw-r--r--src/third_party/wiredtiger/test/thread/t.c372
-rw-r--r--src/third_party/wiredtiger/test/thread/thread.h20
5 files changed, 507 insertions, 546 deletions
diff --git a/src/third_party/wiredtiger/test/thread/file.c b/src/third_party/wiredtiger/test/thread/file.c
index fa29f9061ec..6e544bb62e7 100644
--- a/src/third_party/wiredtiger/test/thread/file.c
+++ b/src/third_party/wiredtiger/test/thread/file.c
@@ -31,80 +31,76 @@
static void
file_create(const char *name)
{
- WT_SESSION *session;
- int ret;
- char config[128];
+ WT_SESSION *session;
+ int ret;
+ char config[128];
- testutil_check(conn->open_session(conn, NULL, NULL, &session));
+ testutil_check(conn->open_session(conn, NULL, NULL, &session));
- testutil_check(__wt_snprintf(config, sizeof(config),
- "key_format=%s,"
- "internal_page_max=%d,"
- "leaf_page_max=%d,"
- "%s",
- ftype == ROW ? "u" : "r", 16 * 1024, 128 * 1024,
- ftype == FIX ? ",value_format=3t" : ""));
+ testutil_check(__wt_snprintf(config, sizeof(config),
+ "key_format=%s,"
+ "internal_page_max=%d,"
+ "leaf_page_max=%d,"
+ "%s",
+ ftype == ROW ? "u" : "r", 16 * 1024, 128 * 1024, ftype == FIX ? ",value_format=3t" : ""));
- if ((ret = session->create(session, name, config)) != 0)
- if (ret != EEXIST)
- testutil_die(ret, "session.create");
+ if ((ret = session->create(session, name, config)) != 0)
+ if (ret != EEXIST)
+ testutil_die(ret, "session.create");
- testutil_check(session->close(session, NULL));
+ testutil_check(session->close(session, NULL));
}
void
load(const char *name)
{
- WT_CURSOR *cursor;
- WT_ITEM *key, _key, *value, _value;
- WT_SESSION *session;
- size_t len;
- uint64_t keyno;
- char keybuf[64], valuebuf[64];
-
- file_create(name);
-
- testutil_check(conn->open_session(conn, NULL, NULL, &session));
-
- testutil_check(
- session->open_cursor(session, name, NULL, "bulk", &cursor));
-
- key = &_key;
- value = &_value;
- for (keyno = 1; keyno <= nkeys; ++keyno) {
- if (ftype == ROW) {
- testutil_check(__wt_snprintf_len_set(
- keybuf, sizeof(keybuf),
- &len, "%017" PRIu64, keyno));
- key->data = keybuf;
- key->size = (uint32_t)len;
- cursor->set_key(cursor, key);
- } else
- cursor->set_key(cursor, keyno);
- if (ftype == FIX)
- cursor->set_value(cursor, 0x01);
- else {
- testutil_check(__wt_snprintf_len_set(
- valuebuf, sizeof(valuebuf),
- &len, "%37" PRIu64, keyno));
- value->data = valuebuf;
- value->size = (uint32_t)len;
- cursor->set_value(cursor, value);
- }
- testutil_check(cursor->insert(cursor));
- }
-
- testutil_check(session->close(session, NULL));
+ WT_CURSOR *cursor;
+ WT_ITEM *key, _key, *value, _value;
+ WT_SESSION *session;
+ size_t len;
+ uint64_t keyno;
+ char keybuf[64], valuebuf[64];
+
+ file_create(name);
+
+ testutil_check(conn->open_session(conn, NULL, NULL, &session));
+
+ testutil_check(session->open_cursor(session, name, NULL, "bulk", &cursor));
+
+ key = &_key;
+ value = &_value;
+ for (keyno = 1; keyno <= nkeys; ++keyno) {
+ if (ftype == ROW) {
+ testutil_check(
+ __wt_snprintf_len_set(keybuf, sizeof(keybuf), &len, "%017" PRIu64, keyno));
+ key->data = keybuf;
+ key->size = (uint32_t)len;
+ cursor->set_key(cursor, key);
+ } else
+ cursor->set_key(cursor, keyno);
+ if (ftype == FIX)
+ cursor->set_value(cursor, 0x01);
+ else {
+ testutil_check(
+ __wt_snprintf_len_set(valuebuf, sizeof(valuebuf), &len, "%37" PRIu64, keyno));
+ value->data = valuebuf;
+ value->size = (uint32_t)len;
+ cursor->set_value(cursor, value);
+ }
+ testutil_check(cursor->insert(cursor));
+ }
+
+ testutil_check(session->close(session, NULL));
}
void
verify(const char *name)
{
- WT_SESSION *session;
+ WT_SESSION *session;
- testutil_check(conn->open_session(conn, NULL, NULL, &session));
+ testutil_check(conn->open_session(conn, NULL, NULL, &session));
- testutil_check(session->verify(session, name, NULL));
+ testutil_check(session->verify(session, name, NULL));
- testutil_check(session->close(session, NULL));
+ testutil_check(session->close(session, NULL));
}
diff --git a/src/third_party/wiredtiger/test/thread/rw.c b/src/third_party/wiredtiger/test/thread/rw.c
index f874695d584..52a98c77f3c 100644
--- a/src/third_party/wiredtiger/test/thread/rw.c
+++ b/src/third_party/wiredtiger/test/thread/rw.c
@@ -28,19 +28,19 @@
#include "thread.h"
-static void print_stats(u_int);
+static void print_stats(u_int);
static WT_THREAD_RET reader(void *);
static WT_THREAD_RET writer(void *);
typedef struct {
- char *name; /* object name */
- u_int nops; /* Thread op count */
+ char *name; /* object name */
+ u_int nops; /* Thread op count */
- WT_RAND_STATE rnd; /* RNG */
+ WT_RAND_STATE rnd; /* RNG */
- int remove; /* cursor.remove */
- int update; /* cursor.update */
- int reads; /* cursor.search */
+ int remove; /* cursor.remove */
+ int update; /* cursor.update */
+ int reads; /* cursor.search */
} INFO;
static INFO *run_info;
@@ -48,289 +48,269 @@ static INFO *run_info;
void
rw_start(u_int readers, u_int writers)
{
- struct timeval start, stop;
- wt_thread_t *tids;
- double seconds;
- u_int i, name_index, offset, total_nops;
-
- tids = NULL; /* Keep GCC 4.1 happy. */
- total_nops = 0;
-
- /* Create per-thread structures. */
- run_info = dcalloc((size_t)(readers + writers), sizeof(*run_info));
- tids = dcalloc((size_t)(readers + writers), sizeof(*tids));
-
- /* Create the files and load the initial records. */
- for (i = 0; i < writers; ++i) {
- if (i == 0 || multiple_files) {
- run_info[i].name = dmalloc(64);
- testutil_check(__wt_snprintf(
- run_info[i].name, 64, FNAME, i));
-
- /* Vary by orders of magnitude */
- if (vary_nops)
- run_info[i].nops = WT_MAX(1000, max_nops >> i);
- load(run_info[i].name);
- } else
- run_info[i].name = run_info[0].name;
-
- /* Setup op count if not varying ops. */
- if (run_info[i].nops == 0)
- run_info[i].nops = max_nops;
- total_nops += run_info[i].nops;
- }
-
- /* Setup the reader configurations */
- for (i = 0; i < readers; ++i) {
- offset = i + writers;
- if (multiple_files) {
- run_info[offset].name = dmalloc(64);
- /* Have readers read from tables with writes. */
- name_index = i % writers;
- testutil_check(__wt_snprintf(
- run_info[offset].name, 64, FNAME, name_index));
-
- /* Vary by orders of magnitude */
- if (vary_nops)
- run_info[offset].nops =
- WT_MAX(1000, max_nops >> name_index);
- } else
- run_info[offset].name = run_info[0].name;
-
- /* Setup op count if not varying ops. */
- if (run_info[offset].nops == 0)
- run_info[offset].nops = max_nops;
- total_nops += run_info[offset].nops;
- }
-
- (void)gettimeofday(&start, NULL);
-
- /* Create threads. */
- for (i = 0; i < readers; ++i)
- testutil_check(__wt_thread_create(
- NULL, &tids[i], reader, (void *)(uintptr_t)i));
- for (; i < readers + writers; ++i)
- testutil_check(__wt_thread_create(
- NULL, &tids[i], writer, (void *)(uintptr_t)i));
-
- /* Wait for the threads. */
- for (i = 0; i < readers + writers; ++i)
- testutil_check(__wt_thread_join(NULL, &tids[i]));
-
- (void)gettimeofday(&stop, NULL);
- seconds = (stop.tv_sec - start.tv_sec) +
- (stop.tv_usec - start.tv_usec) * 1e-6;
- fprintf(stderr, "timer: %.2lf seconds (%d ops/second)\n",
- seconds, (int)(((readers + writers) * total_nops) / seconds));
-
- /* Verify the files. */
- for (i = 0; i < readers + writers; ++i) {
- verify(run_info[i].name);
- if (!multiple_files)
- break;
- }
-
- /* Output run statistics. */
- print_stats(readers + writers);
-
- /* Free allocated memory. */
- for (i = 0; i < readers + writers; ++i) {
- free(run_info[i].name);
- if (!multiple_files)
- break;
- }
-
- free(run_info);
- free(tids);
+ struct timeval start, stop;
+ wt_thread_t *tids;
+ double seconds;
+ u_int i, name_index, offset, total_nops;
+
+ tids = NULL; /* Keep GCC 4.1 happy. */
+ total_nops = 0;
+
+ /* Create per-thread structures. */
+ run_info = dcalloc((size_t)(readers + writers), sizeof(*run_info));
+ tids = dcalloc((size_t)(readers + writers), sizeof(*tids));
+
+ /* Create the files and load the initial records. */
+ for (i = 0; i < writers; ++i) {
+ if (i == 0 || multiple_files) {
+ run_info[i].name = dmalloc(64);
+ testutil_check(__wt_snprintf(run_info[i].name, 64, FNAME, i));
+
+ /* Vary by orders of magnitude */
+ if (vary_nops)
+ run_info[i].nops = WT_MAX(1000, max_nops >> i);
+ load(run_info[i].name);
+ } else
+ run_info[i].name = run_info[0].name;
+
+ /* Setup op count if not varying ops. */
+ if (run_info[i].nops == 0)
+ run_info[i].nops = max_nops;
+ total_nops += run_info[i].nops;
+ }
+
+ /* Setup the reader configurations */
+ for (i = 0; i < readers; ++i) {
+ offset = i + writers;
+ if (multiple_files) {
+ run_info[offset].name = dmalloc(64);
+ /* Have readers read from tables with writes. */
+ name_index = i % writers;
+ testutil_check(__wt_snprintf(run_info[offset].name, 64, FNAME, name_index));
+
+ /* Vary by orders of magnitude */
+ if (vary_nops)
+ run_info[offset].nops = WT_MAX(1000, max_nops >> name_index);
+ } else
+ run_info[offset].name = run_info[0].name;
+
+ /* Setup op count if not varying ops. */
+ if (run_info[offset].nops == 0)
+ run_info[offset].nops = max_nops;
+ total_nops += run_info[offset].nops;
+ }
+
+ (void)gettimeofday(&start, NULL);
+
+ /* Create threads. */
+ for (i = 0; i < readers; ++i)
+ testutil_check(__wt_thread_create(NULL, &tids[i], reader, (void *)(uintptr_t)i));
+ for (; i < readers + writers; ++i)
+ testutil_check(__wt_thread_create(NULL, &tids[i], writer, (void *)(uintptr_t)i));
+
+ /* Wait for the threads. */
+ for (i = 0; i < readers + writers; ++i)
+ testutil_check(__wt_thread_join(NULL, &tids[i]));
+
+ (void)gettimeofday(&stop, NULL);
+ seconds = (stop.tv_sec - start.tv_sec) + (stop.tv_usec - start.tv_usec) * 1e-6;
+ fprintf(stderr, "timer: %.2lf seconds (%d ops/second)\n", seconds,
+ (int)(((readers + writers) * total_nops) / seconds));
+
+ /* Verify the files. */
+ for (i = 0; i < readers + writers; ++i) {
+ verify(run_info[i].name);
+ if (!multiple_files)
+ break;
+ }
+
+ /* Output run statistics. */
+ print_stats(readers + writers);
+
+ /* Free allocated memory. */
+ for (i = 0; i < readers + writers; ++i) {
+ free(run_info[i].name);
+ if (!multiple_files)
+ break;
+ }
+
+ free(run_info);
+ free(tids);
}
/*
* reader_op --
- * Read operation.
+ * Read operation.
*/
static inline void
reader_op(WT_SESSION *session, WT_CURSOR *cursor, INFO *s)
{
- WT_ITEM *key, _key;
- size_t len;
- uint64_t keyno;
- int ret;
- char keybuf[64];
-
- key = &_key;
-
- keyno = __wt_random(&s->rnd) % nkeys + 1;
- if (ftype == ROW) {
- testutil_check(__wt_snprintf_len_set(
- keybuf, sizeof(keybuf), &len, "%017" PRIu64, keyno));
- key->data = keybuf;
- key->size = (uint32_t)len;
- cursor->set_key(cursor, key);
- } else
- cursor->set_key(cursor, keyno);
- if ((ret = cursor->search(cursor)) != 0 && ret != WT_NOTFOUND)
- testutil_die(ret, "cursor.search");
- if (log_print)
- testutil_check(session->log_printf(session,
- "Reader Thread %p key %017" PRIu64, pthread_self(), keyno));
+ WT_ITEM *key, _key;
+ size_t len;
+ uint64_t keyno;
+ int ret;
+ char keybuf[64];
+
+ key = &_key;
+
+ keyno = __wt_random(&s->rnd) % nkeys + 1;
+ if (ftype == ROW) {
+ testutil_check(__wt_snprintf_len_set(keybuf, sizeof(keybuf), &len, "%017" PRIu64, keyno));
+ key->data = keybuf;
+ key->size = (uint32_t)len;
+ cursor->set_key(cursor, key);
+ } else
+ cursor->set_key(cursor, keyno);
+ if ((ret = cursor->search(cursor)) != 0 && ret != WT_NOTFOUND)
+ testutil_die(ret, "cursor.search");
+ if (log_print)
+ testutil_check(
+ session->log_printf(session, "Reader Thread %p key %017" PRIu64, pthread_self(), keyno));
}
/*
* reader --
- * Reader thread start function.
+ * Reader thread start function.
*/
static WT_THREAD_RET
reader(void *arg)
{
- INFO *s;
- WT_CURSOR *cursor;
- WT_SESSION *session;
- u_int i;
- int id;
- char tid[128];
-
- id = (int)(uintptr_t)arg;
- s = &run_info[id];
- testutil_check(__wt_thread_str(tid, sizeof(tid)));
- __wt_random_init(&s->rnd);
-
- printf(" read thread %2d starting: tid: %s, file: %s\n",
- id, tid, s->name);
-
- __wt_yield(); /* Get all the threads created. */
-
- if (session_per_op) {
- for (i = 0; i < s->nops; ++i, ++s->reads, __wt_yield()) {
- testutil_check(
- conn->open_session(conn, NULL, NULL, &session));
- testutil_check(session->open_cursor(
- session, s->name, NULL, NULL, &cursor));
- reader_op(session, cursor, s);
- testutil_check(session->close(session, NULL));
- }
- } else {
- testutil_check(conn->open_session(conn, NULL, NULL, &session));
- testutil_check(session->open_cursor(
- session, s->name, NULL, NULL, &cursor));
- for (i = 0; i < s->nops; ++i, ++s->reads, __wt_yield())
- reader_op(session, cursor, s);
- testutil_check(session->close(session, NULL));
- }
-
- printf(" read thread %2d stopping: tid: %s, file: %s\n",
- id, tid, s->name);
-
- return (WT_THREAD_RET_VALUE);
+ INFO *s;
+ WT_CURSOR *cursor;
+ WT_SESSION *session;
+ u_int i;
+ int id;
+ char tid[128];
+
+ id = (int)(uintptr_t)arg;
+ s = &run_info[id];
+ testutil_check(__wt_thread_str(tid, sizeof(tid)));
+ __wt_random_init(&s->rnd);
+
+ printf(" read thread %2d starting: tid: %s, file: %s\n", id, tid, s->name);
+
+ __wt_yield(); /* Get all the threads created. */
+
+ if (session_per_op) {
+ for (i = 0; i < s->nops; ++i, ++s->reads, __wt_yield()) {
+ testutil_check(conn->open_session(conn, NULL, NULL, &session));
+ testutil_check(session->open_cursor(session, s->name, NULL, NULL, &cursor));
+ reader_op(session, cursor, s);
+ testutil_check(session->close(session, NULL));
+ }
+ } else {
+ testutil_check(conn->open_session(conn, NULL, NULL, &session));
+ testutil_check(session->open_cursor(session, s->name, NULL, NULL, &cursor));
+ for (i = 0; i < s->nops; ++i, ++s->reads, __wt_yield())
+ reader_op(session, cursor, s);
+ testutil_check(session->close(session, NULL));
+ }
+
+ printf(" read thread %2d stopping: tid: %s, file: %s\n", id, tid, s->name);
+
+ return (WT_THREAD_RET_VALUE);
}
/*
* writer_op --
- * Write operation.
+ * Write operation.
*/
static inline void
writer_op(WT_SESSION *session, WT_CURSOR *cursor, INFO *s)
{
- WT_ITEM *key, _key, *value, _value;
- size_t len;
- uint64_t keyno;
- int ret;
- char keybuf[64], valuebuf[64];
-
- key = &_key;
- value = &_value;
-
- keyno = __wt_random(&s->rnd) % nkeys + 1;
- if (ftype == ROW) {
- testutil_check(__wt_snprintf_len_set(
- keybuf, sizeof(keybuf), &len, "%017" PRIu64, keyno));
- key->data = keybuf;
- key->size = (uint32_t)len;
- cursor->set_key(cursor, key);
- } else
- cursor->set_key(cursor, keyno);
- if (keyno % 5 == 0) {
- ++s->remove;
- if ((ret = cursor->remove(cursor)) != 0 && ret != WT_NOTFOUND)
- testutil_die(ret, "cursor.remove");
- } else {
- ++s->update;
- value->data = valuebuf;
- if (ftype == FIX)
- cursor->set_value(cursor, 0x10);
- else {
- testutil_check(__wt_snprintf_len_set(
- valuebuf, sizeof(valuebuf),
- &len, "XXX %37" PRIu64, keyno));
- value->size = (uint32_t)len;
- cursor->set_value(cursor, value);
- }
- testutil_check(cursor->update(cursor));
- }
- if (log_print)
- testutil_check(session->log_printf(session,
- "Writer Thread %p key %017" PRIu64, pthread_self(), keyno));
+ WT_ITEM *key, _key, *value, _value;
+ size_t len;
+ uint64_t keyno;
+ int ret;
+ char keybuf[64], valuebuf[64];
+
+ key = &_key;
+ value = &_value;
+
+ keyno = __wt_random(&s->rnd) % nkeys + 1;
+ if (ftype == ROW) {
+ testutil_check(__wt_snprintf_len_set(keybuf, sizeof(keybuf), &len, "%017" PRIu64, keyno));
+ key->data = keybuf;
+ key->size = (uint32_t)len;
+ cursor->set_key(cursor, key);
+ } else
+ cursor->set_key(cursor, keyno);
+ if (keyno % 5 == 0) {
+ ++s->remove;
+ if ((ret = cursor->remove(cursor)) != 0 && ret != WT_NOTFOUND)
+ testutil_die(ret, "cursor.remove");
+ } else {
+ ++s->update;
+ value->data = valuebuf;
+ if (ftype == FIX)
+ cursor->set_value(cursor, 0x10);
+ else {
+ testutil_check(
+ __wt_snprintf_len_set(valuebuf, sizeof(valuebuf), &len, "XXX %37" PRIu64, keyno));
+ value->size = (uint32_t)len;
+ cursor->set_value(cursor, value);
+ }
+ testutil_check(cursor->update(cursor));
+ }
+ if (log_print)
+ testutil_check(
+ session->log_printf(session, "Writer Thread %p key %017" PRIu64, pthread_self(), keyno));
}
/*
* writer --
- * Writer thread start function.
+ * Writer thread start function.
*/
static WT_THREAD_RET
writer(void *arg)
{
- INFO *s;
- WT_CURSOR *cursor;
- WT_SESSION *session;
- u_int i;
- int id;
- char tid[128];
-
- id = (int)(uintptr_t)arg;
- s = &run_info[id];
- testutil_check(__wt_thread_str(tid, sizeof(tid)));
- __wt_random_init(&s->rnd);
-
- printf("write thread %2d starting: tid: %s, file: %s\n",
- id, tid, s->name);
-
- __wt_yield(); /* Get all the threads created. */
-
- if (session_per_op) {
- for (i = 0; i < s->nops; ++i, __wt_yield()) {
- testutil_check(conn->open_session(
- conn, NULL, NULL, &session));
- testutil_check(session->open_cursor(
- session, s->name, NULL, NULL, &cursor));
- writer_op(session, cursor, s);
- testutil_check(session->close(session, NULL));
- }
- } else {
- testutil_check(conn->open_session(conn, NULL, NULL, &session));
- testutil_check(session->open_cursor(
- session, s->name, NULL, NULL, &cursor));
- for (i = 0; i < s->nops; ++i, __wt_yield())
- writer_op(session, cursor, s);
- testutil_check(session->close(session, NULL));
- }
-
- printf("write thread %2d stopping: tid: %s, file: %s\n",
- id, tid, s->name);
-
- return (WT_THREAD_RET_VALUE);
+ INFO *s;
+ WT_CURSOR *cursor;
+ WT_SESSION *session;
+ u_int i;
+ int id;
+ char tid[128];
+
+ id = (int)(uintptr_t)arg;
+ s = &run_info[id];
+ testutil_check(__wt_thread_str(tid, sizeof(tid)));
+ __wt_random_init(&s->rnd);
+
+ printf("write thread %2d starting: tid: %s, file: %s\n", id, tid, s->name);
+
+ __wt_yield(); /* Get all the threads created. */
+
+ if (session_per_op) {
+ for (i = 0; i < s->nops; ++i, __wt_yield()) {
+ testutil_check(conn->open_session(conn, NULL, NULL, &session));
+ testutil_check(session->open_cursor(session, s->name, NULL, NULL, &cursor));
+ writer_op(session, cursor, s);
+ testutil_check(session->close(session, NULL));
+ }
+ } else {
+ testutil_check(conn->open_session(conn, NULL, NULL, &session));
+ testutil_check(session->open_cursor(session, s->name, NULL, NULL, &cursor));
+ for (i = 0; i < s->nops; ++i, __wt_yield())
+ writer_op(session, cursor, s);
+ testutil_check(session->close(session, NULL));
+ }
+
+ printf("write thread %2d stopping: tid: %s, file: %s\n", id, tid, s->name);
+
+ return (WT_THREAD_RET_VALUE);
}
/*
* print_stats --
- * Display reader/writer thread stats.
+ * Display reader/writer thread stats.
*/
static void
print_stats(u_int nthreads)
{
- INFO *s;
- u_int id;
+ INFO *s;
+ u_int id;
- s = run_info;
- for (id = 0; id < nthreads; ++id, ++s)
- printf("%3u: read %6d, remove %6d, update %6d\n",
- id, s->reads, s->remove, s->update);
+ s = run_info;
+ for (id = 0; id < nthreads; ++id, ++s)
+ printf("%3u: read %6d, remove %6d, update %6d\n", id, s->reads, s->remove, s->update);
}
diff --git a/src/third_party/wiredtiger/test/thread/stats.c b/src/third_party/wiredtiger/test/thread/stats.c
index b6c0f817109..a23d40f78ff 100644
--- a/src/third_party/wiredtiger/test/thread/stats.c
+++ b/src/third_party/wiredtiger/test/thread/stats.c
@@ -35,47 +35,44 @@
void
stats(void)
{
- FILE *fp;
- WT_CURSOR *cursor;
- WT_SESSION *session;
- uint64_t v;
- int ret;
- const char *desc, *pval;
- char name[64];
+ FILE *fp;
+ WT_CURSOR *cursor;
+ WT_SESSION *session;
+ uint64_t v;
+ int ret;
+ char name[64];
+ const char *desc, *pval;
- testutil_check(conn->open_session(conn, NULL, NULL, &session));
+ testutil_check(conn->open_session(conn, NULL, NULL, &session));
- if ((fp = fopen(FNAME_STAT, "w")) == NULL)
- testutil_die(errno, "fopen " FNAME_STAT);
+ if ((fp = fopen(FNAME_STAT, "w")) == NULL)
+ testutil_die(errno, "fopen " FNAME_STAT);
- /* Connection statistics. */
- testutil_check(session->open_cursor(
- session, "statistics:", NULL, NULL, &cursor));
+ /* Connection statistics. */
+ testutil_check(session->open_cursor(session, "statistics:", NULL, NULL, &cursor));
- while ((ret = cursor->next(cursor)) == 0 &&
- (ret = cursor->get_value(cursor, &desc, &pval, &v)) == 0)
- (void)fprintf(fp, "%s=%s\n", desc, pval);
+ while (
+ (ret = cursor->next(cursor)) == 0 && (ret = cursor->get_value(cursor, &desc, &pval, &v)) == 0)
+ (void)fprintf(fp, "%s=%s\n", desc, pval);
- if (ret != WT_NOTFOUND)
- testutil_die(ret, "cursor.next");
- testutil_check(cursor->close(cursor));
+ if (ret != WT_NOTFOUND)
+ testutil_die(ret, "cursor.next");
+ testutil_check(cursor->close(cursor));
- /* File statistics. */
- if (!multiple_files) {
- testutil_check(__wt_snprintf(
- name, sizeof(name), "statistics:" FNAME, 0));
- testutil_check(session->open_cursor(
- session, name, NULL, NULL, &cursor));
+ /* File statistics. */
+ if (!multiple_files) {
+ testutil_check(__wt_snprintf(name, sizeof(name), "statistics:" FNAME, 0));
+ testutil_check(session->open_cursor(session, name, NULL, NULL, &cursor));
- while ((ret = cursor->next(cursor)) == 0 &&
- (ret = cursor->get_value(cursor, &desc, &pval, &v)) == 0)
- (void)fprintf(fp, "%s=%s\n", desc, pval);
+ while ((ret = cursor->next(cursor)) == 0 &&
+ (ret = cursor->get_value(cursor, &desc, &pval, &v)) == 0)
+ (void)fprintf(fp, "%s=%s\n", desc, pval);
- if (ret != WT_NOTFOUND)
- testutil_die(ret, "cursor.next");
- testutil_check(cursor->close(cursor));
+ if (ret != WT_NOTFOUND)
+ testutil_die(ret, "cursor.next");
+ testutil_check(cursor->close(cursor));
- testutil_check(session->close(session, NULL));
- }
- (void)fclose(fp);
+ testutil_check(session->close(session, NULL));
+ }
+ (void)fclose(fp);
}
diff --git a/src/third_party/wiredtiger/test/thread/t.c b/src/third_party/wiredtiger/test/thread/t.c
index 10fe89b4a75..63d1abab46a 100644
--- a/src/third_party/wiredtiger/test/thread/t.c
+++ b/src/third_party/wiredtiger/test/thread/t.c
@@ -28,23 +28,22 @@
#include "thread.h"
-WT_CONNECTION *conn; /* WiredTiger connection */
-__ftype ftype; /* File type */
-u_int nkeys, max_nops; /* Keys, Operations */
-int vary_nops; /* Vary operations by thread */
-int log_print; /* Log print per operation */
-int multiple_files; /* File per thread */
-int session_per_op; /* New session per operation */
-
-static char home[512]; /* Program working dir */
-static FILE *logfp; /* Log file */
-
-static int handle_error(WT_EVENT_HANDLER *, WT_SESSION *, int, const char *);
-static int handle_message(WT_EVENT_HANDLER *, WT_SESSION *, const char *);
-static void onint(int)
- WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn));
+WT_CONNECTION *conn; /* WiredTiger connection */
+__ftype ftype; /* File type */
+u_int nkeys, max_nops; /* Keys, Operations */
+int vary_nops; /* Vary operations by thread */
+int log_print; /* Log print per operation */
+int multiple_files; /* File per thread */
+int session_per_op; /* New session per operation */
+
+static char home[512]; /* Program working dir */
+static FILE *logfp; /* Log file */
+
+static int handle_error(WT_EVENT_HANDLER *, WT_SESSION *, int, const char *);
+static int handle_message(WT_EVENT_HANDLER *, WT_SESSION *, const char *);
+static void onint(int) WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn));
static void shutdown(void);
-static int usage(void);
+static int usage(void);
static void wt_connect(char *);
static void wt_shutdown(void);
@@ -54,236 +53,225 @@ extern char *__wt_optarg;
int
main(int argc, char *argv[])
{
- u_int readers, writers;
- int ch, cnt, runs;
- char *config_open, *working_dir;
-
- (void)testutil_set_progname(argv);
-
- config_open = NULL;
- working_dir = NULL;
- ftype = ROW;
- log_print = 0;
- multiple_files = 0;
- nkeys = 1000;
- max_nops = 10000;
- readers = 10;
- runs = 1;
- session_per_op = 0;
- vary_nops = 0;
- writers = 10;
-
- while ((ch = __wt_getopt(
- progname, argc, argv, "C:Fk:h:Ll:n:R:r:St:vW:")) != EOF)
- switch (ch) {
- case 'C': /* wiredtiger_open config */
- config_open = __wt_optarg;
- break;
- case 'F': /* multiple files */
- multiple_files = 1;
- break;
- case 'h':
- working_dir = __wt_optarg;
- break;
- case 'k': /* rows */
- nkeys = (u_int)atoi(__wt_optarg);
- break;
- case 'L': /* log print per operation */
- log_print = 1;
- break;
- case 'l': /* log */
- if ((logfp = fopen(__wt_optarg, "w")) == NULL) {
- fprintf(stderr,
- "%s: %s\n", __wt_optarg, strerror(errno));
- return (EXIT_FAILURE);
- }
- break;
- case 'n': /* operations */
- max_nops = (u_int)atoi(__wt_optarg);
- break;
- case 'R':
- readers = (u_int)atoi(__wt_optarg);
- break;
- case 'r': /* runs */
- runs = atoi(__wt_optarg);
- break;
- case 'S': /* new session per operation */
- session_per_op = 1;
- break;
- case 't':
- switch (__wt_optarg[0]) {
- case 'f':
- ftype = FIX;
- break;
- case 'r':
- ftype = ROW;
- break;
- case 'v':
- ftype = VAR;
- break;
- default:
- return (usage());
- }
- break;
- case 'v': /* vary operation count */
- vary_nops = 1;
- break;
- case 'W':
- writers = (u_int)atoi(__wt_optarg);
- break;
- default:
- return (usage());
- }
-
- argc -= __wt_optind;
- if (argc != 0)
- return (usage());
-
- testutil_work_dir_from_path(home, 512, working_dir);
-
- if (vary_nops && !multiple_files) {
- fprintf(stderr,
- "Variable op counts only supported with multiple tables\n");
- return (usage());
- }
-
- /* Clean up on signal. */
- (void)signal(SIGINT, onint);
-
- printf("%s: process %" PRIu64 "\n", progname, (uint64_t)getpid());
- for (cnt = 1; runs == 0 || cnt <= runs; ++cnt) {
- printf(
- " %d: %u readers, %u writers\n", cnt, readers, writers);
-
- shutdown(); /* Clean up previous runs */
-
- wt_connect(config_open); /* WiredTiger connection */
-
- rw_start(readers, writers); /* Loop operations */
-
- stats(); /* Statistics */
-
- wt_shutdown(); /* WiredTiger shut down */
- }
- return (0);
+ u_int readers, writers;
+ int ch, cnt, runs;
+ char *config_open, *working_dir;
+
+ (void)testutil_set_progname(argv);
+
+ config_open = NULL;
+ working_dir = NULL;
+ ftype = ROW;
+ log_print = 0;
+ multiple_files = 0;
+ nkeys = 1000;
+ max_nops = 10000;
+ readers = 10;
+ runs = 1;
+ session_per_op = 0;
+ vary_nops = 0;
+ writers = 10;
+
+ while ((ch = __wt_getopt(progname, argc, argv, "C:Fk:h:Ll:n:R:r:St:vW:")) != EOF)
+ switch (ch) {
+ case 'C': /* wiredtiger_open config */
+ config_open = __wt_optarg;
+ break;
+ case 'F': /* multiple files */
+ multiple_files = 1;
+ break;
+ case 'h':
+ working_dir = __wt_optarg;
+ break;
+ case 'k': /* rows */
+ nkeys = (u_int)atoi(__wt_optarg);
+ break;
+ case 'L': /* log print per operation */
+ log_print = 1;
+ break;
+ case 'l': /* log */
+ if ((logfp = fopen(__wt_optarg, "w")) == NULL) {
+ fprintf(stderr, "%s: %s\n", __wt_optarg, strerror(errno));
+ return (EXIT_FAILURE);
+ }
+ break;
+ case 'n': /* operations */
+ max_nops = (u_int)atoi(__wt_optarg);
+ break;
+ case 'R':
+ readers = (u_int)atoi(__wt_optarg);
+ break;
+ case 'r': /* runs */
+ runs = atoi(__wt_optarg);
+ break;
+ case 'S': /* new session per operation */
+ session_per_op = 1;
+ break;
+ case 't':
+ switch (__wt_optarg[0]) {
+ case 'f':
+ ftype = FIX;
+ break;
+ case 'r':
+ ftype = ROW;
+ break;
+ case 'v':
+ ftype = VAR;
+ break;
+ default:
+ return (usage());
+ }
+ break;
+ case 'v': /* vary operation count */
+ vary_nops = 1;
+ break;
+ case 'W':
+ writers = (u_int)atoi(__wt_optarg);
+ break;
+ default:
+ return (usage());
+ }
+
+ argc -= __wt_optind;
+ if (argc != 0)
+ return (usage());
+
+ testutil_work_dir_from_path(home, 512, working_dir);
+
+ if (vary_nops && !multiple_files) {
+ fprintf(stderr, "Variable op counts only supported with multiple tables\n");
+ return (usage());
+ }
+
+ /* Clean up on signal. */
+ (void)signal(SIGINT, onint);
+
+ printf("%s: process %" PRIu64 "\n", progname, (uint64_t)getpid());
+ for (cnt = 1; runs == 0 || cnt <= runs; ++cnt) {
+ printf(" %d: %u readers, %u writers\n", cnt, readers, writers);
+
+ shutdown(); /* Clean up previous runs */
+
+ wt_connect(config_open); /* WiredTiger connection */
+
+ rw_start(readers, writers); /* Loop operations */
+
+ stats(); /* Statistics */
+
+ wt_shutdown(); /* WiredTiger shut down */
+ }
+ return (0);
}
/*
* wt_connect --
- * Configure the WiredTiger connection.
+ * Configure the WiredTiger connection.
*/
static void
wt_connect(char *config_open)
{
- static WT_EVENT_HANDLER event_handler = {
- handle_error,
- handle_message,
- NULL,
- NULL /* Close handler. */
- };
- char config[512];
-
- testutil_clean_work_dir(home);
- testutil_make_work_dir(home);
-
- testutil_check(__wt_snprintf(config, sizeof(config),
- "create,statistics=(all),error_prefix=\"%s\",%s%s",
- progname,
- config_open == NULL ? "" : ",",
- config_open == NULL ? "" : config_open));
-
- testutil_check(wiredtiger_open(home, &event_handler, config, &conn));
+ static WT_EVENT_HANDLER event_handler = {
+ handle_error, handle_message, NULL, NULL /* Close handler. */
+ };
+ char config[512];
+
+ testutil_clean_work_dir(home);
+ testutil_make_work_dir(home);
+
+ testutil_check(
+ __wt_snprintf(config, sizeof(config), "create,statistics=(all),error_prefix=\"%s\",%s%s",
+ progname, config_open == NULL ? "" : ",", config_open == NULL ? "" : config_open));
+
+ testutil_check(wiredtiger_open(home, &event_handler, config, &conn));
}
/*
* wt_shutdown --
- * Flush the file to disk and shut down the WiredTiger connection.
+ * Flush the file to disk and shut down the WiredTiger connection.
*/
static void
wt_shutdown(void)
{
- WT_SESSION *session;
+ WT_SESSION *session;
- testutil_check(conn->open_session(conn, NULL, NULL, &session));
+ testutil_check(conn->open_session(conn, NULL, NULL, &session));
- testutil_check(session->checkpoint(session, NULL));
+ testutil_check(session->checkpoint(session, NULL));
- testutil_check(conn->close(conn, NULL));
+ testutil_check(conn->close(conn, NULL));
}
/*
* shutdown --
- * Clean up from previous runs.
+ * Clean up from previous runs.
*/
static void
shutdown(void)
{
- testutil_clean_work_dir(home);
+ testutil_clean_work_dir(home);
}
static int
-handle_error(WT_EVENT_HANDLER *handler,
- WT_SESSION *session, int error, const char *errmsg)
+handle_error(WT_EVENT_HANDLER *handler, WT_SESSION *session, int error, const char *errmsg)
{
- (void)(handler);
- (void)(session);
- (void)(error);
+ (void)(handler);
+ (void)(session);
+ (void)(error);
- return (fprintf(stderr, "%s\n", errmsg) < 0 ? -1 : 0);
+ return (fprintf(stderr, "%s\n", errmsg) < 0 ? -1 : 0);
}
static int
-handle_message(WT_EVENT_HANDLER *handler,
- WT_SESSION *session, const char *message)
+handle_message(WT_EVENT_HANDLER *handler, WT_SESSION *session, const char *message)
{
- (void)(handler);
- (void)(session);
+ (void)(handler);
+ (void)(session);
- if (logfp != NULL)
- return (fprintf(logfp, "%s\n", message) < 0 ? -1 : 0);
+ if (logfp != NULL)
+ return (fprintf(logfp, "%s\n", message) < 0 ? -1 : 0);
- return (printf("%s\n", message) < 0 ? -1 : 0);
+ return (printf("%s\n", message) < 0 ? -1 : 0);
}
/*
* onint --
- * Interrupt signal handler.
+ * Interrupt signal handler.
*/
static void
onint(int signo)
{
- (void)(signo);
+ (void)(signo);
- shutdown();
+ shutdown();
- fprintf(stderr, "\n");
- exit(EXIT_FAILURE);
+ fprintf(stderr, "\n");
+ exit(EXIT_FAILURE);
}
/*
* usage --
- * Display usage statement and exit failure.
+ * Display usage statement and exit failure.
*/
static int
usage(void)
{
- fprintf(stderr,
- "usage: %s "
- "[-FLSv] [-C wiredtiger-config] [-k keys] [-l log]\n\t"
- "[-n ops] [-R readers] [-r runs] [-t f|r|v] [-W writers]\n",
- progname);
- fprintf(stderr, "%s",
- "\t-C specify wiredtiger_open configuration arguments\n"
- "\t-F create a file per thread\n"
- "\t-k set number of keys to load\n"
- "\t-L log print per operation\n"
- "\t-l specify a log file\n"
- "\t-n set number of operations each thread does\n"
- "\t-R set number of reading threads\n"
- "\t-r set number of runs (0 for continuous)\n"
- "\t-S open/close a session on every operation\n"
- "\t-t set a file type (fix | row | var)\n"
- "\t-v do a different number of operations on different tables\n"
- "\t-W set number of writing threads\n");
- return (EXIT_FAILURE);
+ fprintf(stderr,
+ "usage: %s "
+ "[-FLSv] [-C wiredtiger-config] [-k keys] [-l log]\n\t"
+ "[-n ops] [-R readers] [-r runs] [-t f|r|v] [-W writers]\n",
+ progname);
+ fprintf(stderr, "%s",
+ "\t-C specify wiredtiger_open configuration arguments\n"
+ "\t-F create a file per thread\n"
+ "\t-k set number of keys to load\n"
+ "\t-L log print per operation\n"
+ "\t-l specify a log file\n"
+ "\t-n set number of operations each thread does\n"
+ "\t-R set number of reading threads\n"
+ "\t-r set number of runs (0 for continuous)\n"
+ "\t-S open/close a session on every operation\n"
+ "\t-t set a file type (fix | row | var)\n"
+ "\t-v do a different number of operations on different tables\n"
+ "\t-W set number of writing threads\n");
+ return (EXIT_FAILURE);
}
diff --git a/src/third_party/wiredtiger/test/thread/thread.h b/src/third_party/wiredtiger/test/thread/thread.h
index c485e899eba..ea7965434be 100644
--- a/src/third_party/wiredtiger/test/thread/thread.h
+++ b/src/third_party/wiredtiger/test/thread/thread.h
@@ -30,20 +30,20 @@
#include <signal.h>
-#define FNAME "file:wt.%03d" /* File name */
-#define FNAME_STAT "__stats" /* File name for statistics */
+#define FNAME "file:wt.%03d" /* File name */
+#define FNAME_STAT "__stats" /* File name for statistics */
-extern WT_CONNECTION *conn; /* WiredTiger connection */
+extern WT_CONNECTION *conn; /* WiredTiger connection */
-typedef enum { FIX, ROW, VAR } __ftype; /* File type */
+typedef enum { FIX, ROW, VAR } __ftype; /* File type */
extern __ftype ftype;
-extern int log_print; /* Log print per operation */
-extern int multiple_files; /* File per thread */
-extern u_int nkeys; /* Keys to load */
-extern u_int max_nops; /* Operations per thread */
-extern int vary_nops; /* Operations per thread */
-extern int session_per_op; /* New session per operation */
+extern int log_print; /* Log print per operation */
+extern int multiple_files; /* File per thread */
+extern u_int nkeys; /* Keys to load */
+extern u_int max_nops; /* Operations per thread */
+extern int vary_nops; /* Operations per thread */
+extern int session_per_op; /* New session per operation */
void load(const char *);
void rw_start(u_int, u_int);