diff options
author | Luke Chen <luke.chen@mongodb.com> | 2021-06-21 15:40:39 +1000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-06-21 06:08:48 +0000 |
commit | be37944971d75246d7773d91deacb5ee3f7dcc7c (patch) | |
tree | 1d6bccd3f8692176a91c6d0c092bd1fd158c66c5 /src/third_party/wiredtiger/bench | |
parent | 71463bd8736c60f9d675d9ecdcc7b86040011c5b (diff) | |
download | mongo-be37944971d75246d7773d91deacb5ee3f7dcc7c.tar.gz |
Import wiredtiger: 7123f8deb40e1d0100eb513c93a7aa52268cab07 from branch mongodb-5.0
ref: cc7bcfd1c1..7123f8deb4
for: 5.1.0
WT-7676 Reformat wtperf backup to only read in files instead of wt_copy_and_sync
Diffstat (limited to 'src/third_party/wiredtiger/bench')
-rw-r--r-- | src/third_party/wiredtiger/bench/wtperf/misc.c | 51 | ||||
-rw-r--r-- | src/third_party/wiredtiger/bench/wtperf/wtperf.c | 4 | ||||
-rw-r--r-- | src/third_party/wiredtiger/bench/wtperf/wtperf.h | 1 |
3 files changed, 53 insertions, 3 deletions
diff --git a/src/third_party/wiredtiger/bench/wtperf/misc.c b/src/third_party/wiredtiger/bench/wtperf/misc.c index ac11d23fcea..948bb881095 100644 --- a/src/third_party/wiredtiger/bench/wtperf/misc.c +++ b/src/third_party/wiredtiger/bench/wtperf/misc.c @@ -28,6 +28,8 @@ #include "wtperf.h" +#define WT_BACKUP_COPY_SIZE (128 * 1024) + /* Setup the logging output mechanism. */ int setup_log_file(WTPERF *wtperf) @@ -102,3 +104,52 @@ lprintf(const WTPERF *wtperf, int err, uint32_t level, const char *fmt, ...) if (err == WT_PANIC) abort(); } + +/* + * backup_read -- + * Read in a file, used mainly to measure the impact of backup on a single machine. Backup is + * usually copied across different machines, therefore the write portion doesn't affect the + * machine backup is performing on. + */ +void +backup_read(WTPERF *wtperf, const char *filename) +{ + char *buf; + int rfd; + size_t len; + ssize_t rdsize; + struct stat st; + uint32_t buf_size, size, total; + + buf = NULL; + rfd = -1; + + /* Open the file handle. */ + len = strlen(wtperf->home) + strlen(filename) + 10; + buf = dmalloc(len); + testutil_check(__wt_snprintf(buf, len, "%s/%s", wtperf->home, filename)); + error_sys_check(rfd = open(buf, O_RDONLY, 0644)); + + /* Get the file's size. */ + testutil_check(stat(buf, &st)); + size = (uint32_t)st.st_size; + free(buf); + + buf = dmalloc(WT_BACKUP_COPY_SIZE); + total = 0; + buf_size = WT_MIN(size, WT_BACKUP_COPY_SIZE); + while (total < size) { + /* Use the read size since we may have read less than the granularity. */ + error_sys_check(rdsize = read(rfd, buf, buf_size)); + + /* If we get EOF, we're done. */ + if (rdsize == 0) + break; + total += (uint32_t)rdsize; + buf_size = WT_MIN(buf_size, size - total); + } + + if (rfd != -1) + testutil_check(close(rfd)); + free(buf); +} diff --git a/src/third_party/wiredtiger/bench/wtperf/wtperf.c b/src/third_party/wiredtiger/bench/wtperf/wtperf.c index 032acd855ac..4bf6dd6c1c2 100644 --- a/src/third_party/wiredtiger/bench/wtperf/wtperf.c +++ b/src/third_party/wiredtiger/bench/wtperf/wtperf.c @@ -1252,8 +1252,6 @@ backup_worker(void *arg) break; wtperf->backup = true; - /* Cleanup the data from the previous backup and create the backup directories. */ - testutil_create_backup_directory(wtperf->home); /* * open_cursor can return EBUSY if concurrent with a metadata operation, retry in that case. @@ -1266,7 +1264,7 @@ backup_worker(void *arg) while ((ret = backup_cursor->next(backup_cursor)) == 0) { testutil_check(backup_cursor->get_key(backup_cursor, &key)); - testutil_copy_file(session, key); + backup_read(wtperf, key); } if (ret != WT_NOTFOUND) { diff --git a/src/third_party/wiredtiger/bench/wtperf/wtperf.h b/src/third_party/wiredtiger/bench/wtperf/wtperf.h index 5cedb438507..14b5d55a2ed 100644 --- a/src/third_party/wiredtiger/bench/wtperf/wtperf.h +++ b/src/third_party/wiredtiger/bench/wtperf/wtperf.h @@ -261,6 +261,7 @@ struct __wtperf_thread { /* Per-thread structure */ TRACK update; /* Update operations */ }; +void backup_read(WTPERF *, const char *); void cleanup_truncate_config(WTPERF *); int config_opt_file(WTPERF *, const char *); void config_opt_cleanup(CONFIG_OPTS *); |