From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Try and detect common problems in lexical code Date: Wed, 18 Mar 2020 20:00:37 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="31311"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: =?windows-1252?Q?Cl=E9ment?= Pit-Claudel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Mar 19 01:01:30 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jEicr-00082z-UI for ged-emacs-devel@m.gmane-mx.org; Thu, 19 Mar 2020 01:01:29 +0100 Original-Received: from localhost ([::1]:59916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEicr-0000Ev-16 for ged-emacs-devel@m.gmane-mx.org; Wed, 18 Mar 2020 20:01:29 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52200) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEic7-0008BC-HV for emacs-devel@gnu.org; Wed, 18 Mar 2020 20:00:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEic5-00046n-LG for emacs-devel@gnu.org; Wed, 18 Mar 2020 20:00:42 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:42108) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEic5-00044L-EH for emacs-devel@gnu.org; Wed, 18 Mar 2020 20:00:41 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id AD72F1003B1; Wed, 18 Mar 2020 20:00:40 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id D6F671002CF; Wed, 18 Mar 2020 20:00:38 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1584576038; bh=IZhMK5VHyaeZT5x3eaEDVG8/7eIA+fT6QATwB4BcKj8=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=cWX664ejf2xhNvQaJNKTNQ4NcgCVOTw7CKP/1DX9zMOmq+/i5A/E10JwHqcVXXlfT iXD1iCSxgM80JdCBC7xBiI8I/4vC+zNjxX+3xpj0Qdk5WPyrgternGxN5XUv/KYUIK i6i+bNpPonWmznqMxJGxCv5Rb3x/+e7zitCxrLdGiFmG2glxWhYYRa++cPDUFiDnzO jtemDSSUEQwG4TZ6A9r8dm167KfhvkhJ7NW4waZAt7m2cvE3BBkNVaZ/tbyIlcdM2A rqFjODnJj9jH/Z6IHie6ncQb04muA+ovF4pDDzM6lwQTUEgKS3t58pDFHBdlkrHJ+B 5EdlnQUeg/H4Q== Original-Received: from alfajor (unknown [104.247.241.114]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 9AFDA120254; Wed, 18 Mar 2020 20:00:38 -0400 (EDT) In-Reply-To: (=?windows-1252?Q?=22Cl=E9ment?= Pit-Claudel"'s message of "Wed, 18 Mar 2020 18:29:15 -0400") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 132.204.25.50 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:245575 Archived-At: >> Another difference is that this probably has a more noticeable >> performance impact > Shouldn't the cost be essentially 0 when (defvar) happens "at the toplevel", > within an empty specdpl stack? And isn't that the common case (a defvar is > a toplevel form in a file loaded by a `require')? specpdl holds all the current dynamic let-bindings, unwind_protects (and their variants), and the call backtrace info, so it's never really empty (e.g. `load` itself installs a handful of unwind_protects and let-bindings on the specpdl stack around the execution of the actual loaded code). With the use of lexical binding (especially after byte-compilation), the specpdl is typically less deep, indeed. And at the top-level of loading a file it's usually not terribly deep (unless it's an autoload that happens in the middle of a deepish recursion). So there's a chance the cost won't be significant. I just wanted to be clear that there is a possibility that the cost can be above the noise-level in some cases (e.g. files with many defvars that get (auto)loaded while we're in the middle of a deepish recursion). I haven't bothered to measure it at all, tho. Stefan