summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/test/csuite/wt1965_col_efficiency/main.c
diff options
context:
space:
mode:
authorLuke Chen <luke.chen@mongodb.com>2019-09-09 14:45:50 +1000
committerLuke Chen <luke.chen@mongodb.com>2019-09-09 14:48:15 +1000
commitd1c52b7aafac44e16dd62ce94663eab1aa16f921 (patch)
tree2aea018150b745b0fc7ef3dc626c4ef4164d2704 /src/third_party/wiredtiger/test/csuite/wt1965_col_efficiency/main.c
parentb326fd656716e95418e563ff12368a3015994b5e (diff)
downloadmongo-d1c52b7aafac44e16dd62ce94663eab1aa16f921.tar.gz
Import wiredtiger: c600bde20363629405082a3ea985b70dfb00850e from branch mongodb-4.2
ref: 280c572c80..c600bde203 for: 4.2.1 WT-4535 Enhance wt command line utility to use read-only mode WT-4658 Apply Clang Format WT-4810 Adding WT_ERR_ASSERT and WT_RET_ASSERT macros WT-4831 Add option to python tests to not fail if stdout is not empty WT-4884 Test for recovery correctness with modify operations WT-4935 Add a perf test to find out the wiredtiger_calc_modify overhead WT-4966 Fix valgrind detected memory leak from test/csuite/import/smoke.sh WT-5043 Add debugging to aid in test/format hang WT-5046 Prepared transactions aren't properly cleared from global table with WT_CONN_LOG_DEBUG_MODE enabled WT-5062 Adjust the record size to consume less size WT-5063 Return proper error message for cursor modify operation for not supported cursor types WT-5074 Fix "make check" on exotic architectures WT-5076 Cut WiredTiger 3.2.1 release WT-5080 New wtperf workload modify_distribute option WT-5085 Fix spacing in wtperf output WT-5087 Add time tracking at start of reconciliation WT-5088 Refine clearing and setting of debug timer WT-5100 Update test format to disable readonly mode in utility
Diffstat (limited to 'src/third_party/wiredtiger/test/csuite/wt1965_col_efficiency/main.c')
-rw-r--r--src/third_party/wiredtiger/test/csuite/wt1965_col_efficiency/main.c256
1 files changed, 119 insertions, 137 deletions
diff --git a/src/third_party/wiredtiger/test/csuite/wt1965_col_efficiency/main.c b/src/third_party/wiredtiger/test/csuite/wt1965_col_efficiency/main.c
index 057d216d042..efa477f98e1 100644
--- a/src/third_party/wiredtiger/test/csuite/wt1965_col_efficiency/main.c
+++ b/src/third_party/wiredtiger/test/csuite/wt1965_col_efficiency/main.c
@@ -28,157 +28,139 @@
#include "test_util.h"
/*
- * JIRA ticket reference: WT-1965
- * Test case description: The reported issue was that column store tables
- * exhibit high CPU usage when populated with sparse record IDs.
- * Failure mode: It isn't simple to make this test case failure explicit since
- * it is demonstrating an inefficiency rather than a correctness bug.
+ * JIRA ticket reference: WT-1965 Test case description: The reported issue was that column store
+ * tables exhibit high CPU usage when populated with sparse record IDs. Failure mode: It isn't
+ * simple to make this test case failure explicit since it is demonstrating an inefficiency rather
+ * than a correctness bug.
*/
/* If changing field count also need to change set_value and get_value calls */
-#define NR_FIELDS 8
-#define NR_OBJECTS 100
-#define NR_THREADS 4
+#define NR_FIELDS 8
+#define NR_OBJECTS 100
+#define NR_THREADS 4
static uint64_t g_ts = 0;
/*
- * Each thread inserts a set of keys into the record store database. The keys
- * are generated in such a way that there are large gaps in the key range.
+ * Each thread inserts a set of keys into the record store database. The keys are generated in such
+ * a way that there are large gaps in the key range.
*/
static void *
thread_func(void *arg)
{
- TEST_OPTS *opts;
- WT_CURSOR *cursor, *idx_cursor;
- WT_SESSION *session;
- uint64_t i, ins_rotor, ins_thr_idx, thr_idx, ts;
- uint64_t *obj_data;
-
- opts = (TEST_OPTS *)arg;
- thr_idx = __wt_atomic_fetch_addv64(&opts->next_threadid, 1);
- ts = g_ts;
- obj_data = dcalloc(
- (NR_OBJECTS/NR_THREADS + 1) * NR_FIELDS, sizeof(*obj_data));
-
- testutil_check(opts->conn->open_session(
- opts->conn, NULL, NULL, &session));
-
- testutil_check(session->open_cursor(
- session, opts->uri, NULL, NULL, &cursor));
- testutil_check(session->open_cursor(
- session, "table:index", NULL, NULL, &idx_cursor));
-
- for (ins_rotor = 1; ins_rotor < 10; ++ins_rotor) {
- for (ins_thr_idx = thr_idx, i = 0; ins_thr_idx < NR_OBJECTS;
- ins_thr_idx += NR_THREADS, i += NR_FIELDS) {
-
- testutil_check(
- session->begin_transaction(session, "sync=false"));
-
- cursor->set_key(cursor, ins_thr_idx << 40 | ins_rotor);
- cursor->set_value(cursor, ts,
- obj_data[i+0], obj_data[i+1], obj_data[i+2],
- obj_data[i+3], obj_data[i+4], obj_data[i+5],
- obj_data[i+6], obj_data[i+7]);
- testutil_check(cursor->insert(cursor));
-
- idx_cursor->set_key(
- idx_cursor, ins_thr_idx << 40 | ts);
- idx_cursor->set_value(idx_cursor, ins_rotor);
- testutil_check(idx_cursor->insert(idx_cursor));
-
- testutil_check(
- session->commit_transaction(session, NULL));
-
- /* change object fields */
- ++obj_data[i + ((ins_thr_idx + ins_rotor) % NR_FIELDS)];
- ++obj_data[i +
- ((ins_thr_idx + ins_rotor + 1) % NR_FIELDS)];
-
- ++g_ts;
- /* 5K updates/sec */
- (void)usleep(1000000ULL * NR_THREADS / 5000);
- }
- }
-
- testutil_check(session->close(session, NULL));
- free(obj_data);
- return (NULL);
+ TEST_OPTS *opts;
+ WT_CURSOR *cursor, *idx_cursor;
+ WT_SESSION *session;
+ uint64_t i, ins_rotor, ins_thr_idx, thr_idx, ts;
+ uint64_t *obj_data;
+
+ opts = (TEST_OPTS *)arg;
+ thr_idx = __wt_atomic_fetch_addv64(&opts->next_threadid, 1);
+ ts = g_ts;
+ obj_data = dcalloc((NR_OBJECTS / NR_THREADS + 1) * NR_FIELDS, sizeof(*obj_data));
+
+ testutil_check(opts->conn->open_session(opts->conn, NULL, NULL, &session));
+
+ testutil_check(session->open_cursor(session, opts->uri, NULL, NULL, &cursor));
+ testutil_check(session->open_cursor(session, "table:index", NULL, NULL, &idx_cursor));
+
+ for (ins_rotor = 1; ins_rotor < 10; ++ins_rotor) {
+ for (ins_thr_idx = thr_idx, i = 0; ins_thr_idx < NR_OBJECTS;
+ ins_thr_idx += NR_THREADS, i += NR_FIELDS) {
+
+ testutil_check(session->begin_transaction(session, "sync=false"));
+
+ cursor->set_key(cursor, ins_thr_idx << 40 | ins_rotor);
+ cursor->set_value(cursor, ts, obj_data[i + 0], obj_data[i + 1], obj_data[i + 2],
+ obj_data[i + 3], obj_data[i + 4], obj_data[i + 5], obj_data[i + 6], obj_data[i + 7]);
+ testutil_check(cursor->insert(cursor));
+
+ idx_cursor->set_key(idx_cursor, ins_thr_idx << 40 | ts);
+ idx_cursor->set_value(idx_cursor, ins_rotor);
+ testutil_check(idx_cursor->insert(idx_cursor));
+
+ testutil_check(session->commit_transaction(session, NULL));
+
+ /* change object fields */
+ ++obj_data[i + ((ins_thr_idx + ins_rotor) % NR_FIELDS)];
+ ++obj_data[i + ((ins_thr_idx + ins_rotor + 1) % NR_FIELDS)];
+
+ ++g_ts;
+ /* 5K updates/sec */
+ (void)usleep(1000000ULL * NR_THREADS / 5000);
+ }
+ }
+
+ testutil_check(session->close(session, NULL));
+ free(obj_data);
+ return (NULL);
}
int
main(int argc, char *argv[])
{
- TEST_OPTS *opts, _opts;
- WT_CURSOR *cursor;
- WT_SESSION *session;
- pthread_t thr[NR_THREADS];
- size_t t;
- uint64_t f[NR_FIELDS], r, ts;
- int i, ret;
- char table_format[256];
-
- opts = &_opts;
- memset(opts, 0, sizeof(*opts));
- testutil_check(testutil_parse_opts(argc, argv, opts));
- testutil_make_work_dir(opts->home);
-
- testutil_check(wiredtiger_open(opts->home, NULL,
- "create,cache_size=1G,checkpoint=(wait=30),"
- "eviction_trigger=80,eviction_target=64,eviction_dirty_target=65,"
- "log=(enabled,file_max=10M),"
- "transaction_sync=(enabled=true,method=none)", &opts->conn));
- testutil_check(opts->conn->open_session(
- opts->conn, NULL, NULL, &session));
-
- testutil_check(__wt_snprintf(
- table_format, sizeof(table_format), "key_format=r,value_format="));
- for (i = 0; i < NR_FIELDS; i++)
- strcat(table_format, "Q");
-
- /* recno -> timestamp + NR_FIELDS * Q */
- testutil_check(session->create(
- session, opts->uri, table_format));
- /* timestamp -> recno */
- testutil_check(session->create(session,
- "table:index", "key_format=Q,value_format=Q"));
-
- testutil_check(session->close(session, NULL));
-
- for (t = 0; t < NR_THREADS; ++t)
- testutil_check(
- pthread_create(&thr[t], NULL, thread_func, opts));
-
- for (t = 0; t < NR_THREADS; ++t)
- (void)pthread_join(thr[t], NULL);
-
- testutil_check(opts->conn->open_session(
- opts->conn, NULL, NULL, &session));
-
- /* recno -> timestamp + NR_FIELDS * Q */
- testutil_check(session->create(session, opts->uri, table_format));
-
- testutil_check(session->open_cursor(
- session, opts->uri, NULL, NULL, &cursor));
-
- while ((ret = cursor->next(cursor)) == 0) {
- testutil_check(cursor->get_key(cursor, &r));
- testutil_check(cursor->get_value(cursor, &ts,
- &f[0], &f[1], &f[2], &f[3], &f[4], &f[5], &f[6], &f[7]));
-
- if (!opts->verbose)
- continue;
-
- printf("(%" PRIu64 ",%llu)\t\t%" PRIu64,
- (r >> 40), r & ((1ULL << 40) - 1), ts);
-
- for (i = 0; i < NR_FIELDS; i++)
- printf("\t%" PRIu64, f[i]);
- printf("\n");
- }
- testutil_assert(ret == WT_NOTFOUND);
-
- testutil_cleanup(opts);
- return (EXIT_SUCCESS);
+ TEST_OPTS *opts, _opts;
+ WT_CURSOR *cursor;
+ WT_SESSION *session;
+ pthread_t thr[NR_THREADS];
+ size_t t;
+ uint64_t f[NR_FIELDS], r, ts;
+ int i, ret;
+ char table_format[256];
+
+ opts = &_opts;
+ memset(opts, 0, sizeof(*opts));
+ testutil_check(testutil_parse_opts(argc, argv, opts));
+ testutil_make_work_dir(opts->home);
+
+ testutil_check(wiredtiger_open(opts->home, NULL,
+ "create,cache_size=1G,checkpoint=(wait=30),"
+ "eviction_trigger=80,eviction_target=64,eviction_dirty_target=65,"
+ "log=(enabled,file_max=10M),"
+ "transaction_sync=(enabled=true,method=none)",
+ &opts->conn));
+ testutil_check(opts->conn->open_session(opts->conn, NULL, NULL, &session));
+
+ testutil_check(__wt_snprintf(table_format, sizeof(table_format), "key_format=r,value_format="));
+ for (i = 0; i < NR_FIELDS; i++)
+ strcat(table_format, "Q");
+
+ /* recno -> timestamp + NR_FIELDS * Q */
+ testutil_check(session->create(session, opts->uri, table_format));
+ /* timestamp -> recno */
+ testutil_check(session->create(session, "table:index", "key_format=Q,value_format=Q"));
+
+ testutil_check(session->close(session, NULL));
+
+ for (t = 0; t < NR_THREADS; ++t)
+ testutil_check(pthread_create(&thr[t], NULL, thread_func, opts));
+
+ for (t = 0; t < NR_THREADS; ++t)
+ (void)pthread_join(thr[t], NULL);
+
+ testutil_check(opts->conn->open_session(opts->conn, NULL, NULL, &session));
+
+ /* recno -> timestamp + NR_FIELDS * Q */
+ testutil_check(session->create(session, opts->uri, table_format));
+
+ testutil_check(session->open_cursor(session, opts->uri, NULL, NULL, &cursor));
+
+ while ((ret = cursor->next(cursor)) == 0) {
+ testutil_check(cursor->get_key(cursor, &r));
+ testutil_check(
+ cursor->get_value(cursor, &ts, &f[0], &f[1], &f[2], &f[3], &f[4], &f[5], &f[6], &f[7]));
+
+ if (!opts->verbose)
+ continue;
+
+ printf("(%" PRIu64 ",%llu)\t\t%" PRIu64, (r >> 40), r & ((1ULL << 40) - 1), ts);
+
+ for (i = 0; i < NR_FIELDS; i++)
+ printf("\t%" PRIu64, f[i]);
+ printf("\n");
+ }
+ testutil_assert(ret == WT_NOTFOUND);
+
+ testutil_cleanup(opts);
+ return (EXIT_SUCCESS);
}