Changeset: 1ff793275a63 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1ff793275a63
Modified Files:
        gdk/gdk_bbp.c
        gdk/gdk_utils.c
        testing/Mtest.py.in
Branch: Dec2023
Log Message:

Improve test for whether all free bats are in a free list.


diffs (114 lines):

diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -4915,7 +4915,8 @@ BBPprintinfo(void)
        int nh = 0;
 
        BBPtmlock();
-       for (bat i = 1, sz = (bat) ATOMIC_GET(&BBPsize); i < sz; i++) {
+       bat sz = (bat) ATOMIC_GET(&BBPsize);
+       for (bat i = 1; i < sz; i++) {
                MT_lock_set(&GDKswapLock(i));
                if (BBP_refs(i) > 0 || BBP_lrefs(i) > 0) {
                        BAT *b = BBP_desc(i);
@@ -4947,9 +4948,13 @@ BBPprintinfo(void)
                }
                MT_lock_unset(&GDKswapLock(i));
        }
+       uint32_t nfree = BBP_nfree;
        BBPtmunlock();
-       printf("%d persistent bats using %zu virtual memory (%zu malloced)\n", 
pn, pvm, pmem);
-       printf("%d transient bats using %zu virtual memory (%zu malloced)\n", 
tn, tvm, tmem);
+       printf("%d persistent bats using %zu virtual memory (%zu malloced)\n",
+              pn, pvm, pmem);
+       printf("%d transient bats using %zu virtual memory (%zu malloced)\n",
+              tn, tvm, tmem);
        printf("%d bats are \"hot\" (i.e. currently or recently used)\n", nh);
-       printf("%"PRIu32" bats are in global free list\n", BBP_nfree);
+       printf("%d bats total, %"PRIu32" free bats in common shared list\n",
+              sz - 1, nfree);
 }
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -2060,6 +2060,7 @@ GDKprintinfo(void)
        size_t allocated = (size_t) ATOMIC_GET(&GDK_mallocedbytes_estimate);
        size_t vmallocated = (size_t) ATOMIC_GET(&GDK_vm_cursize);
 
+       printf("SIGUSR1 info start\n");
        printf("Virtual memory allocated: %zu, of which %zu with malloc\n",
               vmallocated + allocated, allocated);
        printf("gdk_vm_maxsize: %zu, gdk_mem_maxsize: %zu\n",
@@ -2093,4 +2094,5 @@ GDKprintinfo(void)
        dump_threads();
        for (struct prinfocb *p = prinfocb; p; p = p->next)
                (*p->func)();
+       printf("SIGUSR1 info end\n");
 }
diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -64,6 +64,11 @@ mapiportre = re.compile(r'mapi:monetdb:/
 
 geos_version = '@GEOS_VERSION@'.split('.')
 
+# free bats, used bats, total bats
+fbre = re.compile(r' (?P<bats>\d+) free bats')
+ubre = re.compile(r'^(?P<bats>\d+) (persistent|transient) bats')
+tbre = re.compile(r'^(?P<bats>\d+) bats total')
+
 # default is no color (these three functions may get redefined)
 def prred(str):
     print(str, end='')
@@ -1468,9 +1473,7 @@ def PerformDir(env, testdir, testlist, t
                     nbats, maxid = crs.fetchall()[0]
                     crs.close()
                     dbh.close()
-                    if maxid > nbats and maxid - nbats > 10000:
-                        pSrvr.outfile.write(f'Too many free bats.  Max ID = 
{maxid}, # used = {nbats}, diff = {maxid - nbats}.\n')
-                        pSrvr.sendusr1()
+                    pSrvr.sendusr1()
                 pSrvr.terminate()
                 pSrvr = None
                 if produce_html:
@@ -1480,10 +1483,31 @@ def PerformDir(env, testdir, testlist, t
                         o.write('<head><title>{} standard 
{}</title></head>\n'.format(TSTDIR, 'output' if ext == 'out' else 'error'))
                         o.write('<body>\n')
                         empty = True
+                        sigusr1 = False
+                        nfree = 0
+                        nused = 0
+                        ntotal = 0
                         for line in openutf8(os.path.join(TSTTRGDIR, 
f'SingleServer.{ext}')):
                             if empty:
                                 o.write('<pre>\n')
                             empty = False
+                            if 'SIGUSR1 info start' in line:
+                                sigusr1 = True
+                                line = '#' + line
+                            elif 'SIGUSR1 info end' in line:
+                                sigusr1 = False
+                                line = '#' + line
+                            elif sigusr1:
+                                res = fbre.search(line)
+                                if res is not None:
+                                    nfree += int(res.group('bats'))
+                                res = ubre.search(line)
+                                if res is not None:
+                                    nused += int(res.group('bats'))
+                                res = tbre.search(line)
+                                if res is not None:
+                                    ntotal = int(res.group('bats'))
+                                line = '#' + line
                             span1 = span2 = ''
                             if line != '\n' and not line.startswith('#'):
                                 if ext == 'out':
@@ -1494,6 +1518,8 @@ def PerformDir(env, testdir, testlist, t
                                 span2 = '</span>\n'
                                 line = line.rstrip('\n')
                             o.write(span1 + line.replace('&', 
'&amp;').replace('<', '&lt;').replace('>', '&gt;') + span2)
+                        if nused + nfree != ntotal:
+                            o.write(f'<span style="background-color: 
rgb(100%,0%,0%);">Mismatch in free bats: total bats = {ntotal}, #free = 
{nfree}, #used = {nused}</span>\n')
                         o.write('{}\n</body>\n</html>\n'.format('<p>(nothing 
to see here)</p>' if empty else '</pre>'))
                         o.close()
                 else:
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to