From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Gerd_M=C3=B6llmann?= Newsgroups: gmane.emacs.devel Subject: Re: igc, macOS avoiding signals Date: Sat, 04 Jan 2025 08:01:13 +0100 Message-ID: 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> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30461"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , Pip Cet , 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 Sat Jan 04 08:02:16 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 1tTyAp-0007ll-73 for ged-emacs-devel@m.gmane-mx.org; Sat, 04 Jan 2025 08:02:15 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tTyA7-0001qR-Rz; Sat, 04 Jan 2025 02:01:32 -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 1tTyA1-0001pP-QU for emacs-devel@gnu.org; Sat, 04 Jan 2025 02:01:27 -0500 Original-Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tTy9w-00065j-7L; Sat, 04 Jan 2025 02:01:22 -0500 Original-Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3863703258fso8079024f8f.1; Fri, 03 Jan 2025 23:01:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735974075; x=1736578875; darn=gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=qU8MQhLKB/XZJ465putm8xiGxzIY8FkKPKDn6KlwR5o=; b=V9bIjPtQKl+Yu/1NOfwgioeH7iyYqB5fHfrsxaUGOBKdH+JXRgCC3QGFE5yMwbH5fw fB5iW3mbnwRl9kMszjNu/2Suh5qNtEfgXv6WIfD9dOQ/OxoKNl9d5GL9saEoTSUje/0m 3RQ2ZWnAxedfZMPfYVlEm5A711beViENFaFISh76gs12iB6N4FM4WPZqXdY0OiGjva++ kgrH8Hf8YZz+6JSZlgWPhX5Kf7ZNa6tbUbOpV1D4kb03CWLwXE1EVyiIa+GlFpnRNDZB M85DAUC0ao7RwnwvNNDyf2OI9aeY10pB59BFUOFkPWJQnWT6sA25RI3tIvXdQ8iIWBxz DtaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735974075; x=1736578875; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qU8MQhLKB/XZJ465putm8xiGxzIY8FkKPKDn6KlwR5o=; b=AHQuqFM5hT6qQAd2ULW3Rmy7XvF5YeUJ937WSiF8W58DVIrvL78wlpXLyhIZfbagHk mnsV2JD35ktoB5jM8RuzGXl9RmpOHmHxnRR3sv4/nqyNd8xg9qGHpt3w8AtIEZ1cn6uM R+NqU0X0aFwsM0nXcnRb4+EgNZ9iFmd/emTisJWosMBFfuMJajG60fjPoxESW/hvFSYY a0zr13TXAmH5ozLDbL1aa04SKcz9ztHJVEuV8YIUF00Qz89mWofVBqWBhXodPerHfgma JxIPimx7RKMgdDDJ7VwN7z6BUhZufhrT5z6q6ZTXgcrTsBc7768YJMRIlFih5xDT1dlS Li4A== X-Forwarded-Encrypted: i=1; AJvYcCW2vNnggn7DG/YzACQJk8WP+Yv/jZ7G75a+YvKc4vxQrm7k0US/uUNI4p/K7kpOWtbTFoSc/V2XUM4GvA==@gnu.org X-Gm-Message-State: AOJu0YyjD9af3ltf6W8RcvJM/ZuNVe98wbIKoV2rsqb07iKALaive6EX cPh1klhaidzGEGqXX+tMgE7KVo7iUzFyBdDGmZFSepbNpZjv/hMvhQOpAQ== X-Gm-Gg: ASbGncsHzqI+lRIyib15RQZZ0RyYSmYtyltkHlEaTPz0hB2iTENFcxoZ1N/18R753vB LzzoIPnj/aqlOWauX4vENWS0tFPeA4YWb0PBuCOUWcy6ydOiPUerUiBTqOk1PV0X4fwBy2ALU14 61H/nLJPTtD6HMnrUDMRU/IKu80y5zu0hD36a21nH17cjSKTHCeeZJK7gMYTFfcRQdRSoTKz7cd YqSwqxtH+Py9KnKI6uYi4Ab3pjIQJWI81N+5aWKZhzlOeMKnMH8Zho2ne/8S5gN+6zPpf9+kS4a jeqWavRq2GdbW/h7U9tXYFLk0JBBUDcWsGGXF9Kt0fT3tUFvPN27wuje1KHpp+j8jw== X-Google-Smtp-Source: AGHT+IHtaSiKFSVv3YaYgKa7Yyx2S+LG9BP9yh7+soARaJU8EAXXFHq2l1XSmGc7f/PcegFH3XT9Fg== X-Received: by 2002:a05:6000:1864:b0:388:c61d:4415 with SMTP id ffacd0b85a97d-38a22a2d914mr39592296f8f.18.1735974075172; Fri, 03 Jan 2025 23:01:15 -0800 (PST) Original-Received: from pro2 (p200300e0b73c9f00c50ae305bf989514.dip0.t-ipconnect.de. [2003:e0:b73c:9f00:c50a:e305:bf98:9514]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8b874asm42412262f8f.109.2025.01.03.23.01.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2025 23:01:14 -0800 (PST) In-Reply-To: <87pll3ivzs.fsf@gmail.com> (Helmut Eller's message of "Fri, 03 Jan 2025 19:37:59 +0100") Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=gerd.moellmann@gmail.com; helo=mail-wr1-x42d.google.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, 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:327651 Archived-At: Helmut Eller writes: > 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. > > (In eval_sub and Ffuncall, it would also help the profiler to move the > maybe_quit call forward before lisp_eval_depth--. This would only matter > for interpreted functions, not in byte compiled code. Curiously, > apply_lambda doesn't call maybe_quit at all.) > > Helmut Doesn't matter much at this point, probably, but I'm feeling a bit uneasy about the pending_profiler_signals count. Say we get two SIGPROFs that we can't record samples for, for some reason. The signals occur at times t0 and t1. We then add_sample(2) at t2 > t1 with the assumption that sample(t1) is close to sample(t2) so to speak, which I find okay if t2 is close enough to t1. When we use a count of 2 though, we kind of also assumes that sample(t0) is close to samole(t1). Is that okay? Not sure.