From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tomas Hlavaty Newsgroups: gmane.emacs.devel Subject: funcall consing Date: Fri, 31 Dec 2021 12:01:09 +0100 Message-ID: <87ee5tm422.fsf@logand.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32906"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Dec 31 12:03:22 2021 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 1n3Fgv-0008Ry-2n for ged-emacs-devel@m.gmane-mx.org; Fri, 31 Dec 2021 12:03:21 +0100 Original-Received: from localhost ([::1]:36092 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n3Fgt-0003hU-PT for ged-emacs-devel@m.gmane-mx.org; Fri, 31 Dec 2021 06:03:19 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:54320) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n3Fez-0002Aj-ER for emacs-devel@gnu.org; Fri, 31 Dec 2021 06:01:21 -0500 Original-Received: from logand.com ([37.48.87.44]:35952) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n3Fex-0008O1-BF for emacs-devel@gnu.org; Fri, 31 Dec 2021 06:01:20 -0500 Original-Received: by logand.com (Postfix, from userid 1001) id 0AB6119EC86; Fri, 31 Dec 2021 12:01:11 +0100 (CET) X-Mailer: emacs 27.2 (via feedmail 11-beta-1 I) Received-SPF: pass client-ip=37.48.87.44; envelope-from=tom@logand.com; helo=logand.com X-Spam_score_int: 0 X-Spam_score: -0.0 X-Spam_bar: / X-Spam_report: (-0.0 / 5.0 requ) SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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:283729 Archived-At: Hi, in order to optimize some elisp code, I am trying to understand where my consing comes from. So far it looks like that my assumption about the cause of consing are wrong and that the cause of consing is funcall. Is that plausible? I am seeing similar results like this (lexical-binding, also byte compiled): (benchmark-run 10 (dotimes (i 100000) (1+ i))) ;;(2.720941123 40 1.7525918699999998) (let ((x (lambda (i) (1+ i)))) (benchmark-run 10 (dotimes (i 100000) (funcall x i)))) ;;(4.9373091140000005 80 3.4835688719999958) i.e. funcall conses a lot and introduces cca double performance penalty. Is that right or am I doing something wrong? Would it be possible to improve that? Thank you in advance Tomas