From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: advice on reducing C stack frame size? Date: Sat, 13 Sep 2008 18:56:10 +0200 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1221324999 6811 80.91.229.12 (13 Sep 2008 16:56:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 13 Sep 2008 16:56:39 +0000 (UTC) To: guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat Sep 13 18:57:34 2008 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KeYRA-000484-5b for guile-devel@m.gmane.org; Sat, 13 Sep 2008 18:57:32 +0200 Original-Received: from localhost ([127.0.0.1]:52700 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KeYQ9-0006jc-PU for guile-devel@m.gmane.org; Sat, 13 Sep 2008 12:56:29 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KeYQ4-0006ix-Hd for guile-devel@gnu.org; Sat, 13 Sep 2008 12:56:24 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KeYQ2-0006hd-V5 for guile-devel@gnu.org; Sat, 13 Sep 2008 12:56:24 -0400 Original-Received: from [199.232.76.173] (port=33819 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KeYQ2-0006hP-RH for guile-devel@gnu.org; Sat, 13 Sep 2008 12:56:22 -0400 Original-Received: from a-sasl-fastnet.sasl.smtp.pobox.com ([207.106.133.19]:57324 helo=sasl.smtp.pobox.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KeYQ2-0006hk-FM for guile-devel@gnu.org; Sat, 13 Sep 2008 12:56:22 -0400 Original-Received: from localhost.localdomain (localhost [127.0.0.1]) by a-sasl-fastnet.sasl.smtp.pobox.com (Postfix) with ESMTP id 1A52460143 for ; Sat, 13 Sep 2008 12:56:22 -0400 (EDT) Original-Received: from unquote (177.Red-83-34-179.dynamicIP.rima-tde.net [83.34.179.177]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-sasl-fastnet.sasl.smtp.pobox.com (Postfix) with ESMTPSA id 71DAC60142 for ; Sat, 13 Sep 2008 12:56:21 -0400 (EDT) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-Pobox-Relay-ID: E4A2D65A-81B4-11DD-B7AF-D0CFFE4BC1C1-02397024!a-sasl-fastnet.pobox.com X-detected-operating-system: by monty-python.gnu.org: Solaris 10 (beta) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:7684 Archived-At: Hi, With a local patch, it seems that my C stack frames are getting large enough to start hitting the stack overflow checks. (In the future this won't be a terrible problem, as you won't be recursively calling the evaluator the the vm then the evaluator etc too much, but while we still have a fair amount of code being interpreted, it is important.) So for example, just sitting at the repl, we have: [...] #27 0x0014e99b in scm_apply (proc=0xb7f0d718, arg1=0x404, args=0x404) at eval.i.c:1656 1656 return scm_dapply (proc, arg1, args); (gdb) #28 0x001c48fc in vm_run (vm=0xb7f1ff58, program=0x8d53df8, args=0x404) at vm-i-system.c:510 510 *sp = scm_apply (x, args, SCM_EOL); (gdb) p sp - vp->stack_base $3 = 104 (gdb) up #29 0x001bfcad in program_apply (program=0xb7ee2730, args=0x404) at programs.c:126 126 return scm_vm_apply (scm_the_vm (), program, args); (gdb) p 0x001c48fc - 0x001bfcad $4 = 19535 The difference between #29 and #28 is the size of the vm_run() stack frame (I think). It is about 20 kilobytes!!! In contrast, a deval frame appears to be less, but still excessive: #19 0x0014b076 in deval (x=0xb7f3a478, env=0xb7ee2560) at eval.i.c:358 358 (void) EVAL (form, env); (gdb) #20 0x0014e72e in scm_dapply (proc=0xb7f3a6d0, arg1=, args=0xb7ee25d0) at eval.i.c:1858 1858 RETURN (EVALCAR (proc, args)); (gdb) p 0x0014e72e - 0x0014b076 $5 = 14008 This is with gcc 4.3.0 20080428 (Red Hat 4.3.0-8). My question is: what should I do about this? Wait for the runtime tuning patches to land in master and then merge them? Assume that over time, I will eliminate the need to recursively call the vm, perhaps by eliminating calls to the interpreter? Change the code for the VM to use less local blocks (like { SCM foo; do_something (); }) ? Thanks for any insight, Andy -- http://wingolog.org/