From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: =?UTF-8?Q?Cl=c3=a9ment_Pit-Claudel?= Newsgroups: gmane.emacs.devel Subject: Re: Try and detect common problems in lexical code Date: Fri, 20 Mar 2020 12:47:06 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="5821"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Mar 20 17:47:52 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 1jFKoK-0001Q7-6G for ged-emacs-devel@m.gmane-mx.org; Fri, 20 Mar 2020 17:47:52 +0100 Original-Received: from localhost ([::1]:56068 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jFKoJ-0000zt-6o for ged-emacs-devel@m.gmane-mx.org; Fri, 20 Mar 2020 12:47:51 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51043) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jFKnf-0000Kn-Ag for emacs-devel@gnu.org; Fri, 20 Mar 2020 12:47:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jFKne-0008Ou-2W for emacs-devel@gnu.org; Fri, 20 Mar 2020 12:47:11 -0400 Original-Received: from mail-qk1-x729.google.com ([2607:f8b0:4864:20::729]:46102) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jFKnd-0008Oi-Us for emacs-devel@gnu.org; Fri, 20 Mar 2020 12:47:10 -0400 Original-Received: by mail-qk1-x729.google.com with SMTP id f28so7454811qkk.13 for ; Fri, 20 Mar 2020 09:47:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=3vFH3XeH0ePgaWaitgkfw9sGtCv+6dde5hukdarAw48=; b=JAYp1YnPnNOLFLa3TF7QvfGD11Ya7LocYKniYpneCUAg10SF3EOLK+qrPuTwZXYeIW PPe3Q99aXbjt+D29bHjcjb+x0AdxXaBewZWHtzXY6ZVrEjs6XbA2dKrW9OnXAqDtt/tN fnkf5uta4QpjHfcbjUDZrk0gnmYkR4W0jro0HzRUJkgSXr8OEzzcJ4w2MPkSN+HLYM2w R45t27CIOk4OfJnOeN/M+sd1Bp1FEFqrF0Qho7nUbq4hVPHi8im3iNyR30Bvu333jFh0 pJThXTZukFytZ8t62WkasYEa2JSgTPcin/7Bt0pDf1Q0tKZ//0GySpAcyc60y8eoZi1e W/aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=3vFH3XeH0ePgaWaitgkfw9sGtCv+6dde5hukdarAw48=; b=ro7mWbXUcoVArQjocfadA+yAScw3Up685kLuk5QFP9e5xUfMr2hscjJ3gwbyIMXLgn Qsi7fZA00X+37MF9OrYTaJxBG+Ee1bbPBMl++SHXoe3NFf56mPwlbYfNjghfKP5NydW0 VfYJ8lkuPIr6Z6/ZGxPb52OrMok27coJKBa6w0ZsMwDN56d+Wyj3vt5RlKwpS4dUuO5+ lB6Vl0qdho4m6vFZoaoZ0LnAwb7VWKJdnqOtHxwqJ5rAV/AtLgT8JniCaiWKuIB1HZyI ggyEbtBibXtL9tu3eFXxedR7UDCFY6pR+sUzK1B9SGZ60C9kHobwn7h23S/LYs36RnUe mtqA== X-Gm-Message-State: ANhLgQ0ObuGpbvsF4wPYIF2k8Hci2Z0qKCiKVps/iHNmG0MyloT5EcWy WNpkJtqjhhv0qYVs9rQOGlgEoYX5 X-Google-Smtp-Source: ADFU+vsb5a1/IOJqLrq/GDrfdSjE2BZDuylRF4hjwl2rxN26CwWG2OU9A2hC9jr7vwsu8smv+YXdCg== X-Received: by 2002:a37:a551:: with SMTP id o78mr4022220qke.453.1584722828444; Fri, 20 Mar 2020 09:47:08 -0700 (PDT) Original-Received: from ?IPv6:2601:184:4180:66e7:b9ec:a7c2:617d:8aac? ([2601:184:4180:66e7:b9ec:a7c2:617d:8aac]) by smtp.googlemail.com with ESMTPSA id w21sm4315267qkf.60.2020.03.20.09.47.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 Mar 2020 09:47:08 -0700 (PDT) In-Reply-To: Content-Language: en-GB X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::729 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:245605 Archived-At: On 18/03/2020 20.00, Stefan Monnier wrote: >>> 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. Btw, we already do something like this in defvaralias, to make sure that the variable being aliased isn't already let-bound.