unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Stefan Israelsson Tampe <stefan.itampe@gmail.com>
To: Chapi Chapo <rixed@happyleptic.org>
Cc: 13088@debbugs.gnu.org
Subject: bug#13088: stack overflow while compiling
Date: Wed, 12 Dec 2012 18:13:39 +0100	[thread overview]
Message-ID: <CAGua6m2XwFrREvoa-dXWP+FmJS+1C9zS3aovvnGhXLSGcJ8wdA@mail.gmail.com> (raw)
In-Reply-To: <20121212083335.GA2565@securactive.lan>


[-- Attachment #1.1: Type: text/plain, Size: 1750 bytes --]

Hi,

I added a patch to suggest a new environment variable.

   GUILE_STACK_SIZE_NSCM

If this is defined and setted to a reasonable number then this will be the
number
of SCM (8 byte on a 64bit arch or 4 on a 32 bit arch) to allocate to the VM
stack.

The naming might not be the best, we might want to name it VM_STACK in
stead of stack.

anyway here is a patch. I tested it to the example in the beginning of this
thread and it seams
to work just fine.

The intention is for this to be enough to close the bug.

/Stefan





On Wed, Dec 12, 2012 at 9:33 AM, <rixed@happyleptic.org> wrote:

> -[ Tue, Dec 11, 2012 at 11:29:31PM +0100, Stefan Israelsson Tampe ]----
> > Anyway in vm.c I changed the
> > #define VM_DEFAULT_STACK_SIZE (64 * 1024)
> >
> > to
> > #define VM_DEFAULT_STACK_SIZE (64 * 1024 * 64)
> >
> > and recompiled!
>
> Oh, I hadn't realized you were speaking about the VM's stack. It all makes
> sense now.
> Any inconvenient to set this stack even bigger ? How many such stacks do we
> have in a running environment ? One per thread ?
>
> > Then I can compile to tree-il. Compiling all the way does not work well,
> > But if you enter
> > scheme@(guile-user)> (compile program #:to 'value #:opts
> '(#:partial-eval?
> > #f #:cse? #f))  ;;NO OPTIMIZATION PASSES
> >
> > It will compile to.
> >
> > $7 = #<procedure 3708400 (proto server-port client-zone server-zone
> > signature-id)>
>
> Yes, I did this and as a result the compiled function was... 20% faster !?
> (note that my bench exclude the compilation time, and uses
> get-internal-run-time
> as a clock source).
>
> Thank you very much for all these advices.
> As usual, support from free software community is much better than it is
> from
> any business I've seen :-)
>
>

[-- Attachment #1.2: Type: text/html, Size: 2485 bytes --]

[-- Attachment #2: stack-size.patch --]
[-- Type: application/octet-stream, Size: 1228 bytes --]

From 1b4a49db86fa6ebf6943613fe6c1ac9728f72d30 Mon Sep 17 00:00:00 2001
From: Stefan Israelsson Tampe <stefan.itampe@gmail.com>
Date: Wed, 12 Dec 2012 17:37:44 +0100
Subject: [PATCH] vm: added stack size environment variable
 GUILE_STACK_SIZE_NSCM * libguile/vm.h in function make_vm  
 added code to use environment variable for stack size if
 defined

---
 libguile/vm.c |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/libguile/vm.c b/libguile/vm.c
index 5dec106..adde00d 100644
--- a/libguile/vm.c
+++ b/libguile/vm.c
@@ -670,7 +670,18 @@ make_vm (void)
 
   vp = scm_gc_malloc (sizeof (struct scm_vm), "vm");
 
-  vp->stack_size  = VM_DEFAULT_STACK_SIZE;
+  size_t ssz = VM_DEFAULT_STACK_SIZE;
+  SCM env_stack_size = scm_getenv( scm_from_locale_string ("GUILE_STACK_SIZE_NSCM"));
+  
+  if (scm_is_true (env_stack_size))
+    {
+      env_stack_size = scm_string_to_number (env_stack_size, scm_from_int (10));
+      if(scm_is_true (env_stack_size) 
+         && scm_is_unsigned_integer (env_stack_size, 1000, 2000000000))
+        ssz = scm_to_uint32 (env_stack_size);
+    }
+
+  vp->stack_size  = ssz;
 
 #ifdef VM_ENABLE_PRECISE_STACK_GC_SCAN
   vp->stack_base = (SCM *)
-- 
1.7.9.5


  reply	other threads:[~2012-12-12 17:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-05 16:31 bug#13088: stack overflow while compiling rixed
2012-12-06 16:01 ` Stefan Israelsson Tampe
2012-12-08 21:44   ` Stefan Israelsson Tampe
2012-12-10 12:16     ` rixed
2012-12-11 22:29       ` Stefan Israelsson Tampe
2012-12-12  8:33         ` rixed
2012-12-12 17:13           ` Stefan Israelsson Tampe [this message]
2012-12-14 12:46             ` rixed
2013-03-07 13:27             ` Andy Wingo
2013-03-07 13:26     ` Andy Wingo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGua6m2XwFrREvoa-dXWP+FmJS+1C9zS3aovvnGhXLSGcJ8wdA@mail.gmail.com \
    --to=stefan.itampe@gmail.com \
    --cc=13088@debbugs.gnu.org \
    --cc=rixed@happyleptic.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).