Changeset: 0cdd54169846 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/0cdd54169846
Modified Files:
monetdb5/mal/mal_client.c
Branch: resource_management
Log Message:
merge upstream
diffs (159 lines):
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -534,6 +534,7 @@ struct tm *gmtime_r(const time_t *restri
ssize_t hgeFromStr(allocator *ma, const char *src, size_t *len, hge **dst,
bool external);
ssize_t hgeToStr(allocator *ma, str *dst, size_t *len, const hge *src, bool
external);
const hge hge_nil;
+char *humansize(size_t val, char *buf, size_t buflen)
__attribute__((__access__(write_only, 2, 3)));
const inet4 inet4_nil;
const inet6 inet6_nil;
ssize_t intFromStr(allocator *ma, const char *src, size_t *len, int **dst,
bool external);
diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c
--- a/gdk/gdk_atoms.c
+++ b/gdk/gdk_atoms.c
@@ -1494,8 +1494,7 @@ INET6fromString(allocator *ma, const cha
const char *s = svalue;
if (*len < 16 || *retval == NULL) {
- GDKfree(*retval);
- if ((*retval = GDKmalloc(16)) == NULL)
+ if ((*retval = ma_alloc(ma, 16)) == NULL)
return -1;
*len = 16;
}
@@ -1675,9 +1674,7 @@ INET6toString(allocator *ma, str *retval
(void) external;
/* max size: strlen("1234:1234:1234:1234:1234:1234:1234:1234")+1 */
if (*len < 40 || *retval == NULL) {
- if (*retval)
- GDKfree(*retval);
- if ((*retval = GDKmalloc(40)) == NULL)
+ if ((*retval = ma_alloc(ma, 40)) == NULL)
return -1;
*len = 40;
}
diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h
--- a/gdk/gdk_private.h
+++ b/gdk/gdk_private.h
@@ -241,8 +241,6 @@ void HEAP_recover(Heap *, const var_t *,
gdk_return HEAPsave(Heap *h, const char *nme, const char *ext, bool dosync,
BUN free, MT_Lock *lock)
__attribute__((__warn_unused_result__))
__attribute__((__visibility__("hidden")));
-char *humansize(size_t val, char *buf, size_t buflen)
- __attribute__((__visibility__("hidden")));
double joincost(BAT *r, BUN lcount, struct canditer *rci, bool *hash, bool
*phash, bool *cand)
__attribute__((__visibility__("hidden")));
void STRMPincref(Strimps *strimps)
diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -195,7 +195,7 @@ struct thread_funcs {
};
struct mtthread {
- allocator* thread_allocator;
+ allocator *thread_allocator;
struct mtthread *next;
void (*func) (void *); /* function to be called */
void *data; /* and its data */
@@ -298,7 +298,6 @@ void
dump_threads(void)
{
char buf[1024];
- char abuf[128]; // allocator buffer
#if defined(HAVE_PTHREAD_MUTEX_TIMEDLOCK) && defined(HAVE_CLOCK_GETTIME)
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
@@ -324,17 +323,6 @@ dump_threads(void)
MT_Cond *cn = t->condwait;
struct mtthread *jn = t->joinwait;
const char *working = ATOMIC_PTR_GET(&t->working);
- if (t->thread_allocator) {
- const char *name =
- sa_name(t->thread_allocator);
- snprintf(abuf, sizeof(abuf),
- ", %s allocator %zu bytes",
- name ? name : "(unknown)",
- sa_size(t->thread_allocator));
-
- }
- else
- abuf[0] = 0;
int pos = snprintf(buf, sizeof(buf),
"%s, tid %zu, "
@@ -344,7 +332,7 @@ dump_threads(void)
#ifdef HAVE_GETTID
"LWP %ld, "
#endif
- "%"PRIu32" free bats, waiting for %s%s,
working on %.200s%s",
+ "%"PRIu32" free bats, waiting for %s%s,
working on %.200s",
t->threadname,
t->tid,
#ifdef HAVE_PTHREAD_H
@@ -357,7 +345,7 @@ dump_threads(void)
lk ? "lock " : sm ? "semaphore " : cn ?
"condvar " : jn ? "thread " : "",
lk ? lk->name : sm ? sm->name : cn ?
cn->name : jn ? jn->threadname : "nothing",
ATOMIC_GET(&t->exited) ? "exiting" :
- working ? working : "nothing", abuf);
+ working ? working : "nothing");
#ifdef LOCK_OWNER
const char *sep = ", locked: ";
for (MT_Lock *l = t->mylocks; l && pos < (int) sizeof(buf); l =
l->nxt) {
diff --git a/gdk/gdk_utils.h b/gdk/gdk_utils.h
--- a/gdk/gdk_utils.h
+++ b/gdk/gdk_utils.h
@@ -110,6 +110,8 @@ gdk_export str GDKstrndup(const char *s,
__attribute__((__malloc__(GDKfree, 1)))
__attribute__((__warn_unused_result__));
gdk_export size_t GDKmallocated(const void *s);
+gdk_export char *humansize(size_t val, char *buf, size_t buflen)
+ __attribute__((__access__(write_only, 2, 3)));
gdk_export void MT_init(void); /* init the package. */
struct opt;
diff --git a/monetdb5/mal/mal_client.c b/monetdb5/mal/mal_client.c
--- a/monetdb5/mal/mal_client.c
+++ b/monetdb5/mal/mal_client.c
@@ -440,10 +440,10 @@ MCcloseClient(Client c)
c->mode = FREECLIENT;
c->idx = -1;
}
+ MT_thread_setallocator(NULL);
ma_destroy(c->ma);
c->ta = NULL;
c->ma = NULL;
- MT_thread_setallocator(NULL);
MT_lock_unset(&mal_contextLock);
}
diff --git a/sql/backends/monet5/sql_scenario.c
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -175,10 +175,10 @@ CLIENTprintinfo(void)
ma_used += sa_size(be->mvc->pa);
}
if (ma_used)
- snprintf(mabuf, sizeof(mabuf), ", Allocators
combined: %zu bytes", ma_used);
+ snprintf(mabuf, sizeof(mabuf), ", allocators
combined: %zu%s bytes", ma_used, humansize(ma_used, (char[24]){0}, 24));
else
mabuf[0] = 0;
- printf("client %d, user %s, thread %s, using %"PRIu64"
bytes of transient space%s%s%s%s%s%s%s%s%s%s\n", c->idx, c->username,
c->mythread ? c->mythread : "?", (uint64_t) ATOMIC_GET(&c->qryctx.datasize),
mmbuf, tmbuf, trbuf, chbuf, cabuf, clbuf, cpbuf, crbuf, qybuf, mabuf);
+ printf("client %d, user %s, thread %s, using %"PRIu64"
bytes of transient space%s%s%s%s%s%s%s%s%s%s\n", c->idx, c->username,
c->mythread ? c->mythread : "?", (uint64_t) ATOMIC_GET(&c->qryctx.datasize),
mmbuf, mabuf, tmbuf, trbuf, chbuf, cabuf, clbuf, cpbuf, crbuf, qybuf);
break;
case FINISHCLIENT:
/* finishing */
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -7881,7 +7881,8 @@ store_printinfo(sqlstore *store)
}
printf("WAL:\n");
printf("SQL store oldest pending "ULLFMT"\n", store->oldest_pending);
- printf("SQL store allocator: %zu bytes\n", sa_size(store->sa));
+ size_t sz = sa_size(store->sa);
+ printf("SQL store allocator: %zu%s\n", sz, humansize(sz, (char[24]){0},
24));
log_printinfo(store->logger);
MT_lock_unset(&store->commit);
}
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]