From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Date: Sun, 07 Feb 2021 22:58:12 +0100 Message-ID: <87r1lrwnez.fsf@gnus.org> References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> <87y2fz3lpe.fsf@gnus.org> <87h7mn22ls.fsf@gnus.org> <83eehrn408.fsf@gnu.org> <87y2fzzqxb.fsf@gnus.org> <87tuqnzqh2.fsf@gnus.org> <83blcvn1ku.fsf@gnu.org> <87czxbznly.fsf@gnus.org> <834kinmzpy.fsf@gnu.org> <87zh0fy82q.fsf@gnus.org> <83y2fzlkpk.fsf@gnu.org> <87v9b3wnnu.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32815"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 22763@debbugs.gnu.org, esq@lawlist.com, monnier@iro.umontreal.ca To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Feb 07 23:08:46 2021 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 1l8sEW-0008Nv-6i for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 07 Feb 2021 23:08:44 +0100 Original-Received: from localhost ([::1]:46398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l8sEV-0002rE-7U for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 07 Feb 2021 17:08:43 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37800) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l8s58-0005l0-1h for bug-gnu-emacs@gnu.org; Sun, 07 Feb 2021 16:59:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37565) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l8s57-0008Pk-Pm for bug-gnu-emacs@gnu.org; Sun, 07 Feb 2021 16:59:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l8s57-0000hR-Ng for bug-gnu-emacs@gnu.org; Sun, 07 Feb 2021 16:59:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2021 21:59:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed Original-Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.16127351202662 (code B ref 22763); Sun, 07 Feb 2021 21:59:01 +0000 Original-Received: (at 22763) by debbugs.gnu.org; 7 Feb 2021 21:58:40 +0000 Original-Received: from localhost ([127.0.0.1]:49111 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8s4l-0000gr-AD for submit@debbugs.gnu.org; Sun, 07 Feb 2021 16:58:40 -0500 Original-Received: from quimby.gnus.org ([95.216.78.240]:40244) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8s4f-0000gY-Np for 22763@debbugs.gnu.org; Sun, 07 Feb 2021 16:58:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=I7tArte4fcPzXJz21eSwvLoVwUnha94RLuYDLzdWnhE=; b=glCI7XyuDQmrvR1k2ozsiGuLPc rTsQbvyvG1/GoGiTBCsWCeD9UFOTnmBP/0XGT/Rd7HPXzCoEhLEBgzQ1sBAThUCWze2IpOftoNZnj /Tr1w+VdbBHDLiiKQPZ03Vr7NGJOLfPn1/nmHOqYT7fRUH0eq7F0o9HqOWSMLIfM36Pc=; Original-Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8s4M-0005Oc-Iw; Sun, 07 Feb 2021 22:58:20 +0100 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAGFBMVEVRam0xOFHNxq2k iFldZmCXGgu3ZB3///+tWyq4AAAAAWJLR0QHFmGI6wAAAAd0SU1FB+UCBxUeJnHrkPEAAAGtSURB VDjLpdRPd6IwEADw/KF7JgU9u4HeNajnSEbv+xZ6r0i+/0fozAS7uNq+7tu5BObHZCDJQwgOKZT2 gLGFKTithKyUcqKFumqJQsMgnRBOaWUKqFqwBsF6rsiKlVKqMQbqUBlTAkxgTK6d3ryOmArLX1hS McjlmFMdAyzeymtvhJIgjpjxp9jRwLLoOxpOl4zBg08VAq95oAo4jv5aIJ4i9dAx4jeE3dh9gDzh hbIYVbDW2XpqrjdK194R2JbAJsiqjSisj4Nr9rGn+J3mkuuf5rkpIwdD3yUw0uTG3INJ8b8A34bx EQz/DOfPejyGxZnW8AEs70FSvpzgdQY/DlRwYbikknRMMgZgGE8zSE1q3sHL0zRTOrsEK2cra7fH Gegr1Awdz/QlKGkEw9pNUH5UfAH5Wl3heDNVvlLWt7bezcEYfGMEPKUJuhtwNmLFcQ4yR9jFfojD dg46wTDszvt9fwcvDR+SsYe/YGVt6Afs8QfwXVPzzNsbkAS5V7XIHAEkwPVrDiJrDoH+IVv6ywRI kG8QAzS4kUUT8CbQloqDARpx3WjxgZIFPfkOxPLTQ0eiKuIAAAAldEVYdGRhdGU6Y3JlYXRlADIw MjEtMDItMDdUMjE6MzA6MzgrMDA6MDCKg84bAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIxLTAyLTA3 VDIxOjMwOjM4KzAwOjAw+952pwAAAABJRU5ErkJggg== X-Now-Playing: =?UTF-8?Q?Gar=C3=A7ons's?= _Divorce_: "French Boy (Reprise)" In-Reply-To: <87v9b3wnnu.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sun, 07 Feb 2021 22:52:53 +0100") 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:199574 Archived-At: Lars Ingebrigtsen writes: > It seems it tests one longword_ptr at a time? So that's 8 bytes on > 64-bit CPUs, I think. Doesn't look like any SSE/AVX support, though. Never mind -- there are even more optimised versions using SSE2 etc, too: https://github.com/lattera/glibc/blob/master/sysdeps/x86_64/memchr.S I've done some further benchmarking -- with a perhaps more typical file than the ChangeLog: (with-temp-buffer (dotimes (_ 100) (insert-file-contents "~/src/emacs/trunk/lisp/printing.el") (goto-char (point-max))) (benchmark-run 10 (dotimes (i 100) (goto-char (* (/ (buffer-size) 100) i)) (line-number-at-pos (point))))) The cached version is only 5x slower than the non-cached one. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no