Changeset: 3ed3bd4888f4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/3ed3bd4888f4
Branch: default
Log Message:
merged
diffs (truncated from 789 to 300 lines):
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -968,8 +968,7 @@ GDKinit(opt *set, int setlen, bool embed
const char *dbpath;
const char *dbtrace;
const char *p;
- opt *n;
- int i, nlen = 0;
+ int i;
char buf[16];
if (caller_revision) {
@@ -1089,7 +1088,8 @@ GDKinit(opt *set, int setlen, bool embed
GDK_mem_maxsize = (size_t) ((double) MT_npages() * (double)
MT_pagesize() * 0.815);
const char *allow = mo_find_option(set, setlen, "allow_hge_upgrade");
const char *procwalxit = mo_find_option(set, setlen,
"process-wal-and-exit");
- if (BBPinit(allow && strcmp(allow, "yes") == 0, procwalxit &&
strcmp(procwalxit, "yes") == 0) != GDK_SUCCEED)
+ if (BBPinit(allow && strcmp(allow, "yes") == 0,
+ procwalxit && strcmp(procwalxit, "yes") == 0) !=
GDK_SUCCEED)
return GDK_FAIL;
first = false;
@@ -1099,70 +1099,75 @@ GDKinit(opt *set, int setlen, bool embed
GDK_mmap_minsize_persistent =
GDK_mmap_minsize_transient;
}
- n = (opt *) malloc(setlen * sizeof(opt));
- if (n == NULL) {
- GDKsyserror("malloc failed\n");
- return GDK_FAIL;
+ /* check some options before creating our first BAT */
+ p = mo_find_option(set, setlen, "gdk_mem_maxsize");
+ if (p) {
+ char *e;
+ GDK_mem_maxsize = (size_t) strtoll(p, &e, 10);
+ if (e && *e) {
+ TRC_CRITICAL(GDK, "gdk_mem_maxsize must be an integer");
+ return GDK_FAIL;
+ }
+ GDK_mem_maxsize = MAX(1 << 26, GDK_mem_maxsize);
+ if (GDK_mem_maxsize / 16 < GDK_mmap_minsize_transient)
+ GDK_mmap_minsize_transient = MAX(MMAP_PAGESIZE,
GDK_mem_maxsize / 16);
+ if (GDK_mmap_minsize_persistent > GDK_mmap_minsize_transient)
+ GDK_mmap_minsize_persistent =
GDK_mmap_minsize_transient;
}
-
- for (i = 0; i < setlen; i++) {
- bool done = false;
-
- for (int j = 0; j < nlen; j++) {
- if (strcmp(n[j].name, set[i].name) == 0) {
- if (n[j].kind < set[i].kind) {
- n[j] = set[i];
- }
- done = true;
- break;
- }
+ p = mo_find_option(set, setlen, "gdk_vm_maxsize");
+ if (p) {
+ char *e;
+ GDK_vm_maxsize = (size_t) strtoll(p, &e, 10);
+ if (e && *e) {
+ TRC_CRITICAL(GDK, "gdk_vm_maxsize must be an integer");
+ return GDK_FAIL;
}
- if (!done) {
- n[nlen] = set[i];
- nlen++;
+ GDK_vm_maxsize = MAX(1 << 30, GDK_vm_maxsize);
+ }
+ p = mo_find_option(set, setlen, "gdk_mmap_minsize_persistent");
+ if (p) {
+ char *e;
+ GDK_mmap_minsize_persistent = (size_t) strtoll(p, &e, 10);
+ if (e && *e) {
+ TRC_CRITICAL(GDK, "gdk_mmap_minsize_persistent must be
an integer");
+ return GDK_FAIL;
}
}
- /* check some options before creating our first BAT */
- for (i = 0; i < nlen; i++) {
- if (strcmp("gdk_mem_maxsize", n[i].name) == 0) {
- GDK_mem_maxsize = (size_t) strtoll(n[i].value, NULL,
10);
- GDK_mem_maxsize = MAX(1 << 26, GDK_mem_maxsize);
- if (GDK_mem_maxsize / 16 < GDK_mmap_minsize_transient)
- GDK_mmap_minsize_transient = MAX(MMAP_PAGESIZE,
GDK_mem_maxsize / 16);
- if (GDK_mmap_minsize_persistent >
GDK_mmap_minsize_transient)
- GDK_mmap_minsize_persistent =
GDK_mmap_minsize_transient;
- } else if (strcmp("gdk_vm_maxsize", n[i].name) == 0) {
- GDK_vm_maxsize = (size_t) strtoll(n[i].value, NULL, 10);
- GDK_vm_maxsize = MAX(1 << 30, GDK_vm_maxsize);
- } else if (strcmp("gdk_mmap_minsize_persistent", n[i].name) ==
0) {
- GDK_mmap_minsize_persistent = (size_t)
strtoll(n[i].value, NULL, 10);
- } else if (strcmp("gdk_mmap_minsize_transient", n[i].name) ==
0) {
- GDK_mmap_minsize_transient = (size_t)
strtoll(n[i].value, NULL, 10);
- } else if (strcmp("gdk_mmap_pagesize", n[i].name) == 0) {
- GDK_mmap_pagesize = (size_t) strtoll(n[i].value, NULL,
10);
- if (GDK_mmap_pagesize < 1 << 12 ||
- GDK_mmap_pagesize > 1 << 20 ||
- /* x & (x - 1): turn off rightmost 1 bit;
- * i.e. if result is zero, x is power of
- * two */
- (GDK_mmap_pagesize & (GDK_mmap_pagesize - 1)) != 0)
{
- free(n);
- TRC_CRITICAL(GDK, "gdk_mmap_pagesize must be
power of 2 between 2**12 and 2**20\n");
- return GDK_FAIL;
- }
+ p = mo_find_option(set, setlen, "gdk_mmap_minsize_transient");
+ if (p) {
+ char *e;
+ GDK_mmap_minsize_transient = (size_t) strtoll(p, &e, 10);
+ if (e && *e) {
+ TRC_CRITICAL(GDK, "gdk_mmap_minsize_transient must be
an integer");
+ return GDK_FAIL;
+ }
+ }
+ p = mo_find_option(set, setlen, "gdk_mmap_pagesize");
+ if (p) {
+ char *e;
+ GDK_mmap_pagesize = (size_t) strtoll(p, &e, 10);
+ if (e && *e) {
+ TRC_CRITICAL(GDK, "gdk_mmap_pagesize must be an
integer");
+ return GDK_FAIL;
+ }
+ if (GDK_mmap_pagesize < 1 << 12 ||
+ GDK_mmap_pagesize > 1 << 20 ||
+ /* x & (x - 1): turn off rightmost 1 bit; i.e. if
+ * result is zero, x is power of two */
+ (GDK_mmap_pagesize & (GDK_mmap_pagesize - 1)) != 0) {
+ TRC_CRITICAL(GDK, "gdk_mmap_pagesize must be power of 2
between 2**12 and 2**20\n");
+ return GDK_FAIL;
}
}
GDKkey = COLnew(0, TYPE_str, 100, TRANSIENT);
GDKval = COLnew(0, TYPE_str, 100, TRANSIENT);
if (GDKkey == NULL || GDKval == NULL) {
- free(n);
TRC_CRITICAL(GDK, "Could not create environment BATs");
return GDK_FAIL;
}
if (BBPrename(GDKkey, "environment_key") != 0 ||
BBPrename(GDKval, "environment_val") != 0) {
- free(n);
TRC_CRITICAL(GDK, "BBPrename of environment BATs failed");
return GDK_FAIL;
}
@@ -1170,13 +1175,27 @@ GDKinit(opt *set, int setlen, bool embed
BBP_pid(GDKval->batCacheid) = 0;
/* store options into environment BATs */
- for (i = 0; i < nlen; i++)
- if (GDKsetenv(n[i].name, n[i].value) != GDK_SUCCEED) {
- TRC_CRITICAL(GDK, "GDKsetenv %s failed", n[i].name);
- free(n);
+ for (i = 0; i < setlen; i++) {
+ if (set[i].kind == opt_builtin &&
+ GDKsetenv(set[i].name, set[i].value) != GDK_SUCCEED) {
+ TRC_CRITICAL(GDK, "GDKsetenv %s failed", set[i].name);
return GDK_FAIL;
}
- free(n);
+ }
+ for (i = 0; i < setlen; i++) {
+ if (set[i].kind == opt_config &&
+ GDKsetenv(set[i].name, set[i].value) != GDK_SUCCEED) {
+ TRC_CRITICAL(GDK, "GDKsetenv %s failed", set[i].name);
+ return GDK_FAIL;
+ }
+ }
+ for (i = 0; i < setlen; i++) {
+ if (set[i].kind == opt_cmdline &&
+ GDKsetenv(set[i].name, set[i].value) != GDK_SUCCEED) {
+ TRC_CRITICAL(GDK, "GDKsetenv %s failed", set[i].name);
+ return GDK_FAIL;
+ }
+ }
if (GDKgetenv_int("gdk_nr_threads", 0) != 0) {
GDKnr_threads = GDKgetenv_int("gdk_nr_threads", 0);
diff --git a/tools/mserver/monet_version.c.in b/tools/mserver/monet_version.c.in
--- a/tools/mserver/monet_version.c.in
+++ b/tools/mserver/monet_version.c.in
@@ -38,11 +38,11 @@ print_libversion(const char *lib, const
void
monet_version(void)
{
- dbl sz_mem_gb;
+ double sz_mem_gb;
int cores;
MT_init(); /* for MT_pagesize */
- sz_mem_gb = (dbl)(MT_npages() * MT_pagesize()) / (1024.0 * 1024.0 *
1024.0);
+ sz_mem_gb = ldexp((double) (MT_npages() * MT_pagesize()), -30);
if ((cores = GDKnr_threads) == 0)
cores = MT_check_nr_cores();
@@ -65,7 +65,8 @@ monet_version(void)
#ifndef MONETDB_RELEASE
printf("This is an unreleased version\n");
#endif
- printf("Copyright (C) %s MonetDB Foundation.\n", &__DATE__[7]);
+ printf("Copyright (C) %s MonetDB Foundation, all rights reserved\n",
+ &__DATE__[7]);
printf("Visit https://www.monetdb.org/ for further information\n");
printf("Found %.1fGiB available memory, %d available cpu core%s\n",
sz_mem_gb, cores, cores != 1 ? "s" : "");
diff --git a/tools/mserver/mserver5.c b/tools/mserver/mserver5.c
--- a/tools/mserver/mserver5.c
+++ b/tools/mserver/mserver5.c
@@ -330,44 +330,84 @@ wmain(int argc, wchar_t **argv)
bool inmemory = false;
bool readpwdxit = false;
static const char in_memory[] = "in-memory";
- static const struct option long_options[] = {
- {"config", required_argument, NULL, 'c'},
- {"dbextra", required_argument, NULL, 0},
- {"dbtemp", required_argument, NULL, 0},
- {"dbpath", required_argument, NULL, 0},
- {"dbtrace", required_argument, NULL, 0},
- {"debug", optional_argument, NULL, 'd'},
- {"help", no_argument, NULL, '?'},
- {"in-memory", no_argument, NULL, 0},
- {"readonly", no_argument, NULL, 'r'},
- {"set", required_argument, NULL, 's'},
- {"single-user", no_argument, NULL, 0},
- {"version", no_argument, NULL, 0},
-
- {"logging", required_argument, NULL, 0},
+ enum options {
+ /* options that correspond to short options */
+ opt_CONFIG = 'c',
+ opt_DEBUG = 'd',
+ opt_READONLY = 'r',
+ opt_SET = 's',
- {"algorithms", no_argument, NULL, 0},
- {"forcemito", no_argument, NULL, 0},
- {"heaps", no_argument, NULL, 0},
- {"io", no_argument, NULL, 0},
- {"memory", no_argument, NULL, 0},
- {"modules", no_argument, NULL, 0},
- {"performance", no_argument, NULL, 0},
- {"properties", no_argument, NULL, 0},
- {"threads", no_argument, NULL, 0},
- {"transactions", no_argument, NULL, 0},
+ /* options only available as long options */
+ opt_DBEXTRA = 1000,
+ opt_DBTEMP,
+ opt_DBPATH,
+ opt_DBTRACE,
+ opt_IN_MEMORY,
+ opt_SINGLE_USER,
+ opt_LOGGING,
+ opt_ALGORITHMS,
+ opt_FORCEMITO,
+ opt_HEAPS,
+ opt_IO,
+ opt_MEMORY,
+ opt_MODULES,
+ opt_PERFORMANCE,
+ opt_PROPERTIES,
+ opt_THREADS,
+ opt_TRANSACTIONS,
+ opt_LOADMODULE,
+ opt_WITHOUT_GEOM,
+ opt_PIPELINE,
+ opt_READ_PASSWORD_INITIALIZE_AND_EXIT,
+ opt_PROCESS_WAL_AND_EXIT,
+ opt_CLEAN_BBP,
+ opt_ACCEPT_THE_RISKS_RUNNING_AS_ROOT,
+ opt_VERSION,
+ opt_HELP,
+ };
+ static const struct option long_options[] = {
+ /* last field uniquely identifies option
+ * if letter, option is equivalent to short form option */
+ {"config", required_argument, NULL, opt_CONFIG},
+ {"dbextra", required_argument, NULL, opt_DBEXTRA},
+ {"dbtemp", required_argument, NULL, opt_DBTEMP},
+ {"dbpath", required_argument, NULL, opt_DBPATH},
+ {"dbtrace", required_argument, NULL, opt_DBTRACE},
+ {"debug", optional_argument, NULL, opt_DEBUG},
+ {"in-memory", no_argument, NULL, opt_IN_MEMORY},
+ {"readonly", no_argument, NULL, opt_READONLY},
+ {"set", required_argument, NULL, opt_SET},
+ {"single-user", no_argument, NULL, opt_SINGLE_USER},
- {"loadmodule", required_argument, NULL, 0},
- {"without-geom", no_argument, NULL, 0},
- {"pipeline", no_argument, NULL, 0},
+ {"logging", required_argument, NULL, opt_LOGGING},
- {"read-password-initialize-and-exit", no_argument, NULL, 0},
- {"process-wal-and-exit", no_argument, NULL, 0},
- {"clean-BBP", no_argument, NULL, 0},
+ {"algorithms", no_argument, NULL, opt_ALGORITHMS},
+ {"forcemito", no_argument, NULL, opt_FORCEMITO},
+ {"heaps", no_argument, NULL, opt_HEAPS},
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]