From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.devel Subject: Re: master 695f679: Remove ; ; ; ###tramp-autoload cookie from Tramp defcustoms (Bug#47063) Date: Sat, 27 Mar 2021 01:18:33 +0000 Message-ID: <878s69pf6e.fsf@tcd.ie> References: <20210313133546.6042.78482@vcs0.savannah.gnu.org> <20210313133547.AA06C20B2E@vcs0.savannah.gnu.org> <877dma1yfv.fsf@tcd.ie> <87sg4ygmd9.fsf@gmx.de> <87zgz5uc0k.fsf@tcd.ie> <87tup0kxeg.fsf@tcd.ie> <878s6ba96u.fsf@gnus.org> <87mtuqaqa2.fsf@tcd.ie> <87v99d7efl.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1517"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Michael Albinus , Stefan Monnier , emacs-devel@gnu.org To: Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Mar 27 02:19:19 2021 Return-path: Envelope-to: ged-emacs-devel@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 1lPxbi-0000HV-0Y for ged-emacs-devel@m.gmane-mx.org; Sat, 27 Mar 2021 02:19:18 +0100 Original-Received: from localhost ([::1]:37076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPxbg-000378-16 for ged-emacs-devel@m.gmane-mx.org; Fri, 26 Mar 2021 21:19:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPxb6-0002fe-Lv for emacs-devel@gnu.org; Fri, 26 Mar 2021 21:18:40 -0400 Original-Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:39794) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lPxb4-0003TX-CI for emacs-devel@gnu.org; Fri, 26 Mar 2021 21:18:40 -0400 Original-Received: by mail-wr1-x433.google.com with SMTP id e18so7265362wrt.6 for ; Fri, 26 Mar 2021 18:18:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd.ie; s=google21; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=MNmsf115Kwm1Lw/XgF/0AjS8Ia8GwJWYW0WyRuQrq2U=; b=QNaexyhOND/ARv9pHU4P7+tIPECMxw2ylgkhDlYL7r0wa7HLTTXMJ8ItSAeVI+LinH rswNnx2mvFcfD7lYK+xf8Or8k+PG9JSx8hUUPIJA7EHXfcG+WzficYAn25g8079X3sOH 9uaGSotetF33if1ojIeaKGcLYiGBmiTKGlLkeDdRW5gkwUqTWbYHxUUS5Fht2+JTyTf6 3X4HKNRQCZHVmXJBH7+BAtsg/g2iUIUuEUR40wp0pWcQBR3x1R2upL414iTzkFKnGgqe MzcCs1c0w2XxfYRFOazZIfAr7xXXSEXPczBwQVaJ/SvU+AV5xd6qE/nL0fcoxWcLjRmH 3OaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=MNmsf115Kwm1Lw/XgF/0AjS8Ia8GwJWYW0WyRuQrq2U=; b=LQMbF049mjBziWaica8/lYKqqHZ0wM547XYKjHFS3///rxvzimtgFd7WuDZquNjYz3 v3DDl602sc16Qi8cTwv5SsXYXj83LljntIfyFDSLh8YE6qIlBf9+IjtAVucpRBhoKDD4 1OmwsDbc7cPkm+zgPNGF2Nksi4y3cWAcPztMAZVkpsWK2HcipjWh01yejd9NxhZY5KJk B/IqxOlUCTNMlX3wFA5Lf5wT/BVSiM6/ge7E18U+0VoknBPKeMZp5LYxBd0Q8jntdk9d 7uEx/66GBEd/Hc0isDw+OqN0bRFVP09gqh0JE/IpMaNSerMQS9rx8zb54SJbESXf5uFR yhgQ== X-Gm-Message-State: AOAM5328ulbdDs6rn2IgVePz+ZsaK++QEa19l0abbRV7TZ/oJO4knaiS 1lNtAc2ejGfMqDpxNk5fM1j6fg== X-Google-Smtp-Source: ABdhPJwfrwtZrmT9fY8a1Ckc9PyP4mtqL2xZSvLm2GPElFkCoMt1MSoIzcGzY5VpW2sis1OYQfyoCQ== X-Received: by 2002:a5d:591a:: with SMTP id v26mr16893581wrd.172.1616807915776; Fri, 26 Mar 2021 18:18:35 -0700 (PDT) Original-Received: from localhost ([2a02:8084:20e2:c380:d15:339e:aa10:60f1]) by smtp.gmail.com with ESMTPSA id m11sm15560288wrz.40.2021.03.26.18.18.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Mar 2021 18:18:34 -0700 (PDT) In-Reply-To: <87v99d7efl.fsf@gnus.org> (Lars Ingebrigtsen's message of "Fri, 26 Mar 2021 23:11:58 +0100") Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=contovob@tcd.ie; helo=mail-wr1-x433.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:267093 Archived-At: --=-=-= Content-Type: text/plain Lars Ingebrigtsen writes: > Hm... I'm not quite sure I understand these benchmarks. There are no > completion predicates for any eww-* symbols, I think? So there > shouldn't be any differences here at all, if I read the patch correctly. Oops, sorry, I conflated completion-predicate with command-modes. The eww completion is only one half of the benchmark; the rest operates over all commands in obarray (but less than 1% of those have a completion-predicate, hence the (failed) attempt to prefilter obarray). > What I was wondering was -- if (at some point in the future) we have, > say, 2K symbols with a completion predicate -- would putting that > condition-case inside the loop make things slower or not? My gut > feeling says that it's probably not an issue (so we should just go ahead > and do it), but it'd be nice to know... Here's the attached benchmark on 16K commands (warning: takes a while): == TAB RET == bench-vanilla-no-pred 3.533359 100 2.058253 bench-vanilla-no-pred 3.531937 100 2.054076 bench-vanilla-no-pred 3.529376 100 2.052615 bench-vanilla-with-pred 3.627937 105 2.127567 bench-vanilla-with-pred 3.616596 105 2.117001 bench-vanilla-with-pred 3.612720 105 2.114463 bench-vanilla-safe-pred 3.639222 105 2.132278 bench-vanilla-safe-pred 3.647615 105 2.134284 bench-vanilla-safe-pred 3.636989 105 2.127953 bench-safe-no-pred 3.573388 100 2.087055 bench-safe-no-pred 3.555347 100 2.069622 bench-safe-no-pred 3.545747 100 2.063041 bench-safe-with-pred 3.653066 105 2.145138 bench-safe-with-pred 3.643867 105 2.140400 bench-safe-with-pred 3.659689 105 2.150498 == b e n c h - TAB C-a C-k RET == bench-vanilla-no-pred 0.649064 0 0.000000 bench-vanilla-no-pred 0.652256 0 0.000000 bench-vanilla-no-pred 0.677194 0 0.000000 bench-vanilla-with-pred 1.652515 40 0.750009 bench-vanilla-with-pred 1.653861 40 0.753575 bench-vanilla-with-pred 1.672873 40 0.747151 bench-vanilla-safe-pred 1.669653 40 0.742116 bench-vanilla-safe-pred 1.673809 40 0.743255 bench-vanilla-safe-pred 1.672750 40 0.741095 bench-safe-no-pred 0.646114 0 0.000000 bench-safe-no-pred 0.644843 0 0.000000 bench-safe-no-pred 0.646764 0 0.000000 bench-safe-with-pred 1.672326 40 0.743054 bench-safe-with-pred 1.677331 40 0.742163 bench-safe-with-pred 1.711009 40 0.759025 So condition-case still looks negligible relative to the rest of the work, and my vote's for putting it around the call to read-extended-command-predicate. -- Basil --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=bench3.el Content-Transfer-Encoding: quoted-printable ;;; bench3.el --- benchmark read-extended-command -*- lexical-binding: t -*- ;; Define lots of commands with a `completion-predicate'. (defmacro bench-define-cmd (i) `(defun ,(intern (format "bench-cmd-%d" i)) () (declare (completion always)) (interactive))) (defmacro bench-define-cmds (n) (let (cmds) (dotimes (i n) (push `(bench-define-cmd ,i) cmds)) `(progn ,@cmds))) (bench-define-cmds 16384) ;; Extended `read-extended-command' subroutines with safety nets. (defun bench-completion-predicate (symbol buffer) (if (get symbol 'completion-predicate) (condition-case-unless-debug err (funcall (get symbol 'completion-predicate) symbol buffer) (error (message "bench-completion-predicate: %s: %S" symbol err))) (or (null (command-modes symbol)) (command-completion-using-modes-p symbol buffer)))) (defun bench-read-extended-command () (let ((buffer (current-buffer))) (minibuffer-with-setup-hook (lambda () (add-hook 'post-self-insert-hook (lambda () (setq execute-extended-command--last-typed (minibuffer-contents))) nil 'local) (setq-local minibuffer-default-add-function (lambda () ;; Get a command name at point in the original buffer ;; to propose it after M-n. (let ((def (with-current-buffer (window-buffer (minibuffer-selected-window)) (and (commandp (function-called-at-point)) (format "%S" (function-called-at-point))))) (all (sort (minibuffer-default-add-completions) #'string<))) (if def (cons def (delete def all)) all))))) ;; Read a string, completing from and restricting to the set of ;; all defined commands. Don't provide any initial input. ;; Save the command read on the extended-command history list. (completing-read (concat (cond ((eq current-prefix-arg '-) "- ") ((and (consp current-prefix-arg) (eq (car current-prefix-arg) 4)) "C-u ") ((and (consp current-prefix-arg) (integerp (car current-prefix-arg))) (format "%d " (car current-prefix-arg))) ((integerp current-prefix-arg) (format "%d " current-prefix-arg))) ;; This isn't strictly correct if `execute-extended-command' ;; is bound to anything else (e.g. [menu]). ;; It could use (key-description (this-single-command-keys)), ;; but actually a prompt other than "M-x" would be confusing, ;; because "M-x" is a well-known prompt to read a command ;; and it serves as a shorthand for "Extended command: ". (if (memq 'shift (event-modifiers last-command-event)) "M-X " "M-x ")) (lambda (string pred action) (if (and suggest-key-bindings (eq action 'metadata)) '(metadata (affixation-function . read-extended-command--affixation) (category . command)) (complete-with-action action obarray string pred))) (lambda (sym) (and (commandp sym) (or (null read-extended-command-predicate) (and (functionp read-extended-command-predicate) (condition-case-unless-debug err (funcall read-extended-command-predicate sym buf= fer) (error (message "read-extended-command-predicate: %s: %S" sym err))))))) t nil 'extended-command-history)))) ;; Benchmarks. (defun bench-vanilla-no-pred () (let ((read-extended-command-predicate nil)) (read-extended-command))) (defun bench-vanilla-with-pred () (let ((read-extended-command-predicate #'command-completion-default-include-p)) (read-extended-command))) (defun bench-vanilla-safe-pred () (let ((read-extended-command-predicate #'bench-completion-predicate)) (read-extended-command))) (defun bench-safe-no-pred () (let ((read-extended-command-predicate nil)) (bench-read-extended-command))) (defun bench-safe-with-pred () (let ((read-extended-command-predicate #'command-completion-default-include-p)) (bench-read-extended-command))) (with-current-buffer-window "*bench*" nil nil (let* ((loops 3) (fns '(bench-vanilla-no-pred bench-vanilla-with-pred bench-vanilla-safe-pred bench-safe-no-pred bench-safe-with-pred)) (progress (make-progress-reporter "Marking benches" 0 (* 2 loops loops (length fns))))) (pcase-dolist (`(,reps . ,keys) '((10 . "\C-i\C-m") (100 . "bench-\C-i\C-a\C-k\C-m"))) (insert (if (bobp) "" ?\n) "=3D=3D " (key-description keys) " =3D=3D\= n") (setq keys (listify-key-sequence keys)) (dotimes (_ loops) (insert ?\n) (dolist (fn fns) (dotimes (_ loops) (garbage-collect) (insert (apply #'format "%-24s %f %2d %f\n" fn (benchmark-run reps (setq unread-command-events keys) (funcall fn)))) (progress-reporter-update progress (car progress)))))) (progress-reporter-done progress))) ;;; bench3.el ends here --=-=-=--