From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs Subject: bug#25995: 26.0.50; Mismatch between documented and actual behaviour of icomplete Date: Sun, 18 Jun 2017 23:28:52 -0400 Message-ID: <87injsr6yz.fsf@users.sourceforge.net> References: <87a88yveuj.fsf@debian> <87shmm823i.fsf@users.sourceforge.net> <93815f6a-22a9-f8b5-2583-5b8bd9906d48@yandex.ru> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1497842889 8087 195.159.176.226 (19 Jun 2017 03:28:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 19 Jun 2017 03:28:09 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) Cc: 25995@debbugs.gnu.org, Alexis To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jun 19 05:28:05 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 1dMnMD-0001xB-8d for geb-bug-gnu-emacs@m.gmane.org; Mon, 19 Jun 2017 05:28:05 +0200 Original-Received: from localhost ([::1]:40367 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMnMI-0008UY-A0 for geb-bug-gnu-emacs@m.gmane.org; Sun, 18 Jun 2017 23:28:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47594) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMnMD-0008US-75 for bug-gnu-emacs@gnu.org; Sun, 18 Jun 2017 23:28:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMnMA-0006GI-3T for bug-gnu-emacs@gnu.org; Sun, 18 Jun 2017 23:28:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:52818) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dMnM9-0006Fz-Uz for bug-gnu-emacs@gnu.org; Sun, 18 Jun 2017 23:28:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dMnM9-0001OU-PA for bug-gnu-emacs@gnu.org; Sun, 18 Jun 2017 23:28:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 19 Jun 2017 03:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25995 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 25995-submit@debbugs.gnu.org id=B25995.14978428465312 (code B ref 25995); Mon, 19 Jun 2017 03:28:01 +0000 Original-Received: (at 25995) by debbugs.gnu.org; 19 Jun 2017 03:27:26 +0000 Original-Received: from localhost ([127.0.0.1]:55495 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dMnLa-0001Nc-BB for submit@debbugs.gnu.org; Sun, 18 Jun 2017 23:27:26 -0400 Original-Received: from mail-io0-f171.google.com ([209.85.223.171]:36338) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dMnLY-0001NO-P9 for 25995@debbugs.gnu.org; Sun, 18 Jun 2017 23:27:25 -0400 Original-Received: by mail-io0-f171.google.com with SMTP id y77so56044266ioe.3 for <25995@debbugs.gnu.org>; Sun, 18 Jun 2017 20:27:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=vuc34Kqt1aWzKAJe7Ape031GyMJ7ZVf2zVXq5q6kTpM=; b=nvdfDxrgKkZ30DXj7489emwkZmO+LlQsh3UHd6b9DBpAw6krvVl8DQJrVl9ZHmXZEH u3qAwdpT5+vO6dm//jMLVb8KNl04d3LDiGY9wx+hr/u8btvHQz2OFikNctrMdCEC2B1z P0vKZyug3UQJEIVPL3zhmvbXw3Ls+Ms5gkqDuyUjZPN/rrJkLFuFjOxhkraYSzT66EN1 zIrUvR4kG6SU+Enifdzac6s0vEyYfjqFjqxBodpzddf7QyDwngLNpNHIslN74q/pn2YU tJ9hx2wpaJA3GcOevB5T1HxnVoms8hM2qjHEJXTXs/HWATORouMXAQJky1O5s3ddrB5o jTxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=vuc34Kqt1aWzKAJe7Ape031GyMJ7ZVf2zVXq5q6kTpM=; b=WYZmWg1n12u0hSKP+VlvojbVF2xrrcwzpGIPBIHiqxIbF6YAdstIQ0jJFUoJ/J8Fq7 jUqsgGzRvZSLpsrTrAgfrKu0og7UNU7vJOSJOMEZONmBzvuKHxgdoZVI4CsG4Hy/LpYx uSK/KXKJq5oPTONpmiiT0pe/tO2949Oz+eMowJV5+jb0nzY+Es2nPEYLbA9Hh7w8SEXV G8x1MuCnu/mQwlPNblsP7kHlew5WyIayjNjyB8Ep8d/8E1PLMrtMAdvKYMix/oZdB3Ik gVjwNhgdGsBw2Q7IcQ+WyvjYZf106OzD7Ky82mvz7mlapEJI27paI+ODlMGlBVLMA3nS uDtw== X-Gm-Message-State: AKS2vOxkAnwft7dYUWxzH9BqFSQfo7xO2mKvAJ7SR2EFr/wXB0ceOLjc Yt4gSz443LKXNr/O X-Received: by 10.107.18.219 with SMTP id 88mr20543315ios.149.1497842838869; Sun, 18 Jun 2017 20:27:18 -0700 (PDT) Original-Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id k2sm3216421itk.3.2017.06.18.20.27.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 18 Jun 2017 20:27:18 -0700 (PDT) In-Reply-To: <93815f6a-22a9-f8b5-2583-5b8bd9906d48@yandex.ru> (Dmitry Gutov's message of "Mon, 19 Jun 2017 03:19:16 +0300") 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:133741 Archived-At: --=-=-= Content-Type: text/plain Dmitry Gutov writes: > On 3/10/17 1:25 AM, npostavs@users.sourceforge.net wrote: > >> --- i/lisp/minibuffer.el >> +++ w/lisp/minibuffer.el >> @@ -3257,7 +3257,7 @@ completion-pcm--filename-try-filter >> "\\)\\'"))) >> (dolist (f all) >> (unless (string-match-p re f) (push f try))) >> - (or try all)))) >> + (or (nreverse try) all)))) > > Looks good to me, thank you. > > But what are the chances of this 'nreverse' (or the whole function) > being performance-significant? > > Maybe we could switch this code to `cl-delete-if'. From my testing, > it's considerably faster than dolist+push (even without nreverse). I don't have a good sense of how the completion code fits together, so I'm not sure how significant the performance of this function is, but in my simplistic benchmark I found the opposite: dolist+push+nreverse is quite a bit faster (although the difference can be swamped by GC). So adding `nreverse' won't be a problem. ~/src$ emacs -Q -batch -l emacs/bench-filter.elc dolist+push 1000 Elapsed time: 0.000335s dolist+push 10000 Elapsed time: 0.001951s dolist+push 100000 Elapsed time: 0.056526s (0.035910s in 1 GCs) dolist+push+nreverse 1000 Elapsed time: 0.000212s dolist+push+nreverse 10000 Elapsed time: 0.002086s dolist+push+nreverse 100000 Elapsed time: 0.019966s cl-delete-if 1000 Elapsed time: 0.002174s cl-delete-if 10000 Elapsed time: 0.003604s cl-delete-if 100000 Elapsed time: 0.034759s --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=bench-filter.el Content-Transfer-Encoding: quoted-printable Content-Description: benchmark code ;;; -*- lexical-binding: t -*- (require 'cl-lib) (defconst filter-biglist0 (number-sequence 0 1000)) (defconst filter-biglist1 (number-sequence 0 10000)) (defconst filter-biglist2 (number-sequence 0 100000)) (defconst filter-biglist3 (number-sequence 0 1000000)) (defconst filter-biglist4 (number-sequence 0 10000000)) (defun filter-by-dolist+push+nreverse (list) (let ((result nil)) (dolist (num list) (when (cl-evenp num) (push num result))) (nreverse result))) (defun filter-by-dolist+push (list) (let ((result nil)) (dolist (num list) (when (cl-evenp num) (push num result))) result)) (defun filter-by-cl-delete-if (list) (cl-delete-if #'cl-evenp list)) (progn (message "dolist+push 1000") (benchmark 1 '(filter-by-dolist+push filter-biglist0)) (message "dolist+push 10000") (benchmark 1 '(filter-by-dolist+push filter-biglist1)) (message "dolist+push 100000") (benchmark 1 '(filter-by-dolist+push filter-biglist2)) (message "dolist+push 1000000") (benchmark 1 '(filter-by-dolist+push filter-biglist3))) (progn (message "dolist+push+nreverse 1000") (benchmark 1 '(filter-by-dolist+push+nreverse filter-biglist0)) (message "dolist+push+nreverse 10000") (benchmark 1 '(filter-by-dolist+push+nreverse filter-biglist1)) (message "dolist+push+nreverse 100000") (benchmark 1 '(filter-by-dolist+push+nreverse filter-biglist2)) (message "dolist+push+nreverse 1000000") (benchmark 1 '(filter-by-dolist+push+nreverse filter-biglist3))) (progn (message "cl-delete-if 1000") (benchmark 1 '(filter-by-cl-delete-if filter-biglist0)) (message "cl-delete-if 10000") (benchmark 1 '(filter-by-cl-delete-if filter-biglist1)) (message "cl-delete-if 100000") (benchmark 1 '(filter-by-cl-delete-if filter-biglist2)) (message "cl-delete-if 1000000") (benchmark 1 '(filter-by-cl-delete-if filter-biglist3))) --=-=-=--