From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#53432: [PATCH] Avoid losing keyboard input when inotify is too busy Date: Sat, 22 Jan 2022 08:38:22 +0800 Message-ID: <87r190wqo1.fsf@yahoo.com> References: <25067.17249.604070.872185@chiark.greenend.org.uk> Reply-To: Po Lu Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19190"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.60 (gnu/linux) Cc: 53432@debbugs.gnu.org To: Ian Jackson Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jan 22 01:39:55 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1nB4Re-0004mT-UH for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 22 Jan 2022 01:39:55 +0100 Original-Received: from localhost ([::1]:51498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nB4Rd-0003sY-F4 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 21 Jan 2022 19:39:53 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:42706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nB4Qo-0003qs-TZ for bug-gnu-emacs@gnu.org; Fri, 21 Jan 2022 19:39:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42466) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nB4Qo-0000nK-Bp for bug-gnu-emacs@gnu.org; Fri, 21 Jan 2022 19:39:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nB4Qo-00042U-8X for bug-gnu-emacs@gnu.org; Fri, 21 Jan 2022 19:39:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 22 Jan 2022 00:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53432 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 53432-submit@debbugs.gnu.org id=B53432.164281192215494 (code B ref 53432); Sat, 22 Jan 2022 00:39:02 +0000 Original-Received: (at 53432) by debbugs.gnu.org; 22 Jan 2022 00:38:42 +0000 Original-Received: from localhost ([127.0.0.1]:35369 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nB4QU-00041q-7G for submit@debbugs.gnu.org; Fri, 21 Jan 2022 19:38:42 -0500 Original-Received: from sonic311-25.consmr.mail.ne1.yahoo.com ([66.163.188.206]:37748) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nB4QS-00041Z-2G for 53432@debbugs.gnu.org; Fri, 21 Jan 2022 19:38:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1642811913; bh=rAQDU3l8Mu+O+TUUR2T8eXydRuGkg6zLILPDLyTOfl0=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=Ay0UzXAI4xs5/tCeHaNMemX/f3WJgfxpc1ncw8lY3PQ0tMgpnj1NtGcVPgSgyhQ3XGpI+ueXidy6bVQzXc6Hz/L4mOJj1K1dTEjKrIE7oMdHj05Jqho9QzLsl+waqyhJfSaEpg7MVYiX6RVH8oCsYJMx37nqqeDaKLHusnZC0b7Tmj5wvUf9VcPgeed7YT6M8EW3xcgqEpCakqp7h1Qqjbf79V4MqCWWRZ2yzfKfyrT720XtbwYk5uNQhnyTEZUVAQv3d9BlDfgtG1Jroz7J25rguLXN0EncsbMKxUKNUstlGi3ByaQ8rgZLH3JueEHR9omgECRoUtSisxkjPTqk5Q== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1642811913; bh=1P5KzYafp/06k6mmzZh7i1P9/oiKBtYDb0lcgVlU599=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=C4RCyY6bJWuS5ALIBfqnl0tFLR1Bo0hkHiz69qOflXMmI0WqelPR9SojQaByjBqcdmnofJkQcQN69HWnkEv/WhfnYCL6U3CSiYP9TF58bWoP+ezzm/qyhjlakk0GjR16JdsrZvpjW7IVnC72ChyslKH4wk1MddMwvd0qDd+vEtoNCbuvrdeXe1uvRdrgoyHbGAjMiOEkpI8u6XaPLLweIvZfdQRcHBR/PuRro/jGwvGZSKldw1XLgELoLAhXoeDdRaNvi8zkjrsdYvrekg8vEzGcP4LRzecnIhj+Y8kzFoTgZ0vCbi4+MpsqlOz0RhmF8X3TS8So6DxZcg5+1r30mA== X-YMail-OSG: flczw9AVM1kxpN7ew1_ftDc5eziseGvKi9Gx.U9gy4QFmtRzegveOGgsscZkCWP 2H0LrJuU4yCcvUVTZ5KTybrAVDAijh1xE6bU8K.cg9ypRIP3wFyU.X1cZC93ad0gGs302Z5eEHQk sw3l6Dx0CUhW5ldf1poyYm_elhBJY17ynA5EgODbmTBgJYuFz6_8jbD5NT2yCgv8LgzJoCCkEWnm iD6eMChsMvGFa7dD99JHZqHK3shanaCxRR6EpG5Zm24d2OWldXER4fqm9yUpsMPIPSMvH4eZbpvP Iqh0QT1xR9lWOrEhduZ9QEjAkk5xiliI3zVXo1DMZ..rf8A1MIdvRMdkjHscjyMxXWkB7u_xwRG2 hBOSXvkjTFE21WuaexSq5pra9jCPKuulfqL6zkc7oFUQFl0MOnkd3xfVSgD4JZgk52wOO34vN.nB f8XNYmROO8CqwCpvjjk0ypQtK.AO2piKM9cAgIxsY6ROWF1dBtv0x03jjEFGI1O.rD4FspiCwSqt cGkJObcZclokYvtzmw7u7n9jRbT3nxQYM6lZ2etGuXlxSC44imloFJsuY2CY5Oi_l48WOFA3JCWn vu78dtvhlcjOMLTk1MFOTYJ6VljZOwJoYqugZg8dpluhOLUeCn1XB7eBDjVa25Qon6bgJfsRUPw7 i9352Qb1UMPaeGMeAAT2FJRub9yPf3h_yl0M2UBDrpvY.BDBMyrUW1QvH3jOGPBvGbRNCXQrnZI7 lOQjN6Z1JbacV57SbTsxADfRLZ1bvgNbjEgNgC7uYootUXi.DV82QUWRG7Uwael_1udxC8HkTZKT hjQu1PGjPYxS9otJeYKfItkEUa4ujuKCUH6F6VEQqX X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic311.consmr.mail.ne1.yahoo.com with HTTP; Sat, 22 Jan 2022 00:38:33 +0000 Original-Received: by kubenode504.mail-prod1.omega.sg3.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID c4405ec3a1e2c54e53b69b23d0b7e938; Sat, 22 Jan 2022 00:38:26 +0000 (UTC) In-Reply-To: <25067.17249.604070.872185@chiark.greenend.org.uk> (Ian Jackson's message of "Fri, 21 Jan 2022 23:36:01 +0000") X-Mailer: WebService/1.1.19615 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:224798 Archived-At: Ian Jackson writes: > I experienced a bug where my Emacs (Debian's emacs-lucid) would lose > keystrokes under pathological conditions. I tracked this down to the > keyboard input buffer filling up with inotify events. > > The attached patches have been rebased onto emacs-28 (fbc9b121e062) > and I have tested before-and-after versions in parallel to verify that > the bug appears in the upstream branch and has been fixed with my > patches. > > The bug was really quite severe in my (rather abusive) situation, with > Debian's emacs-lucid 26.1. With the upstream emacs-28 branch it > requires more effort, and loses fewer keys. I suspect that some more > sophisticated approach to inotify requests means it's harder to get > the buffer to fill up with the newer version. Unfortunately I am not > able to share my whole repro, but a key part is to visit the output > file from this > while yes | dd of=t bs=1 count=1000000; do : ; > with global-auto-revert-mode enabled. > > With my patches it is still possible to get emacs to perform very > poorly by abusing it this way, but at least all the keys arrive > eventually. I added some FIXMEs for further work that would be good, > but is not critical to fixing the bug. I would rather not allocate anything on the heap to hold inotify events. The best thing to do, IMO, would be to simply not store any FILE_NOTIFY_EVENTS if the keyboard buffer is full, which shouldn't affect normal use of file notifications, and would result in less change to the keyboard code. Thanks.