diff options
Diffstat (limited to 'src/third_party/wiredtiger/test/format/config.c')
-rw-r--r-- | src/third_party/wiredtiger/test/format/config.c | 182 |
1 files changed, 131 insertions, 51 deletions
diff --git a/src/third_party/wiredtiger/test/format/config.c b/src/third_party/wiredtiger/test/format/config.c index 042316d8344..1b09916bd88 100644 --- a/src/third_party/wiredtiger/test/format/config.c +++ b/src/third_party/wiredtiger/test/format/config.c @@ -35,6 +35,7 @@ static void config_encryption(void); static const char *config_file_type(u_int); static CONFIG *config_find(const char *, size_t); static void config_in_memory(void); +static void config_in_memory_check(void); static int config_is_perm(const char *); static void config_isolation(void); static void config_lrt(void); @@ -43,6 +44,7 @@ static void config_map_compression(const char *, u_int *); static void config_map_encryption(const char *, u_int *); static void config_map_file_type(const char *, u_int *); static void config_map_isolation(const char *, u_int *); +static void config_reset(void); /* * config_setup -- @@ -54,14 +56,10 @@ config_setup(void) CONFIG *cp; /* Clear any temporary values. */ - config_clear(); + config_reset(); - /* - * Periodically, run in-memory; don't do it on the first run, all our - * smoke tests would hit it. - */ - if (!config_is_perm("in_memory") && g.run_cnt % 20 == 19) - g.c_in_memory = 1; + /* Periodically run in-memory. */ + config_in_memory(); /* * Choose a data source type and a file type: they're interrelated (LSM @@ -145,7 +143,7 @@ config_setup(void) /* Some data-sources don't support user-specified collations. */ if (DATASOURCE("helium") || DATASOURCE("kvsbdb")) - g.c_reverse = 0; + config_single("reverse=off", 0); /* * Periodically, run single-threaded so we can compare the results to @@ -159,7 +157,6 @@ config_setup(void) config_compression("compression"); config_compression("logging_compression"); config_encryption(); - config_in_memory(); config_isolation(); config_lrt(); @@ -169,7 +166,7 @@ config_setup(void) * Don't do it on the first run, all our smoke tests would hit it. */ if (!g.replay && g.run_cnt % 10 == 9 && !config_is_perm("delete_pct")) - g.c_delete_pct = 0; + config_single("delete_pct=0", 0); /* * If this is an LSM run, set the cache size and crank up the insert @@ -187,9 +184,12 @@ config_setup(void) if (!config_is_perm("cache") && g.c_cache < g.c_threads) g.c_cache = g.c_threads; + /* Give in-memory configuration a final review. */ + config_in_memory_check(); + /* Make the default maximum-run length 20 minutes. */ if (!config_is_perm("timer")) - g.c_timer = 20; + config_single("timer=20", 0); /* * Key/value minimum/maximum are related, correct unless specified by @@ -329,43 +329,89 @@ config_encryption(void) /* * config_in_memory -- - * In-memory configuration. + * Periodically set up an in-memory configuration. */ static void config_in_memory(void) { + /* + * Configure in-memory before configuring anything else, in-memory has + * many related requirements. Don't configure in-memory if there's any + * incompatible configurations, so we don't have to configure in-memory + * every time we configure something like LSM, that's too painful. + */ + if (config_is_perm("backups")) + return; + if (config_is_perm("checkpoints")) + return; + if (config_is_perm("compression")) + return; + if (config_is_perm("data_source") && DATASOURCE("lsm")) + return; + if (config_is_perm("logging")) + return; + if (config_is_perm("rebalance")) + return; + if (config_is_perm("salvage")) + return; + if (config_is_perm("verify")) + return; + + if (!config_is_perm("in_memory") && mmrand(NULL, 1, 20) == 1) + g.c_in_memory = 1; +} + +/* + * config_in_memory_check -- + * In-memory configuration review. + */ +static void +config_in_memory_check(void) +{ + uint32_t cache; + if (g.c_in_memory == 0) return; /* Turn off a lot of stuff. */ if (!config_is_perm("backups")) - g.c_backups = 0; + config_single("backups=off", 0); if (!config_is_perm("checkpoints")) - g.c_checkpoints = 0; - if (!config_is_perm("compression")) { - g.c_compression = dstrdup("none"); - g.c_compression_flag = COMPRESS_NONE; - } + config_single("checkpoints=off", 0); + if (!config_is_perm("compression")) + config_single("compression=none", 0); if (!config_is_perm("logging")) - g.c_logging = 0; + config_single("logging=off", 0); if (!config_is_perm("rebalance")) - g.c_rebalance = 0; + config_single("rebalance=off", 0); if (!config_is_perm("salvage")) - g.c_salvage = 0; + config_single("salvage=off", 0); if (!config_is_perm("verify")) - g.c_verify = 0; + config_single("verify=off", 0); /* - * Ensure there is 250MB of cache per thread; keep keys/values small, - * overflow items aren't an issue for in-memory configurations and it - * keeps us from overflowing the cache. + * Keep keys/values small, overflow items aren't an issue for in-memory + * configurations and it keeps us from overflowing the cache. */ - if (!config_is_perm("cache")) - g.c_cache = g.c_threads * 250; if (!config_is_perm("key_max")) - g.c_value_max = 64; + config_single("key_max=32", 0); if (!config_is_perm("value_max")) - g.c_value_max = 128; + config_single("value_max=80", 0); + + /* + * Size the cache relative to the initial data set, use 2x the base + * size as a minimum. + */ + if (!config_is_perm("cache")) { + cache = g.c_value_max; + if (g.type == ROW) + cache += g.c_key_max; + cache *= g.c_rows; + cache *= 2; + cache /= WT_MEGABYTE; + if (g.c_cache < cache) + g.c_cache = cache; + } } /* @@ -413,11 +459,11 @@ config_lrt(void) * stores. */ if (g.type == FIX) { - if (g.c_long_running_txn && config_is_perm("long_running_txn")) + if (config_is_perm("long_running_txn")) testutil_die(EINVAL, "long_running_txn not supported with fixed-length " "column store"); - g.c_long_running_txn = 0; + config_single("long_running_txn=off", 0); } } @@ -503,18 +549,36 @@ config_file(const char *name) /* * config_clear -- - * Clear per-run values. + * Clear all configuration values. */ void config_clear(void) { CONFIG *cp; - /* Clear configuration data. */ + /* Clear all allocated configuration data. */ + for (cp = c; cp->name != NULL; ++cp) + if (cp->vstr != NULL) { + free((void *)*cp->vstr); + *cp->vstr = NULL; + } + free(g.uri); + g.uri = NULL; +} + +/* + * config_reset -- + * Clear per-run configuration values. + */ +static void +config_reset(void) +{ + CONFIG *cp; + + /* Clear temporary allocated configuration data. */ for (cp = c; cp->name != NULL; ++cp) { F_CLR(cp, C_TEMP); - if (!F_ISSET(cp, C_PERM) && - F_ISSET(cp, C_STRING) && cp->vstr != NULL) { + if (!F_ISSET(cp, C_PERM) && cp->vstr != NULL) { free((void *)*cp->vstr); *cp->vstr = NULL; } @@ -531,7 +595,7 @@ void config_single(const char *s, int perm) { CONFIG *cp; - uint32_t v; + long v; char *p; const char *ep; @@ -557,43 +621,59 @@ config_single(const char *s, int perm) exit(EXIT_FAILURE); } + /* + * Free the previous setting if a configuration has been + * passed in twice. + */ + if (*cp->vstr != NULL) { + free(*cp->vstr); + *cp->vstr = NULL; + } + if (strncmp(s, "checksum", strlen("checksum")) == 0) { config_map_checksum(ep, &g.c_checksum_flag); - *cp->vstr = strdup(ep); + *cp->vstr = dstrdup(ep); } else if (strncmp( s, "compression", strlen("compression")) == 0) { config_map_compression(ep, &g.c_compression_flag); - *cp->vstr = strdup(ep); + *cp->vstr = dstrdup(ep); } else if (strncmp( s, "encryption", strlen("encryption")) == 0) { config_map_encryption(ep, &g.c_encryption_flag); - *cp->vstr = strdup(ep); + *cp->vstr = dstrdup(ep); } else if (strncmp(s, "isolation", strlen("isolation")) == 0) { config_map_isolation(ep, &g.c_isolation_flag); - *cp->vstr = strdup(ep); + *cp->vstr = dstrdup(ep); } else if (strncmp(s, "file_type", strlen("file_type")) == 0) { config_map_file_type(ep, &g.type); - *cp->vstr = strdup(config_file_type(g.type)); + *cp->vstr = dstrdup(config_file_type(g.type)); } else if (strncmp(s, "logging_compression", strlen("logging_compression")) == 0) { config_map_compression(ep, &g.c_logging_compression_flag); - *cp->vstr = strdup(ep); + *cp->vstr = dstrdup(ep); } else { free((void *)*cp->vstr); - *cp->vstr = strdup(ep); + *cp->vstr = dstrdup(ep); } - if (*cp->vstr == NULL) - testutil_die(errno, "malloc"); return; } - v = (uint32_t)strtoul(ep, &p, 10); - if (*p != '\0') { - fprintf(stderr, "%s: %s: illegal numeric value\n", - g.progname, s); - exit(EXIT_FAILURE); + v = -1; + if (F_ISSET(cp, C_BOOL)) { + if (strncmp(ep, "off", strlen("off")) == 0) + v = 0; + else if (strncmp(ep, "on", strlen("on")) == 0) + v = 1; + } + if (v == -1) { + v = strtol(ep, &p, 10); + if (*p != '\0') { + fprintf(stderr, "%s: %s: illegal numeric value\n", + g.progname, s); + exit(EXIT_FAILURE); + } } if (F_ISSET(cp, C_BOOL)) { if (v != 0 && v != 1) { @@ -607,7 +687,7 @@ config_single(const char *s, int perm) g.progname, s, cp->min, cp->maxset); exit(EXIT_FAILURE); } - *cp->v = v; + *cp->v = (uint32_t)v; } /* |