From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#25606: [DRAFT PATCH 2/2] Signal list cycles in =?UTF-8?Q?=E2=80=98length=E2=80=99?= etc. Date: Thu, 2 Feb 2017 15:01:16 -0800 Organization: UCLA Computer Science Department Message-ID: <0a01d2ce-ef3e-7db0-6854-1b5e46d49be4@cs.ucla.edu> References: <20170201235622.30836-1-eggert@cs.ucla.edu> <20170201235622.30836-2-eggert@cs.ucla.edu> <83wpd8v6x8.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1486076538 11694 195.159.176.226 (2 Feb 2017 23:02:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 2 Feb 2017 23:02:18 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 Cc: 25606@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Feb 03 00:02:12 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cZQOK-0002mF-LA for geb-bug-gnu-emacs@m.gmane.org; Fri, 03 Feb 2017 00:02:12 +0100 Original-Received: from localhost ([::1]:59368 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZQOQ-0006qC-0h for geb-bug-gnu-emacs@m.gmane.org; Thu, 02 Feb 2017 18:02:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39548) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZQOF-0006q7-9f for bug-gnu-emacs@gnu.org; Thu, 02 Feb 2017 18:02:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZQOA-00068n-EC for bug-gnu-emacs@gnu.org; Thu, 02 Feb 2017 18:02:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:56099) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cZQOA-00068i-Bq for bug-gnu-emacs@gnu.org; Thu, 02 Feb 2017 18:02:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cZQO9-0000uu-V8 for bug-gnu-emacs@gnu.org; Thu, 02 Feb 2017 18:02:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 02 Feb 2017 23:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25606 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 25606-submit@debbugs.gnu.org id=B25606.14860764863483 (code B ref 25606); Thu, 02 Feb 2017 23:02:01 +0000 Original-Received: (at 25606) by debbugs.gnu.org; 2 Feb 2017 23:01:26 +0000 Original-Received: from localhost ([127.0.0.1]:54298 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cZQNa-0000u7-CR for submit@debbugs.gnu.org; Thu, 02 Feb 2017 18:01:26 -0500 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:35512) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cZQNX-0000ts-Vq for 25606@debbugs.gnu.org; Thu, 02 Feb 2017 18:01:24 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id B5F68160083; Thu, 2 Feb 2017 15:01:17 -0800 (PST) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id Qa1OuwlT85YL; Thu, 2 Feb 2017 15:01:17 -0800 (PST) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id F2D2D1600DA; Thu, 2 Feb 2017 15:01:16 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id ntgq9PvU21qQ; Thu, 2 Feb 2017 15:01:16 -0800 (PST) Original-Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id DA0D4160083; Thu, 2 Feb 2017 15:01:16 -0800 (PST) In-Reply-To: <83wpd8v6x8.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:128895 Archived-At: On 02/02/2017 09:28 AM, Eli Zaretskii wrote: > could we please have tests for these functions? Good point, I'll look into adding some. > I think we shouldn't second-guess users this way, and > should always leave them the possibility of interrupting a possibly > prolonged calculation. Sure, but we shouldn't insert maybe_quit calls after every nanosecond's worth of computation; that'd be overkill and would slow down Emacs unnecessarily. We should insert a maybe_quit call only when Emacs may have done enough computation that it would be annoying if the user typed C-g and Emacs did not respond for that period of time. A reasonable rule of thumb is that if an operation can take longer than a garbage collection, then we should insert a maybe_quit in its loop body. Conversely, if an operation is always significantly faster then GC, then we needn't bother inserting maybe_quit, as Emacs cannot quit in the middle of GC anyway (and if we ever get around to fixing *that* problem then we will likely be able use the fix approach to attack the problem everywhere, not just in GC). This rule of thumb corresponds pretty closely to what Emacs is already doing. For example, Emacs does a maybe_quit while doing regex searching, as in practice buffers can be quite large and searching them can easily take longer than a GC. In contrast, Emacs does not do a maybe_quit when FACE_FOR_CHAR searches font-encoding-charset-alist, as in practice that list is never so long that the a user would notice any C-g delay (and if the list actually did contain billions of elements (!), GC would be slow too as it would have to mark the list). With cycle checking, all the loops containing removed maybe_quits are waaaay faster than a GC would be, which is why these loops don't need those maybe_quit calls once they start checking for list cycles.