From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: eval proposals Date: Fri, 06 Jun 2014 12:58:26 -0400 Message-ID: References: <5391DF55.5090608@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1402073941 11108 80.91.229.3 (6 Jun 2014 16:59:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 6 Jun 2014 16:59:01 +0000 (UTC) Cc: Emacs development discussions To: Dmitry Antipov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jun 06 18:58:54 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WsxTd-0001pj-Oa for ged-emacs-devel@m.gmane.org; Fri, 06 Jun 2014 18:58:49 +0200 Original-Received: from localhost ([::1]:48507 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsxTd-0006sx-Ed for ged-emacs-devel@m.gmane.org; Fri, 06 Jun 2014 12:58:49 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34509) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsxTS-0006gR-Sz for emacs-devel@gnu.org; Fri, 06 Jun 2014 12:58:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WsxTI-0004C2-6k for emacs-devel@gnu.org; Fri, 06 Jun 2014 12:58:38 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:16231) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsxTI-0004Bv-37 for emacs-devel@gnu.org; Fri, 06 Jun 2014 12:58:28 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArUGAIDvNVPO+IOj/2dsb2JhbABZgwaDSsA9gRcXdIIlAQEBAQIBViMFCwsOJhIUGA0kiAQI0hkXiUyEV1cHhDgElGKUN4Fqg0whgS0 X-IPAS-Result: ArUGAIDvNVPO+IOj/2dsb2JhbABZgwaDSsA9gRcXdIIlAQEBAQIBViMFCwsOJhIUGA0kiAQI0hkXiUyEV1cHhDgElGKUN4Fqg0whgS0 X-IronPort-AV: E=Sophos;i="4.97,753,1389762000"; d="scan'208";a="66044124" Original-Received: from 206-248-131-163.dsl.teksavvy.com (HELO pastel.home) ([206.248.131.163]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 06 Jun 2014 12:58:27 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id D52AB600D1; Fri, 6 Jun 2014 12:58:26 -0400 (EDT) In-Reply-To: <5391DF55.5090608@yandex.ru> (Dmitry Antipov's message of "Fri, 06 Jun 2014 19:33:41 +0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:172401 Archived-At: > 1) Protection against C stack overflow caused by enormously huge > `max-lisp-eval-depth'. Note that the stack size limit is examined > just once (because doing it each time when eval_sub or funcall is > called introduces too much overhead), but some OSes are capable to > change this limit when the program is running (prlimit on Linux, > for example). max-lisp-eval-depth exists in large part in order to avoid such stack overflows, so if we do like you suggest, we might want to get rid of max-lisp-eval-depth (tho this would have the disadvantage that infinite-recursion would get caught much later). Also we want some way to get into the debugger when hitting that error, which requires more stack space. Doing both max-lisp-eval-depth and stack_guard at every eval_sub and Ffuncall sounds too costly. Maybe a better mechanism would be one that checks the value of max-lisp-eval-depth (which only needs to be done when max-lisp-eval-depth changes, which is very rare). Of course, the correlation between lisp_eval_depth and actual stack depth is not perfect, but it should be good enough if we include enough fudge factor. > 2) Capability to shrink specpdl stack if it becomes too large. > When `max-specpdl-size' is 83200000 and `max-lisp-eval-depth' is > 640000, this extreme example with 10K let bindings: > > (defun f () > (let ((x0 0) > (x1 1) > ... > (x9999 9999)) (f))) > > creates 73622255-slots specpdl stack before running out of C stack > on my system, which results in 2.5G RSS. And currently there is no > way to reduce it back to reasonable size. I'm not necessarily opposed to shrinking the specpdl, but this example is *really* not compelling: - The code doesn't look like anything I've seen. - max-specpdl-size defaults to 1300, IIRC, which is pretty damn very far from 83200000. - max-lisp-eval-depth defaults to 600 IIRC, which is pretty damn very far from 640000. - Your example runs out of C stack, so it doesn't work anyway. Stefan