From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Matt Armstrong Newsgroups: gmane.emacs.devel Subject: Re: Enabling native compilation by default when libgccjit is present Date: Tue, 07 Dec 2021 08:02:20 -0800 Message-ID: <87czm81jzn.fsf@rfc20.org> References: <83wnkm94oq.fsf@gnu.org> <87y251vdeh.fsf@gnus.org> <87lf11tlzf.fsf@gnus.org> <87r1atrsp9.fsf@gnus.org> <8735n85fa5.fsf@gnus.org> <87r1arskmq.fsf@gnus.org> <87r1arsjpu.fsf@yahoo.com> <87ilw3sjlr.fsf@gnus.org> <87r1ar4mi2.fsf@gmail.com> <874k7nw32n.fsf@gnus.jao.io> <87mtlfasg4.fsf@telefonica.net> <83zgpd28km.fsf@gnu.org> <83o85t25d2.fsf@gnu.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="14539"; mail-complaints-to="usenet@ciao.gmane.io" Cc: ofv@wanadoo.es, rms@gnu.org, emacs-devel@gnu.org To: Eli Zaretskii , Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Dec 07 17:03:09 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 1mucvt-0003b2-CB for ged-emacs-devel@m.gmane-mx.org; Tue, 07 Dec 2021 17:03:09 +0100 Original-Received: from localhost ([::1]:51214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mucvs-0006j9-CX for ged-emacs-devel@m.gmane-mx.org; Tue, 07 Dec 2021 11:03:08 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:53366) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mucvI-0005vc-BQ for emacs-devel@gnu.org; Tue, 07 Dec 2021 11:02:32 -0500 Original-Received: from relay8-d.mail.gandi.net ([217.70.183.201]:41245) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mucvG-0002Is-05; Tue, 07 Dec 2021 11:02:32 -0500 Original-Received: (Authenticated sender: matt@rfc20.org) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 3FA121BF210; Tue, 7 Dec 2021 16:02:22 +0000 (UTC) Original-Received: from matt by naz with local (Exim 4.95) (envelope-from ) id 1mucv6-001Q8p-B6; Tue, 07 Dec 2021 08:02:20 -0800 In-Reply-To: <83o85t25d2.fsf@gnu.org> Received-SPF: pass client-ip=217.70.183.201; envelope-from=matt@rfc20.org; helo=relay8-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, 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" Xref: news.gmane.io gmane.emacs.devel:281260 Archived-At: Eli Zaretskii writes: >> From: Stefan Monnier >> Cc: rms@gnu.org, ofv@wanadoo.es, emacs-devel@gnu.org >> Date: Mon, 06 Dec 2021 08:57:40 -0500 >> >> > I don't think this could fly in practice, because I see no way of >> > predicting when it will provide a benefit. >> >> I'm pretty sure it can fly in some practice, but I think it would have >> to be a JIT rather than AOT compiler: rather than having to predict the >> proportion of time spent in subrs vs time spent in bytecode.c, it could >> measure it and (re)compile the parts that seem most promising. >> I think Java's HotSpot compiler was among the firsts to do this kind >> of thing, but I expect it's fairly widespread in JIT compilers nowadays. > > Sounds like a good idea for a PhD. Indeed, PhDs have been completed in this area. Beyond hot spot, JIT in dynamic languages can use other techniques, such as specializing the JITed code to the concrete types the code sees in practice, etc. I'm not an expert so I'll stop there. I find the approach taken by Ruby's new YJIT interesting. They achieve low "warm up time" before reaching peak performance, and the approach doesn't significantly reduce the performance of not-yet-JITed code. https://shopify.engineering/yjit-just-in-time-compiler-cruby is a good summary. The primary lead on he project recently got a PhD in the technique used. I don't see any technical barriers preventing Emacs and/or Guile from taking the same kinds of approach, but it would be a large effort, requiring deep expertise. It might make more sense to do it in Guile, in the hopes of making Guile Emacs an attractive proposition.