From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pip Cet via "Emacs development discussions." Newsgroups: gmane.emacs.devel Subject: Re: igc, macOS avoiding signals Date: Sat, 04 Jan 2025 16:02:43 +0000 Message-ID: <8734hyh8kg.fsf@protonmail.com> References: <799DDBC5-2C14-4476-B1E0-7BA2FE9E7901@toadstyle.org> <875xn0p3l1.fsf@protonmail.com> <86ldvwm190.fsf@gnu.org> <87cyh8nczh.fsf@protonmail.com> <867c7fncom.fsf@gnu.org> <87pll3ivzs.fsf@gmail.com> <87wmfaof1l.fsf@gmail.com> <868qrqd5oa.fsf@gnu.org> <87ed1iocgu.fsf@gmail.com> Reply-To: Pip Cet Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21428"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , 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 Sat Jan 04 18:38:38 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 1tU86g-0005Q9-AT for ged-emacs-devel@m.gmane-mx.org; Sat, 04 Jan 2025 18:38:38 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tU85s-0003pS-J7; Sat, 04 Jan 2025 12:37:48 -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 1tU6c4-0001S8-MO for emacs-devel@gnu.org; Sat, 04 Jan 2025 11:02:57 -0500 Original-Received: from mail-40131.protonmail.ch ([185.70.40.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tU6c1-0001cZ-HV for emacs-devel@gnu.org; Sat, 04 Jan 2025 11:02:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1736006569; x=1736265769; bh=wFuJJ/vBSlRasV/cB9VVbg+S2ZrmdYKE73u2h6bYID0=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=vyAlOJrVXvSJSkw4n5Czvar38lF/38sOxE5hS8kAcD1zEFZuD4a22ONAg0cEY2s6e Fd7DbBwHzair6sFBMMHZCpO1OAJVt5BdHHqrY4ii+eHZviBf2OxdCGrQ9X+oVJvFki UcjFuVPm6F0+6JvPFmu2u818p7IoUDJMTcoCfarKc8oPL2NYEG4YV2bfSQiaUb2yJa wWFrGFXZlMY5+W0oX+34Fz7R0NGPStrvJzmvjrmFAg3N5OeAjYYeDb2oEA7jxpQTc5 2hCGF48RgKYUBMOZGPiXIF/zzKI5RiKhzTI0DSPTcUAadHE1kx/mZJ6NzzLwCgLGTY bQCWY/v87F6nQ== In-Reply-To: <87ed1iocgu.fsf@gmail.com> Feedback-ID: 112775352:user:proton X-Pm-Message-ID: a4f425516c32186ac5aedbcc724c27be4d4c382c Received-SPF: pass client-ip=185.70.40.131; envelope-from=pipcet@protonmail.com; helo=mail-40131.protonmail.ch 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sat, 04 Jan 2025 12:37:46 -0500 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:327673 Archived-At: "Helmut Eller" writes: > On Sat, Jan 04 2025, Eli Zaretskii wrote: > >>> WDYT? >> >> I'd make these extra calls only call the SIGPROF handler if the >> counter says some signals were missed. There's no need to affect >> other handlers without a good reason. > > If I had my way, I would merge Vquit_flag and pending_signals into a > word-sized bitset like so Bitfield access isn't atomic even on x86_64, thus the array-of-ints in the current code. > union pending_signals { > uintptr_t sigset; > struct { > uintptr_t quit:1; > uintptr_t profiler:1; > uintptr_t child:1; > uintptr_t alarm:1; > uintptr_t io:1; > /* other signals */ > } s; > } pending_signals; > > Then maybe_quit and process_pending_signals would be merged into a > single function that look like this: > > void > process_pending_signals (void) > { > union pending_signals signals =3D pending_signals; > if (signals.sigset) > { > pending_signals.sigset =3D 0; This is really union pending_signals new_pending_signals =3D pending_signals; new_pending_signals.sigset =3D 0; <--- HERE pending_signals =3D new_pending_signals; If a signal handler strikes at the marked location, and sets a bit, then that bit will be unconditionally cleared by the last line. > If no signal is pending, this only needs to load and test one word > instead of two. If only one signal is pending, then it only calls that I agree we should set pending_signals when we set Vquit_flag (and merge global_igc->signals_pending and the existing flag), and simplify maybe_quit that way, but that is an optimization only. If you want to access individual bits atomically, you need to use an atomic type, and have a workaround for machines without lock-free atomics. > handler. For the rest, I'd hope that a modern branch predictor > determines quite accurately which handler will mostly likely be called. Sounds like PGO, which we can do as soon as we have a representative simulated work run. Pip