Jeroen Demeyer on Wed, 20 Jan 2016 10:34:41 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PATCH] Guard stack size warnings with DEBUGMEM


On 2016-01-14 10:31, Jeroen Demeyer wrote:
I don't like random warnings about the stack size to appear, what do you
think of this patch?

You could even make debugmem=1 the default if you want.

This is a better version of my initial patch. It makes the stack size warnings appear only if debugmem>0. However, it also sets debugmem=1 the default such that nothing will change in practice.

Jeroen.
>From fabe701c04b418a9d38f7e38f87663df018a402e Mon Sep 17 00:00:00 2001
From: Jeroen Demeyer <jdemeyer@cage.ugent.be>
Date: Thu, 14 Jan 2016 10:13:39 +0100
Subject: [PATCH 2/2] Use DEBUGMEM for stack size warnings

---
 src/functions/default/debugmem |  7 ++++---
 src/language/init.c            | 12 ++++++++----
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/functions/default/debugmem b/src/functions/default/debugmem
index a7dfcfe..fba7262 100644
--- a/src/functions/default/debugmem
+++ b/src/functions/default/debugmem
@@ -5,12 +5,13 @@ C-Name: sd_debugmem
 Prototype:
 Help:
 Doc: memory debugging level. If it is non-zero, \kbd{gp} will regularly print
- information on memory usage. If it's greater than 2, it will indicate any
- important garbage collecting and the function it is taking place in
+ information on memory usage. It will also display a warning whenever the
+ stack size has changed. If \kbd{debugmem} is at least 2, it will indicate
+ any important garbage collecting and the function it is taking place in
  (see~\b{gm}).
 
  \noindent {\bf Important Note:} As it noticeably slows down the performance,
  the first functionality (memory usage) is disabled if you're not running a
  version compiled for debugging (see Appendix~A).
 
- The default value is \kbd{0} (no debugging messages).
+ The default value is \kbd{1} (few debugging messages).
diff --git a/src/language/init.c b/src/language/init.c
index fa5c167..374375f 100644
--- a/src/language/init.c
+++ b/src/language/init.c
@@ -502,7 +502,8 @@ pari_init_defaults(void)
 #endif
 
   precdl = 16;
-  DEBUGFILES = DEBUGLEVEL = DEBUGMEM = 0;
+  DEBUGFILES = DEBUGLEVEL = 0;
+  DEBUGMEM = 1;
   disable_color = 1;
   logstyle = logstyle_none;
 
@@ -722,7 +723,8 @@ parivstack_resize(ulong newsize)
   evalstate_reset();
   paristack_setsize(pari_mainstack->rsize, newsize);
   s = pari_mainstack->vsize ? pari_mainstack->vsize : pari_mainstack->rsize;
-  pari_warn(warner,"new maximum stack size = %lu (%.3f Mbytes)", s, s/1048576.);
+  if (DEBUGMEM)
+    pari_warn(warner,"new maximum stack size = %lu (%.3f Mbytes)", s, s/1048576.);
   pari_init_errcatch();
   cb_pari_err_recover(-1);
 }
@@ -736,7 +738,8 @@ paristack_newrsize(ulong newsize)
     pari_mainstack_resize(pari_mainstack, newsize, vsize);
   evalstate_reset();
   s = pari_mainstack->rsize;
-  pari_warn(warner,"new stack size = %lu (%.3f Mbytes)", s, s/1048576.);
+  if (DEBUGMEM)
+    pari_warn(warner,"new stack size = %lu (%.3f Mbytes)", s, s/1048576.);
   pari_init_errcatch();
   cb_pari_err_recover(-1);
 }
@@ -750,7 +753,8 @@ paristack_resize(ulong newsize)
   newsize = maxuu(minuu(newsize, vsize), pari_mainstack->size);
   pari_mainstack->size = newsize;
   pari_mainstack->bot = pari_mainstack->top - pari_mainstack->size;
-  pari_warn(warner,"increasing stack size to %lu",newsize);
+  if (DEBUGMEM)
+    pari_warn(warner,"increasing stack size to %lu",newsize);
 }
 
 void
-- 
2.0.5