From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Profiling native-compilation Date: Fri, 23 Apr 2021 13:47:53 +0300 Message-ID: <83im4dnup2.fsf@gnu.org> References: <83mttpo4rv.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4437"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Andrea Corallo Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Apr 23 12:49:16 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 1lZtN5-0000q6-Q2 for ged-emacs-devel@m.gmane-mx.org; Fri, 23 Apr 2021 12:49:15 +0200 Original-Received: from localhost ([::1]:54136 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lZtN4-0005O9-Tq for ged-emacs-devel@m.gmane-mx.org; Fri, 23 Apr 2021 06:49:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56510) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lZtLv-0004bh-BR for emacs-devel@gnu.org; Fri, 23 Apr 2021 06:48:04 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:44276) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lZtLu-0005Be-Sk; Fri, 23 Apr 2021 06:48:02 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2434 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1lZtLt-0000Y3-Tg; Fri, 23 Apr 2021 06:48:02 -0400 In-Reply-To: (message from Andrea Corallo on Fri, 23 Apr 2021 08:45:44 +0000) 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:268311 Archived-At: > From: Andrea Corallo > Cc: emacs-devel@gnu.org > Date: Fri, 23 Apr 2021 08:45:44 +0000 > > AFAIK profiling syncronous native compilation with profile.el should be > possible but with one caveat that is: we run the final pass in a > subprocess so we'll loose visibility on that, OTOH we can consider final > being essentially all libgccjit work. The "final pass" being what in this case? which function call initiates that final pass? > Maybe that's the reason why you see low percentages? Have you profiled a > `native-compile' invocation? Yes, I've profiled the invocation of native-compile. (Btw, it signaled an error near the end.) Is there a way to invoke native compilation in an interactive session while preventing the last pass from being run in a subprocess? > > I think this is important because native-compilation is quite slow, > > and at least I don't have a clear idea where most of that time is > > spent. Andrea, you said once that most of the time is spent in > > libgccjit functions, which I find strange, since those are basically > > parts of GCC code, and I don't think I ever saw such slow compilation > > times from GCC. > > Yes I mentioned that but since we changed the layout of generated code > for storing immediates GCC got way faster and now the Emacs side is > about equally responsible for the time spent in compilation. Which is why it's important to see where the time is spent, so that we could work on perhaps speeding it up. > One simple approach to get an idea of where time is spent in the > compiler is to bind `comp-log-time-report' to get a report pass by pass. That's a start, but it doesn't help to identify the hot spots. > Running: > > === > (require 'comp) > (let ((comp-log-time-report t)) > (native-compile ".../emacs2/lisp/emacs-lisp/byte-opt.el")) > === > > I get: > > Done compiling .../.emacs.d/eln-cache/28.0.50-7f3f9b99/byte-opt-9c5f25f5-d2005e8f.eln > Pass comp-spill-lap took: 0.095720s. > Pass comp-limplify took: 0.423704s. > Pass comp-fwprop took: 3.334509s. > Pass comp-call-optim took: 0.023363s. > Pass comp-ipa-pure took: 0.000046s. > Pass comp-add-cstrs took: 0.222719s. > Pass comp-fwprop took: 2.549254s. > Pass comp-tco took: 0.000044s. > Pass comp-fwprop took: 0.256151s. > Pass comp-remove-type-hints took: 0.025859s. > Pass comp-final took: 4.268238s. That's very fast. I don't think I see such short times. Here's my result, almost 4 times slower: Pass comp-spill-lap took: 1.281250s. Pass comp-limplify took: 1.500000s. Pass comp-fwprop took: 11.078125s. Pass comp-call-optim took: 0.000000s. Pass comp-ipa-pure took: 0.000000s. Pass comp-add-cstrs took: 0.625000s. Pass comp-fwprop took: 8.750000s. Pass comp-tco took: 0.000000s. Pass comp-fwprop took: 0.906250s. Pass comp-remove-type-hints took: 0.000000s. Pass comp-final took: 27.375000s. Note that I ran this in an unoptimized build of Emacs, so any Lisp, bytecode, and calls into primitives are expected to be between 3 and 4 times slower than in an optimized build. How much elapsed time does it take you to compile comp.el itself? > I think would be interesting to sort by priority what I think are the > three main ares to work on the native compiler on the post merge phase: > compile-time, generated code performance, hardening, documentation. They are all equally important, IMO. I hope we can work on them in parallel. I didn't mean to imply that you personally must work on all of them (which would then make them more sequential tasks). Thanks.