From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Phil Sainty Newsgroups: gmane.emacs.bugs Subject: bug#32462: 26.1; Can `count-lines' be rewritten to use the newline cache? Date: Fri, 17 Aug 2018 13:01:38 +1200 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1534467610 6233 195.159.176.226 (17 Aug 2018 01:00:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 17 Aug 2018 01:00:10 +0000 (UTC) User-Agent: Orcon Webmail To: 32462@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Aug 17 03:00:06 2018 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 1fqT7U-0001Tu-Lh for geb-bug-gnu-emacs@m.gmane.org; Fri, 17 Aug 2018 03:00:04 +0200 Original-Received: from localhost ([::1]:58611 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqT9Z-0005JX-Fy for geb-bug-gnu-emacs@m.gmane.org; Thu, 16 Aug 2018 21:02:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57997) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqT9T-0005JR-Ed for bug-gnu-emacs@gnu.org; Thu, 16 Aug 2018 21:02:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fqT9O-0006BO-Oz for bug-gnu-emacs@gnu.org; Thu, 16 Aug 2018 21:02:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:48029) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fqT9O-0006B0-AG for bug-gnu-emacs@gnu.org; Thu, 16 Aug 2018 21:02:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fqT9O-0001vr-6l for bug-gnu-emacs@gnu.org; Thu, 16 Aug 2018 21:02:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Phil Sainty Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 17 Aug 2018 01:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 32462 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.15344677187407 (code B ref -1); Fri, 17 Aug 2018 01:02:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 17 Aug 2018 01:01:58 +0000 Original-Received: from localhost ([127.0.0.1]:53047 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fqT9J-0001vN-St for submit@debbugs.gnu.org; Thu, 16 Aug 2018 21:01:58 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:36973) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fqT9H-0001ux-5s for submit@debbugs.gnu.org; Thu, 16 Aug 2018 21:01:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fqT9B-0005tx-4n for submit@debbugs.gnu.org; Thu, 16 Aug 2018 21:01:50 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:36635) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fqT9B-0005tj-1Y for submit@debbugs.gnu.org; Thu, 16 Aug 2018 21:01:49 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57949) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqT99-0005HD-Si for bug-gnu-emacs@gnu.org; Thu, 16 Aug 2018 21:01:48 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fqT96-0005qw-Mp for bug-gnu-emacs@gnu.org; Thu, 16 Aug 2018 21:01:47 -0400 Original-Received: from smtp-4.orcon.net.nz ([60.234.4.59]:59958) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fqT96-0005cW-Bw for bug-gnu-emacs@gnu.org; Thu, 16 Aug 2018 21:01:44 -0400 Original-Received: from [10.253.37.70] (port=31316 helo=webmail.orcon.net.nz) by smtp-4.orcon.net.nz with esmtpa (Exim 4.86_2) (envelope-from ) id 1fqT90-00077s-Dj for bug-gnu-emacs@gnu.org; Fri, 17 Aug 2018 13:01:39 +1200 Original-Received: from wlgwil-nat-office.catalyst.net.nz ([202.78.240.7]) via [10.253.37.253] by webmail.orcon.net.nz with HTTP (HTTP/1.1 POST); Fri, 17 Aug 2018 13:01:38 +1200 X-Sender: psainty@orcon.net.nz X-GeoIP: -- X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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:149543 Archived-At: I saw this story the other day: https://fuco1.github.io/2018-08-12-WAR-STORY:-When-turning-to-the-profiler-turns-out-to-be-a-good-call.html The summary is that some very slow code turned out to be spending the vast bulk of its time inside `line-number-at-pos' (which was used frequently), and once the author discovered what that function actually entailed they were able to reduce their processing time from 42 seconds down to 5 seconds (processing a file of ~10,000 lines) by finding an alternative approach which did not involve calling `count-lines'. `count-lines' uses a regexp search to find all the newlines (and/or carriage returns -- I don't know if that's a problem) and I recall that internally Emacs uses a newline cache to make certain line-oriented functionality performant. I know nothing about the cache other than that it exists, but I wondered whether `count-lines' might be able to use it to avoid most of the work that it currently does? -Phil In GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, X toolkit, Xaw scroll bars) of 2018-04-10 built on shodan Windowing system distributor 'The X.Org Foundation', version 11.0.11501000 System Description: Ubuntu 14.04.5 LTS Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Configured using: 'configure --prefix=/home/phil/emacs/26/26.1rc1/usr/local --with-x-toolkit=lucid --without-sound' Configured features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK GPM DBUS GSETTINGS NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS LUCID X11 THREADS LCMS2 Important settings: value of $LANG: en_NZ.UTF-8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix Major mode: Dired by name Minor modes in effect: tooltip-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t buffer-read-only: t line-number-mode: t transient-mark-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message rmc puny seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib format-spec rfc822 mml easymenu mml-sec password-cache epa derived epg epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils dired dired-loaddefs advice elec-pair time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 99206 10028) (symbols 48 20474 0) (miscs 40 101 169) (strings 32 29605 992) (string-bytes 1 777027) (vectors 16 14293) (vector-slots 8 495220 11440) (floats 8 55 100) (intervals 56 315 0) (buffers 992 14) (heap 1024 30317 1420))