Changeset: eac76cdd246d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/eac76cdd246d
Modified Files:
gdk/gdk_system.h
sql/common/sql_list.c
sql/common/sql_types.c
sql/include/sql_list.h
sql/server/sql_semantic.c
sql/storage/sql_catalog.c
sql/storage/store.c
Branch: default
Log Message:
Got rid of the ht_lock field.
The one place where there was potentially a need for the lock has been
changed so that no lock is needed anymore.
diffs (truncated from 423 to 300 lines):
diff --git a/gdk/gdk_system.h b/gdk/gdk_system.h
--- a/gdk/gdk_system.h
+++ b/gdk/gdk_system.h
@@ -230,51 +230,36 @@ gdk_export void MT_thread_set_qry_ctx(Qr
TRC_DEBUG(TEM, "Locking %s complete\n", (l)->name); \
} while (0)
-#define _DBG_LOCK_INIT(l) \
- do { \
- (l)->count = 0; \
- ATOMIC_INIT(&(l)->contention, 0); \
- ATOMIC_INIT(&(l)->sleep, 0); \
- (l)->locker = NULL; \
- (l)->thread = NULL; \
- /* if name starts with "sa_" don't link in GDKlocklist */ \
- /* since the lock is in memory that is governed by the */ \
- /* SQL storage allocator, and hence we have no control */ \
- /* over when the lock is destroyed and the memory freed */ \
- if (strncmp((l)->name, "sa_", 3) != 0) { \
- while (ATOMIC_TAS(&GDKlocklistlock) != 0) \
- ; \
- if (GDKlocklist) \
- GDKlocklist->prev = (l); \
- (l)->next = GDKlocklist; \
- (l)->prev = NULL; \
- GDKlocklist = (l); \
- ATOMIC_CLEAR(&GDKlocklistlock); \
- } else { \
- (l)->next = NULL; \
- (l)->prev = NULL; \
- } \
+#define _DBG_LOCK_INIT(l) \
+ do { \
+ (l)->count = 0; \
+ ATOMIC_INIT(&(l)->contention, 0); \
+ ATOMIC_INIT(&(l)->sleep, 0); \
+ (l)->locker = NULL; \
+ (l)->thread = NULL; \
+ while (ATOMIC_TAS(&GDKlocklistlock) != 0) \
+ ; \
+ if (GDKlocklist) \
+ GDKlocklist->prev = (l); \
+ (l)->next = GDKlocklist; \
+ (l)->prev = NULL; \
+ GDKlocklist = (l); \
+ ATOMIC_CLEAR(&GDKlocklistlock); \
} while (0)
-#define _DBG_LOCK_DESTROY(l) \
- do { \
- /* if name starts with "sa_" don't link in GDKlocklist */ \
- /* since the lock is in memory that is governed by the */ \
- /* SQL storage allocator, and hence we have no control */ \
- /* over when the lock is destroyed and the memory freed */ \
- if (strncmp((l)->name, "sa_", 3) != 0) { \
- while (ATOMIC_TAS(&GDKlocklistlock) != 0) \
- ; \
- if ((l)->next) \
- (l)->next->prev = (l)->prev; \
- if ((l)->prev) \
- (l)->prev->next = (l)->next; \
- else if (GDKlocklist == (l)) \
- GDKlocklist = (l)->next; \
- ATOMIC_CLEAR(&GDKlocklistlock); \
- ATOMIC_DESTROY(&(l)->contention); \
- ATOMIC_DESTROY(&(l)->sleep); \
- } \
+#define _DBG_LOCK_DESTROY(l) \
+ do { \
+ while (ATOMIC_TAS(&GDKlocklistlock) != 0) \
+ ; \
+ if ((l)->next) \
+ (l)->next->prev = (l)->prev; \
+ if ((l)->prev) \
+ (l)->prev->next = (l)->next; \
+ else if (GDKlocklist == (l)) \
+ GDKlocklist = (l)->next; \
+ ATOMIC_CLEAR(&GDKlocklistlock); \
+ ATOMIC_DESTROY(&(l)->contention); \
+ ATOMIC_DESTROY(&(l)->sleep); \
} while (0)
#else
diff --git a/sql/common/sql_list.c b/sql/common/sql_list.c
--- a/sql/common/sql_list.c
+++ b/sql/common/sql_list.c
@@ -31,7 +31,6 @@ list_init(list *l, sql_allocator *sa, fd
.sa = sa,
.destroy = destroy,
};
- MT_lock_init(&l->ht_lock, "sa_ht_lock");
}
return l;
}
@@ -109,7 +108,6 @@ list_destroy2(list *l, void *data)
if (l) {
node *n = l->h;
- MT_lock_destroy(&l->ht_lock);
l->h = NULL;
if (l->destroy || l->sa == NULL) {
while (n) {
@@ -153,16 +151,13 @@ list_append_node(list *l, node *n)
l->t = n;
l->cnt++;
if (n->data) {
- MT_lock_set(&l->ht_lock);
if (l->ht) {
int key = l->ht->key(n->data);
if (hash_add(l->ht, key, n->data) == NULL) {
- MT_lock_unset(&l->ht_lock);
return NULL;
}
}
- MT_lock_unset(&l->ht_lock);
}
return l;
}
@@ -200,16 +195,13 @@ list_append_with_validate(list *l, void
}
l->t = n;
l->cnt++;
- MT_lock_set(&l->ht_lock);
if (l->ht) {
int key = l->ht->key(data);
if (hash_add(l->ht, key, data) == NULL) {
- MT_lock_unset(&l->ht_lock);
return NULL;
}
}
- MT_lock_unset(&l->ht_lock);
return NULL;
}
@@ -251,16 +243,13 @@ list_append_sorted(list *l, void *data,
}
}
l->cnt++;
- MT_lock_set(&l->ht_lock);
if (l->ht) {
int key = l->ht->key(data);
if (hash_add(l->ht, key, data) == NULL) {
- MT_lock_unset(&l->ht_lock);
return NULL;
}
}
- MT_lock_unset(&l->ht_lock);
return NULL;
}
@@ -281,16 +270,13 @@ list_append_before(list *l, node *m, voi
p->next = n;
}
l->cnt++;
- MT_lock_set(&l->ht_lock);
if (l->ht) {
int key = l->ht->key(data);
if (hash_add(l->ht, key, data) == NULL) {
- MT_lock_unset(&l->ht_lock);
return NULL;
}
}
- MT_lock_unset(&l->ht_lock);
return l;
}
@@ -307,16 +293,13 @@ list_prepend(list *l, void *data)
n->next = l->h;
l->h = n;
l->cnt++;
- MT_lock_set(&l->ht_lock);
if (l->ht) {
int key = l->ht->key(data);
if (hash_add(l->ht, key, data) == NULL) {
- MT_lock_unset(&l->ht_lock);
return NULL;
}
}
- MT_lock_unset(&l->ht_lock);
return l;
}
@@ -357,10 +340,8 @@ list_remove_node_(list *l, node *n)
if (n == l->t)
l->t = p;
if (data) {
- MT_lock_set(&l->ht_lock);
if (l->ht && data)
hash_delete(l->ht, data);
- MT_lock_unset(&l->ht_lock);
}
l->cnt--;
assert(l->cnt > 0 || l->h == NULL);
@@ -386,10 +367,8 @@ list_remove_data(list *s, void *gdata, v
return;
for (n = s->h; n; n = n->next) {
if (n->data == data) {
- MT_lock_set(&s->ht_lock);
if (s->ht && n->data)
hash_delete(s->ht, n->data);
- MT_lock_unset(&s->ht_lock);
n->data = NULL;
list_remove_node(s, gdata, n);
break;
@@ -413,10 +392,8 @@ list_move_data(list *s, list *d, void *d
for (n = s->h; n; n = n->next) {
if (n->data == data) {
- MT_lock_set(&s->ht_lock);
if (s->ht && n->data)
hash_delete(s->ht, n->data);
- MT_lock_unset(&s->ht_lock);
n->data = NULL; /* make sure data isn't destroyed */
(void)list_remove_node_(s, n);
n->data = data;
@@ -795,10 +772,8 @@ list_hash_delete(list *l, void *data, fc
if (l && data) {
node *n = list_find(l, data, cmp);
if(n) {
- MT_lock_set(&l->ht_lock);
if (l->ht && n->data)
hash_delete(l->ht, data);
- MT_lock_unset(&l->ht_lock);
}
}
}
@@ -809,15 +784,12 @@ list_hash_add(list *l, void *data, fcmp
if (l && data) {
node *n = list_find(l, data, cmp);
if(n) {
- MT_lock_set(&l->ht_lock);
if (l->ht && n->data) {
int nkey = l->ht->key(data);
if (hash_add(l->ht, nkey, data) == NULL) {
- MT_lock_unset(&l->ht_lock);
return NULL;
}
}
- MT_lock_unset(&l->ht_lock);
}
}
return data;
@@ -826,9 +798,5 @@ list_hash_add(list *l, void *data, fcmp
void
list_hash_clear(list *l)
{
- if (l->ht) {
- MT_lock_set(&l->ht_lock);
- l->ht = NULL;
- MT_lock_unset(&l->ht_lock);
- }
+ l->ht = NULL;
}
diff --git a/sql/common/sql_types.c b/sql/common/sql_types.c
--- a/sql/common/sql_types.c
+++ b/sql/common/sql_types.c
@@ -1518,8 +1518,6 @@ types_init(sql_allocator *sa)
types = sa_list(sa);
localtypes = sa_list(sa);
funcs = sa_list(sa);
- MT_lock_set(&funcs->ht_lock);
funcs->ht = hash_new(sa, 1024, (fkeyvalue)&base_key);
- MT_lock_unset(&funcs->ht_lock);
sqltypeinit( sa );
}
diff --git a/sql/include/sql_list.h b/sql/include/sql_list.h
--- a/sql/include/sql_list.h
+++ b/sql/include/sql_list.h
@@ -24,7 +24,6 @@ typedef void (*fdestroy) (void *gdata, v
typedef struct list {
sql_allocator *sa;
sql_hash *ht;
- MT_Lock ht_lock; /* latch protecting ht */
fdestroy destroy;
node *h;
node *t;
diff --git a/sql/server/sql_semantic.c b/sql/server/sql_semantic.c
--- a/sql/server/sql_semantic.c
+++ b/sql/server/sql_semantic.c
@@ -297,7 +297,6 @@ sql_find_func_internal(mvc *sql, list *f
sql_ftype filt = (type == F_FUNC)?F_FILT:type;
if (ff) {
- MT_lock_set(&ff->ht_lock);
if (ff->ht) {
sql_hash_e *he = ff->ht->buckets[key&(ff->ht->size-1)];
if (prev) {
@@ -311,13 +310,10 @@ sql_find_func_internal(mvc *sql, list *f
if (f->type != type && f->type != filt)
continue;
if ((res = func_cmp(sql->sa, f, fname, nrargs))
!= NULL) {
- MT_lock_unset(&ff->ht_lock);
return res;
}
}
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]