From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Re: Bignum performance Date: Mon, 14 Aug 2023 10:42:48 +0800 Message-ID: <87v8dimjiv.fsf@yahoo.com> References: <20230809094655.793FC18A4654@snark.thyrsus.com> <87il9owg0f.fsf@yahoo.com> <83fs4rjq9j.fsf@gnu.org> <87jzu2tvfc.fsf@dataswamp.org> <87y1ih3mc1.fsf@localhost> <87h6p5kcek.fsf@dataswamp.org> <87msyxoj2t.fsf@localhost> <875y5lkb4b.fsf@dataswamp.org> <87bkfdsmde.fsf@localhost> <87v8dlihc5.fsf@dataswamp.org> <87il9l1i59.fsf@localhost> <87edk9icis.fsf@dataswamp.org> <871qg84qij.fsf@localhost> <871qg8l03q.fsf@dataswamp.org> <877cpzl357.fsf@localhost> <87sf8ni85u.fsf@dataswamp.org> <87ttt3fdjt.fsf@localhost> <877cpyicv1.fsf@dataswamp.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26855"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Aug 14 04:43:36 2023 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 1qVNYN-0006q2-J5 for ged-emacs-devel@m.gmane-mx.org; Mon, 14 Aug 2023 04:43:35 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qVNXr-00066y-6k; Sun, 13 Aug 2023 22:43:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qVNXq-00066n-Cj for emacs-devel@gnu.org; Sun, 13 Aug 2023 22:43:02 -0400 Original-Received: from sonic315-21.consmr.mail.ne1.yahoo.com ([66.163.190.147]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qVNXn-0007KP-9h for emacs-devel@gnu.org; Sun, 13 Aug 2023 22:43:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1691980976; bh=DKlYZQBo4xCvbCOeF1ULZ6R/OKjSrNhryo3J9LW5s78=; h=From:To:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=HAiUhnHZe3U58cSc0gO+bNrZw6syIGacQIPaOCjm+XEkps1GJY+y2ba07GpmwVA/7+e6zcy7dIozwyLb3v/jStRvnqUhzMD9NsBN2CCYS44l4UTE4ODYQ32AudhxNfuiwNTL6vxNLGcx/eOEsHfLuIssP4y5QujZ1sJzv2bpw5RmUlA2f8v97y3ajloONe52h3iE5W94jtrGdc5cZtzU8TqGorJ4kHI/q296zfrllrymn3uCZh+5EU+oxFgctq7nQP6lFmCv6BJMhBU3xAlcg4UdV7eBOflYs1VIwfSW5pGwlvt9BuVQVcTFTH04jaAWep4M7KaJn/n2u4jtKdS0QA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1691980976; bh=ObCwpvt7rXFyY/kn0TMnUWL+w/mMLrfmhzk2e1n064l=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=AfEfH2Q5orZ3kvLMR427nQsjRSbTngaQlVqtUz8p+LzpIY0JrcJ916fxBgxccxTzBVGUpIK0Z7PSB6868MPfJUaKD1lTYtGjPhVGQG7dpvlWlCQvh405idzq3f5XL7bIz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fuYYVugekOy2e8sImkBx7cA X-Sonic-MF: X-Sonic-ID: e295a619-4220-4ba7-9fe6-9fcbeaebc4a4 Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic315.consmr.mail.ne1.yahoo.com with HTTP; Mon, 14 Aug 2023 02:42:56 +0000 Original-Received: by hermes--production-sg3-69654d8bd-l9pxw (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 858ed49bf5e64a8937d4d47038cf41fc; Mon, 14 Aug 2023 02:42:52 +0000 (UTC) In-Reply-To: <877cpyicv1.fsf@dataswamp.org> (Emanuel Berg's message of "Mon, 14 Aug 2023 04:20:18 +0200") X-Mailer: WebService/1.1.21695 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=66.163.190.147; envelope-from=luangruo@yahoo.com; helo=sonic315-21.consmr.mail.ne1.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:308698 Archived-At: Emanuel Berg writes: > Ihor Radchenko wrote: > >>>> In practice, as more generic benchmarks demonstrated, we >>>> only had 10% performance hit. Not something to claim that >>>> Elisp is much slower compared to CL. >>> >>> What do you mean, generic +10% is a huge improvement. >> >> It is, but it is also tangent to comparison between Elisp >> and CL. The main (AFAIU) difference between Elisp and CL is >> in how the bignums are stored. Elisp uses its own internal >> object type while CL uses GMP's native format. > > GMP = GNU Multiple Precision Arithmetic Library. > > https://en.wikipedia.org/wiki/GNU_Multiple_Precision_Arithmetic_Library > >> And we have huge overheads converting things back-and-forth >> between GMP and Elisp formats. It is by choice. And my patch >> did not do anything about this difference. AFAIU, no conversion takes place between ``Elisp formats'' and GMP formats. Our bignums rely on GMP for all data storage and memory allocation. struct Lisp_Bignum { union vectorlike_header header; mpz_t value; <-------------------- GMP type } GCALIGNED_STRUCT; and finally: INLINE mpz_t const * bignum_val (struct Lisp_Bignum const *i) { return &i->value; } INLINE mpz_t const * xbignum_val (Lisp_Object i) { return bignum_val (XBIGNUM (i)); }