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: igc, macOS avoiding signals Date: Fri, 03 Jan 2025 21:55:45 +0200 Message-ID: <86zfk7fz9a.fsf@gnu.org> References: <799DDBC5-2C14-4476-B1E0-7BA2FE9E7901@toadstyle.org> <87msgdkt29.fsf@gmail.com> <86h66lnjrt.fsf@gnu.org> <868qrxnfrw.fsf@gnu.org> <87a5ccl2zx.fsf@gmail.com> <875xn0p3l1.fsf@protonmail.com> <86ldvwm190.fsf@gnu.org> <87cyh8nczh.fsf@protonmail.com> <867c7fncom.fsf@gnu.org> <87pll3ivzs.fsf@gmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30618"; mail-complaints-to="usenet@ciao.gmane.io" Cc: pipcet@protonmail.com, gerd.moellmann@gmail.com, spd@toadstyle.org, emacs-devel@gnu.org To: Helmut Eller Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jan 03 20:56:37 2025 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 1tTnme-0007mt-Nw for ged-emacs-devel@m.gmane-mx.org; Fri, 03 Jan 2025 20:56:36 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tTnlw-0002pH-Rg; Fri, 03 Jan 2025 14:55:52 -0500 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 1tTnlu-0002ot-Sp for emacs-devel@gnu.org; Fri, 03 Jan 2025 14:55:50 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tTnlu-00047c-D4; Fri, 03 Jan 2025 14:55:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=YJ+OhucAnt6dlCsp4PiBTrOFHGN65Aio/E5CBYfQm+w=; b=dFhxUrDiBFax aUE/dXp0+3L2PMYJV6xzL/AXlY4WcDS2Hfdk7xXnBjkZEjx0ZIpa3O4n/fFCGHmWiQPnwQELY+voT WVf8UdZ6IfQU2+U0J+cJra3SuaHIa3G3xKLkY3eLlS730kOt5jS70hisIvoyK33AQlwb6nO1PG/MZ ZO7Cnq9yEpZWFxm7+QVz4UJ8nOrVCopZWPgOeMbmL0PM3ivE7+OZcPYFkWSRezjfW7NMSF3iSaStd hwckMFvuT0IKerRHekBRzl8cGwMgQ/LkeiVVsqnjVOmrE+qlQ+J2kVn3/6bKXF6KG6Iu2GDMN4ZH1 SpQEfugYz9Wp8h93GJ9Emg==; In-Reply-To: <87pll3ivzs.fsf@gmail.com> (message from Helmut Eller on Fri, 03 Jan 2025 19:37:59 +0100) 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:327635 Archived-At: > From: Helmut Eller > Cc: Pip Cet , gerd.moellmann@gmail.com, > spd@toadstyle.org, emacs-devel@gnu.org > Date: Fri, 03 Jan 2025 19:37:59 +0100 > > On Tue, Dec 31 2024, Eli Zaretskii wrote: > > We'd need to add a new function to process_pending_signals, which > > would process SIGPROF and maybe also SIGALRM. The signal handlers for > > those would then only set a flag (not pending_signals, some other > > flag). > > I implemented this with the two attached patches. The trouble is that, > the recorded backtraces are not same. This can be seen by looking at > the call tree produced by profiler.el and the attached profiler-test.el. > When add_sample is called in the signal handler, then the call tree for > the foo example looks so: > > ... > 1986 100% main > 1986 100% record-samples > 1986 100% foo > 1074 54% float-time > 0 0% ... > > When add_sample is called from process_pending_signals, it looks like > this: > > ... > 1986 100% main > 1986 100% record-samples > 1986 100% foo > 0 0% ... > > Not the absence of float-time. The reason for this is, that in > bytecode.c, maybe_quit is called before the function is pushed to the > backtrace with record_in_backtrace. In the second patch, I moved this > call forward to before the function is popped with lisp_eval_depth--. > With this patch, the call tree includes float-time again: > > ... > 1989 100% main > 1989 100% record-samples > 1989 100% foo > 1981 99% float-time > 0 0% ... > > However, float-time has now 99% as opposed to 54% in the first call > tree. > > A more complex pair of call trees is attached in the files > bar-0.report and bar-2.report. A significant difference there is > in this section: > > ... > 781 73% animate-place-char > 19 1% delete-char > 16 1% floor > 4 0% undo-auto--undoable-change > 4 0% undo-auto--boundary-ensure-timer > 96 9% insert-char > 14 1% undo-auto--undoable-change > 6 0% undo-auto--boundary-ensure-timer > 5 0% beginning-of-line > 232 21% move-to-column > ... > > compared to the version with both patches applied: > > ... > 693 72% animate-place-char > 32 3% delete-char > 29 3% window-start > 43 4% insert-char > 309 32% move-to-column > 222 23% beginning-of-line > 8 0% undo-auto--undoable-change > 8 0% undo-auto--boundary-ensure-timer > 8 0% run-at-time > 8 0% timer-set-function > 8 0% timerp > 8 0% vectorp > ... > > E.g. the percentage attributed to beginning-of-line is quite different > in those two versions (23% and 0%). > > I'm not sure if those differences are acceptable. I also have no good > idea how to reduce it, except inserting more calls to maybe_quit. Thanks. I guess this means we don't call maybe_quit frequently enough to produce accurate profiles using this method.