From unknown Fri Aug 15 02:04:28 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#78735 <78735@debbugs.gnu.org> To: bug#78735 <78735@debbugs.gnu.org> Subject: Status: feature/igc: [PATCH] Reduce the size of the kbd-buffer GC root Reply-To: bug#78735 <78735@debbugs.gnu.org> Date: Fri, 15 Aug 2025 09:04:28 +0000 retitle 78735 feature/igc: [PATCH] Reduce the size of the kbd-buffer GC root reassign 78735 emacs submitter 78735 Helmut Eller severity 78735 normal tag 78735 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 09 15:37:09 2025 Received: (at submit) by debbugs.gnu.org; 9 Jun 2025 19:37:09 +0000 Received: from localhost ([127.0.0.1]:57750 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uOiIu-0002Y5-8d for submit@debbugs.gnu.org; Mon, 09 Jun 2025 15:37:09 -0400 Received: from lists.gnu.org ([2001:470:142::17]:57994) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uOiIq-0002Vm-Qj for submit@debbugs.gnu.org; Mon, 09 Jun 2025 15:37:05 -0400 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 1uOiId-0006ug-QI for bug-gnu-emacs@gnu.org; Mon, 09 Jun 2025 15:36:51 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uOiIb-000456-Nc for bug-gnu-emacs@gnu.org; Mon, 09 Jun 2025 15:36:51 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-441ab63a415so48644295e9.3 for ; Mon, 09 Jun 2025 12:36:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1749497807; x=1750102607; darn=gnu.org; h=mime-version:user-agent:message-id:date:subject:to:from:from:to:cc :subject:date:message-id:reply-to; bh=FxrgLnE6VyxDp7YZaNOj10PNt3a9fh4QtFMflRtFl+Y=; b=kwv7xAbQb1tJ2RzWxDMp0tz2C1ywsRAO/LYpDxWt5MjQhuDHelpSGo2M0vRhEjhHiO q71rK3zO7lQrUzu3m5egikjZLXpq3OUqW7uZBiH1WqIm+iiRuD0HQLEW6gAQ2C9z2fn0 hLIL+xU6CJPb2evKiid56DoUnmFs6YkSqqqLYK13IldYEt5q2HvEfdUZgkw/rJFH8Gqb rOYV7XVv7OgCUMI7JN6hxBlfLaF61GQxgNddCQSErqQqhE69pI/TN2bKqV/XUl7VbLhU FvYbgKOK0DNXXuoKFtVwCfS9gwbIhXUQOiLHJogwVSvbXSOPAWn7C5i5U8TvUV2scAzP 6ZAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749497807; x=1750102607; h=mime-version:user-agent:message-id:date:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FxrgLnE6VyxDp7YZaNOj10PNt3a9fh4QtFMflRtFl+Y=; b=fWH5TR3c8c4WScYY5XRncIIKWWay8AFrX8nT8B8MqYxEPHZd3xd36f1ELd3DIbJCD1 n6LkTJXHRA1yNqR2kYdNLCxtdRGKZ7qMcbOm+XBV3MNkSv29/rgmZ9gp85YxLzqcbfJX GiNK7KIaYGzwQ+wUDM/RQdrj0C+42fS/FoF4LfUObK7/e7NBb0cNo9lrfhb9awiHw/WS 5BADZslX3oIgnDkmhPveksvkinCOKZcJlZPHHFt7FOn5X8qG87gkF2qx5MbiSKR0TPQv NkZOepgp3EKixZIcBTDrvhcGfrzweEwm/8iesFU6CTeiPmjymQq1TOkkof3QVq7bd5Yy +8Xw== X-Gm-Message-State: AOJu0Yy34sUG2PKsPxvFPtMwJLdwklIhWTZPfZ6fzvlYbGBIQhHEjGQT Qf4RxpRs9XQggYePeC8d/vKRLZaN+0UluJHeI2cVEFgubFegHI62mZlxDa8rlw== X-Gm-Gg: ASbGncuOiw80tBqlCCqiz22fD+O3K82LNsQ+52qzum7jhk0nB26Jhe/WZOFTDsp9qrv rw9waVdJNDNahBJ7UhKonr3B7B5DcXrncqXFPA0QbR+XLy1kJ/6nvDisc44ja5VBz6ewuKawjOM dDGmVWl/dy82N0iLEwo++sEEG6vyMPj4YCYOZBnv2Nbg9EUYbDSYZq4H0MKWY218vTerPo6u8ED kvhULCo3tGYGTwPHQlsuOxNtA8WNVDAVn0Y+BDWggKKfzd7TAwJxCB5sMAPSXghHzQSJBIQ7TYi iwvGXZETi7jlts/OMiXIX5o+p9Dpro7apXVC6RtjFcdC1bcfqRmjyhi8NN5K+oo9ECmuY3QUghD hIl2tCsEf3xm/FprjgLM= X-Google-Smtp-Source: AGHT+IENANJWap2bniZjwCdeKI0ctruYBKr6Pe2rU2GkMrOxDG47Xj1TWO9pxAzBTb+Fz4wntIrChA== X-Received: by 2002:a05:600c:1c95:b0:453:a95:f07d with SMTP id 5b1f17b1804b1-4531de05552mr220105e9.10.1749497806732; Mon, 09 Jun 2025 12:36:46 -0700 (PDT) Received: from caladan (dial-184179.pool.broadband44.net. [212.46.184.179]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4526e0563b6sm117527515e9.7.2025.06.09.12.36.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jun 2025 12:36:45 -0700 (PDT) From: Helmut Eller To: bug-gnu-emacs@gnu.org Subject: feature/igc: [PATCH] Reduce the size of the kbd-buffer GC root X-Debbugs-Cc: Date: Mon, 09 Jun 2025 21:36:45 +0200 Message-ID: <87v7p4g10y.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=eller.helmut@gmail.com; helo=mail-wm1-x334.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-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --=-=-= Content-Type: text/plain This is a proposal to reduce of the size of the kbd-buffer root. Currently the kdb-buffer is an area of ~250kb that is scanned ambiguously. With the patch, instead of tracing the entire kbd_buffer, we only scan the region from kbd_fetch_ptr - 1 to kbd_store_ptr + 1. The -1/+1 is supposed to cover the cases where MPS stops the mutator while those pointers are being updated. If the kbd_buffer is empty, then only 180 bytes are scanned. It's still scanned ambiguously. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Reduce-the-size-of-the-kbd-buffer-GC-root.patch >From d1e9eeb7d3cfea48d1037564fda50b511e80a52b Mon Sep 17 00:00:00 2001 From: Helmut Eller Date: Mon, 9 Jun 2025 18:28:10 +0200 Subject: [PATCH] Reduce the size of the kbd-buffer GC root * src/igc.c (root_create_kbd_buffer): New. (root_create_main_thread): Use it. (scan_kbd_buffer_ambig): New. The actual scan function. (next_kbd_event, prev_kbd_event): New helpers, similar to next_kbd_event in keyboard.c. * src/keyboard.c (init_keyboard): Move the GC root creation code to root_create_kbd_buffer in igc.c. --- src/igc.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/keyboard.c | 4 ---- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/igc.c b/src/igc.c index f63b0fe8c88..5f7a1a78cda 100644 --- a/src/igc.c +++ b/src/igc.c @@ -60,6 +60,7 @@ #include "thread.h" #include "treesit.h" #include "termchar.h" +#include "keyboard.h" #ifdef HAVE_WINDOW_SYSTEM #include TERM_HEADER #endif /* HAVE_WINDOW_SYSTEM */ @@ -1725,6 +1726,48 @@ scan_tty_list (mps_ss_t ss, void *start, void *end, void *closure) return MPS_RES_OK; } +static union buffered_input_event * +prev_kbd_event (union buffered_input_event *kbd_buffer, + union buffered_input_event *ptr) +{ + return ptr == kbd_buffer ? kbd_buffer + KBD_BUFFER_SIZE - 1 : ptr - 1; +} + +static union buffered_input_event * +next_kbd_event (union buffered_input_event *kbd_buffer, + union buffered_input_event *ptr) +{ + return ptr == kbd_buffer + KBD_BUFFER_SIZE - 1 ? kbd_buffer : ptr + 1; +} + +static mps_res_t +scan_kbd_buffer_ambig (mps_ss_t ss, void *start, void *end, void *closure) +{ + igc_assert (start == kbd_buffer); + igc_assert (end == kbd_buffer + ARRAYELTS (kbd_buffer)); + + /* Instead of tracing the entire kbd_buffer, only scan the region from + kbd_fetch_ptr - 1 to kbd_store_ptr + 1. The -1/+1 is supposed to + cover the cases where MPS stops the mutator while those pointers + are being updated. */ + + union buffered_input_event *fetch + = prev_kbd_event (kbd_buffer, kbd_fetch_ptr); + union buffered_input_event *store + = next_kbd_event (kbd_buffer, kbd_store_ptr); + + if (fetch < store) + return scan_ambig (ss, fetch, store, closure); + else + { + mps_res_t res + = scan_ambig (ss, fetch, kbd_buffer + KBD_BUFFER_SIZE, closure); + if (res == MPS_RES_OK) + res = scan_ambig (ss, kbd_buffer, store, closure); + return res; + } +} + /*********************************************************************** Default pad, fwd, ... ***********************************************************************/ @@ -2905,6 +2948,14 @@ root_create_tty_list (struct igc *gc) scan_tty_list, "tty-list"); } +static void +root_create_kbd_buffer (struct igc *gc) +{ + root_create (gc, kbd_buffer, kbd_buffer + ARRAYELTS (kbd_buffer), + mps_rank_ambig (), scan_kbd_buffer_ambig, NULL, + true, "kbd-buffer"); +} + static void root_create_main_thread (struct igc *gc) { @@ -4934,6 +4985,7 @@ make_igc (void) root_create_main_thread (gc); root_create_exact_ptr (gc, ¤t_thread); root_create_exact_ptr (gc, &all_threads); + root_create_kbd_buffer (gc); enable_messages (gc, true); return gc; diff --git a/src/keyboard.c b/src/keyboard.c index 72c6e4c17d8..1c2b4ba9e63 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -12892,10 +12892,6 @@ delete_kboard (KBOARD *kb) void init_keyboard (void) { -#ifdef HAVE_MPS - igc_root_create_ambig (kbd_buffer, kbd_buffer + ARRAYELTS (kbd_buffer), - "kbd-buffer"); -#endif /* This is correct before outermost invocation of the editor loop. */ command_loop_level = -1; quit_char = Ctl ('g'); -- 2.39.5 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 09 16:09:01 2025 Received: (at 78735) by debbugs.gnu.org; 9 Jun 2025 20:09:01 +0000 Received: from localhost ([127.0.0.1]:57952 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uOinj-0007wK-8F for submit@debbugs.gnu.org; Mon, 09 Jun 2025 16:09:01 -0400 Received: from mail-4316.protonmail.ch ([185.70.43.16]:18513) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uOinW-0007tJ-Ds for 78735@debbugs.gnu.org; Mon, 09 Jun 2025 16:08:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1749499719; x=1749758919; bh=LcV6dj3b4bvrxMz2HnEViXRvk6F++crDnwNMLQ9CcCQ=; 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=KDXlYaIVQbWEFX7i1k823HmsyGB+OS+NYs+OA+YE/N1rar64ihaiVxeLQqAF5zofP doOYKeH2rO75F9EIaNubgAZr23D0dXDyYgfDylDvPLF+eYT/+bBXWm6M1KL3PTC2tZ JVX2Zyl4aCiYu2s84SJQBYN2InwIeY4rDaHrjEUg2rVZCtBFsk5KGDNpP+Ma017hLe AgAHNmu2YowytHaKIfN1YpWxndTw0Og9qCnoW7aOPJyVMnWtjT5bh9Xtb8NjOnFnYj ep6FkFjf2fWNa3IFS5g1td3aIM8lwbeqtMAWiIn0FxJdX1dpovVgeU1JAUionM4eES LlG1dK59cS5xg== Date: Mon, 09 Jun 2025 20:08:36 +0000 To: Helmut Eller From: Pip Cet Subject: Re: bug#78735: feature/igc: [PATCH] Reduce the size of the kbd-buffer GC root Message-ID: <87y0u03cg0.fsf@protonmail.com> In-Reply-To: <87v7p4g10y.fsf@gmail.com> References: <87v7p4g10y.fsf@gmail.com> Feedback-ID: 112775352:user:proton X-Pm-Message-ID: cb1733aa83d308e01d9e937e36763256985794af MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78735 Cc: 78735@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) "Helmut Eller" writes: > This is a proposal to reduce of the size of the kbd-buffer root. > Currently the kdb-buffer is an area of ~250kb that is scanned > ambiguously. > > With the patch, instead of tracing the entire kbd_buffer, we only scan > the region from kbd_fetch_ptr - 1 to kbd_store_ptr + 1. The -1/+1 is > supposed to cover the cases where MPS stops the mutator while those > pointers are being updated. If the kbd_buffer is empty, then only 180 > bytes are scanned. It's still scanned ambiguously. That sounds great to me. > +static union buffered_input_event * > +prev_kbd_event (union buffered_input_event *kbd_buffer, > +=09=09union buffered_input_event *ptr) > +{ > + return ptr =3D=3D kbd_buffer ? kbd_buffer + KBD_BUFFER_SIZE - 1 : ptr = - 1; > +} > + > +static union buffered_input_event * > +next_kbd_event (union buffered_input_event *kbd_buffer, > +=09=09union buffered_input_event *ptr) > +{ > + return ptr =3D=3D kbd_buffer + KBD_BUFFER_SIZE - 1 ? kbd_buffer : ptr = + 1; > +} Just out of curiosity, is there a reason for the extra kbd_buffer argument? Since this code is replicated a few times, maybe it would be better to keep next_kbd_event in keyboard.c identical to the one in igc.c. Maybe not, though... > + union buffered_input_event *fetch > + =3D prev_kbd_event (kbd_buffer, kbd_fetch_ptr); > + union buffered_input_event *store > + =3D next_kbd_event (kbd_buffer, kbd_store_ptr); > + > + if (fetch < store) > + return scan_ambig (ss, fetch, store, closure); I think this will fail if kbd_store_ptr + 1 =3D=3D kbd_fetch_ptr (i.e. the kbd_buffer is full)? if (fetch < store - 1) should work, though, and it's not like this case is common enough to worry about scanning the same event twice. Pip From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 10 02:47:18 2025 Received: (at 78735) by debbugs.gnu.org; 10 Jun 2025 06:47:18 +0000 Received: from localhost ([127.0.0.1]:60201 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uOslQ-0000Fh-Bz for submit@debbugs.gnu.org; Tue, 10 Jun 2025 02:47:17 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:49398) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uOsl9-0000CV-4R for 78735@debbugs.gnu.org; Tue, 10 Jun 2025 02:46:59 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-450cb2ddd46so30567105e9.2 for <78735@debbugs.gnu.org>; Mon, 09 Jun 2025 23:46:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1749538012; x=1750142812; darn=debbugs.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=SHcDat1eQkYlaUb4Y0h4+tUY++YsTeqGdgGNyEqfcvc=; b=cA/qrkV6D5JB9uUf/kSwiYJdI8xQf1vkxr7Urya4y7svIQz9KJ4bSnbl8q41aMd9Zi 5EeWCbyKyVj40Q0JLO4NiqXE3vpLNfcVnd7LSqZihQaP2wl9RAnS4pzF5nqQEXljfbCU umSi7kg07qsR7102xcl/E/pCq9/uNkYSW1IyHXg9CVkppJQim8OJPaGx+kYl2MDBSfLX mqsLjMhgbGcGB3EPZyknF90EVx02L/xTsBIWGj6GQXYd6riSvD0l9S3ZeDc4I7m7642e wbrQI0ybLccmsX8+vGkJeFEaOMLtT+rq+M42/xyvC/svcyLq5to7ywIQG0eB9zfiV+yf hL2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749538012; x=1750142812; 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=SHcDat1eQkYlaUb4Y0h4+tUY++YsTeqGdgGNyEqfcvc=; b=GMTOsxM1uFSkN/fqQdf1c9M2Ak/PG5LgV53I5Jjd7M2e/MNNcz1XBeiuFpkb3EaqlW 4QRKLaVBAsEKKBIqnDk3KxPVbhuS/HZ5UxGM/jstU3Me0/2zSAY6pLmbAkbx8nN12fyi epDH2I1VXaSPYxSdN6LTE//3g3iuvMOdVs6xJtbYx5Vvs/+1JAnUfOShlpvELml/StL2 KHvGhRL0OaaYNwzFeTMR3u09biUPouo2Yj1oUsdgRQsNroOmECYIiYHtkBK8p6Jc/UiL RS85dq1u1mGxegM0Z5ZGoUEzVXokOl+QjwJZrHNjzXl0GqUeTjqFaWNFozfTiwsd8ve2 WVaw== X-Gm-Message-State: AOJu0Yw+1YkbNEnxFUzRvfYMcLCv93jwI4Yf3c7KeRJFddQvsXwss6aH gYiSK0csSP5TwVIKUD1GG4jxTT7h7stnalbGb8InzxzN7Prwj9imIsOvCEN2Hw== X-Gm-Gg: ASbGnctnyuzcFh14lwC7R5lxMjANWvHihWDO+Z0oWgPga9bgshlAIYgUIiUvTZTTgAG 9F4C6bemtJZ08vQ6baD9/txn0inWuzQnXIpo0Ta/sKGJ/MOmruOyyXUGGdy5M613vGTUjBMZH7X Pd7gWy7paWMwXTFkYvEjDmWrwjqm1KIsmGe6Ifmd+cJRWPnc+5MOx8uwgfUOqbLEuU2Hlu21u80 dg+Rlxjw6tZabE1HA87GcjQwX0OFKqJILetT1KRc9lbcFQ0kVXCLHNucm7/N7m3e5Cgi4/aKXMe 096HpL9/M8BsojHq2t48/5dqJ6T+gkgLE8Oawp4kQ+ltvNwS1gD2igsp4IRqWHEQpw+/pte13P0 rxo9C+p+nrQm3d7AfrhM= X-Google-Smtp-Source: AGHT+IFl6VhrEJ9Mg0hca1bdmcxVtm0jXSBwwdAkDdu99/5R8HZJiiuyIq+J1i3G5TzVBjM2PSqjkA== X-Received: by 2002:a05:600c:19cd:b0:43d:fa58:700e with SMTP id 5b1f17b1804b1-4531dea753fmr9810645e9.33.1749538012242; Mon, 09 Jun 2025 23:46:52 -0700 (PDT) Received: from caladan (dial-184179.pool.broadband44.net. [212.46.184.179]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45213726c44sm133799855e9.28.2025.06.09.23.46.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jun 2025 23:46:51 -0700 (PDT) From: Helmut Eller To: Pip Cet Subject: Re: bug#78735: feature/igc: [PATCH] Reduce the size of the kbd-buffer GC root In-Reply-To: <87y0u03cg0.fsf@protonmail.com> References: <87v7p4g10y.fsf@gmail.com> <87y0u03cg0.fsf@protonmail.com> Date: Tue, 10 Jun 2025 08:46:51 +0200 Message-ID: <87jz5kf604.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78735 Cc: 78735@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Mon, Jun 09 2025, Pip Cet wrote: [...] >> +static union buffered_input_event * >> +prev_kbd_event (union buffered_input_event *kbd_buffer, >> + union buffered_input_event *ptr) >> +{ >> + return ptr == kbd_buffer ? kbd_buffer + KBD_BUFFER_SIZE - 1 : ptr - 1; >> +} >> + >> +static union buffered_input_event * >> +next_kbd_event (union buffered_input_event *kbd_buffer, >> + union buffered_input_event *ptr) >> +{ >> + return ptr == kbd_buffer + KBD_BUFFER_SIZE - 1 ? kbd_buffer : ptr + 1; >> +} > > Just out of curiosity, is there a reason for the extra kbd_buffer > argument? Since this code is replicated a few times, maybe it would be > better to keep next_kbd_event in keyboard.c identical to the one in > igc.c. Maybe not, though... The extra argument avoids accessing the global variable; that's all. >> + union buffered_input_event *fetch >> + = prev_kbd_event (kbd_buffer, kbd_fetch_ptr); >> + union buffered_input_event *store >> + = next_kbd_event (kbd_buffer, kbd_store_ptr); >> + >> + if (fetch < store) >> + return scan_ambig (ss, fetch, store, closure); > > I think this will fail if kbd_store_ptr + 1 == kbd_fetch_ptr (i.e. the > kbd_buffer is full)? Hmm, indeed. > if (fetch < store - 1) > > should work, though, and it's not like this case is common enough to > worry about scanning the same event twice. Yes, that should work. Helmut From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 13 09:08:04 2025 Received: (at 78735-done) by debbugs.gnu.org; 13 Jun 2025 13:08:04 +0000 Received: from localhost ([127.0.0.1]:44445 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uQ48Z-0007ey-LB for submit@debbugs.gnu.org; Fri, 13 Jun 2025 09:08:03 -0400 Received: from mail-4322.protonmail.ch ([185.70.43.22]:46739) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uQ48X-0007eP-9b for 78735-done@debbugs.gnu.org; Fri, 13 Jun 2025 09:08:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1749820074; x=1750079274; bh=bkloxX2EmQz5SFdrqqA6O0mbKL0SYFX/ipMXS5Xn3PY=; 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=J05zz95vX1eF3zGXwccgKu69ExOO+LqQ4p9ktFFDgRkYAkpovGk+S78A2ws0DkFpV qHw7arsKXV6mIaa5g/8Lmi0XKreLUO2Wf1MK4TSf2fOJVg9/u6T7gInyT93IuVuV3N L9GS10wYO/u43y4s1bhpfriovBMV3XkUYHJYSKcnTKZjn3pyZ0IdwSYZ17J5HYfzSX iaiHv3V9nQpMWM36sMifSPR1VSnJbPKAn7jj6cPRU/OupwrUIfWb9CvG8B5hT3+lkT Xa2oGwFmTHfApde1vaA8juD4IItroUcE+g8HyDCtINU1dhJNFYQA9ljwdF7pawnOnK rkmYu4meWVRrg== Date: Fri, 13 Jun 2025 13:07:50 +0000 To: Helmut Eller From: Pip Cet Subject: Re: bug#78735: feature/igc: [PATCH] Reduce the size of the kbd-buffer GC root Message-ID: <87jz5fyel8.fsf@protonmail.com> In-Reply-To: <87jz5kf604.fsf@gmail.com> References: <87v7p4g10y.fsf@gmail.com> <87y0u03cg0.fsf@protonmail.com> <87jz5kf604.fsf@gmail.com> Feedback-ID: 112775352:user:proton X-Pm-Message-ID: baeed134294e7afb4c3f3ec9b7be4df7d3f63df9 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78735-done Cc: 78735-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) "Helmut Eller" writes: > On Mon, Jun 09 2025, Pip Cet wrote: > > [...] >>> +static union buffered_input_event * >>> +prev_kbd_event (union buffered_input_event *kbd_buffer, >>> +=09=09union buffered_input_event *ptr) >>> +{ >>> + return ptr =3D=3D kbd_buffer ? kbd_buffer + KBD_BUFFER_SIZE - 1 : pt= r - 1; >>> +} >>> + >>> +static union buffered_input_event * >>> +next_kbd_event (union buffered_input_event *kbd_buffer, >>> +=09=09union buffered_input_event *ptr) >>> +{ >>> + return ptr =3D=3D kbd_buffer + KBD_BUFFER_SIZE - 1 ? kbd_buffer : pt= r + 1; >>> +} >> >> Just out of curiosity, is there a reason for the extra kbd_buffer >> argument? Since this code is replicated a few times, maybe it would be >> better to keep next_kbd_event in keyboard.c identical to the one in >> igc.c. Maybe not, though... > > The extra argument avoids accessing the global variable; that's all. > >>> + union buffered_input_event *fetch >>> + =3D prev_kbd_event (kbd_buffer, kbd_fetch_ptr); >>> + union buffered_input_event *store >>> + =3D next_kbd_event (kbd_buffer, kbd_store_ptr); >>> + >>> + if (fetch < store) >>> + return scan_ambig (ss, fetch, store, closure); >> >> I think this will fail if kbd_store_ptr + 1 =3D=3D kbd_fetch_ptr (i.e. t= he >> kbd_buffer is full)? > > Hmm, indeed. > >> if (fetch < store - 1) >> >> should work, though, and it's not like this case is common enough to >> worry about scanning the same event twice. > > Yes, that should work. I've applied a new version of this patch, and am closing the bug. Thanks again, Helmut! Pip From unknown Fri Aug 15 02:04:28 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 12 Jul 2025 11:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator