From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Hongyi Zhao Newsgroups: gmane.emacs.help Subject: Re: Too long completion delay time in LISP interaction mode. Date: Wed, 20 Oct 2021 14:11:02 +0800 Message-ID: References: <87tuhcs2ov.fsf@gnu.org> <87pms0s0ex.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38482"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs To: Tassilo Horn Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Oct 20 08:12:11 2021 Return-path: Envelope-to: geh-help-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 1md4pe-0009oL-SG for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 20 Oct 2021 08:12:10 +0200 Original-Received: from localhost ([::1]:55544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1md4pb-0008N7-TI for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 20 Oct 2021 02:12:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43436) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1md4om-0008Mr-Us for help-gnu-emacs@gnu.org; Wed, 20 Oct 2021 02:11:16 -0400 Original-Received: from mail-ua1-x92e.google.com ([2607:f8b0:4864:20::92e]:42801) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1md4ok-0008IV-Qv; Wed, 20 Oct 2021 02:11:16 -0400 Original-Received: by mail-ua1-x92e.google.com with SMTP id j8so4499599uak.9; Tue, 19 Oct 2021 23:11:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=JxRhZP3MMkpnEkqYl6Hfi8fJyvvoRJldiP8vzvlPGAQ=; b=mw0Gt+sUPZhxmvfir8Im4tupsMBvz4DSX1aNhhQXLiERfG4t9x/6C27HN1xknMb8KF q2OjhGIYi5yAZidgA6s49MYilPL6p6sesZ8dKvc/OVu+FD8RoUGCn98xwjek2if0k+Cm pJsNel2uqork/0gAYaCjA0rTdrLWDm4wTHqRcfxVmrgrmBReq19SjKPy75WPoQ6a98lj ReW8V6uumhbos0geVshUyg2mYRgT9SugLMfHbmsoMMvJx8OrkUIzXYQQte+yzjdW4cv0 WLasaF1t79/wEz9Owgfn+o2cdXEmTzYMxg4rjsb2W7FM2pgDXYJiqKeUtiDt6/5t7lJT w0GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=JxRhZP3MMkpnEkqYl6Hfi8fJyvvoRJldiP8vzvlPGAQ=; b=hu3VKJ/ECF0Kt8wRORDNszTdqjoK/tuZPiBoqzJN5RiBJ66sMwyfJSsxym1GdTa9zk nwotUp8tjtyI/B89RaQvLP+RDqC0sHKlQZ2idNHIbCc6R+hw7opzvSFjl/TDhbfTzl8Q 9KAO14+S0akamM4i5RujJMWRbOQMqJr6Ul2agbuf3tafMG5p0jAp7jJSpY3FOFPfPnNc T1lBTrs9XHuczEgy6oKY95dUQZwHxNR/vo1EbaXiqV93v9V3Xotz6qONWUoahu7xB1xM Fhf1gT2jAF8tuVIz3lNOPnxcdoOwOz1L4pRaQ91755oIVtAROYTm4dvMOaTOFikvTfFo yM4w== X-Gm-Message-State: AOAM532hFQl1hfgWbaxw0NSgsxtr0E6D2XkNnn3gFOYiJ3kLxPkQEwwh mXWQHvR/kdfQkPiuG1vxlI9N3WK7ujdmdhIMOufJ5zvMwvVM/YHf X-Google-Smtp-Source: ABdhPJzh2fKpHCaEDrRaJlrL7JW4uRmv9jWPk2xDLeiFO+qNd+WoNPdvT/O0nwAyYDTVC6pGidaaJa6g76psr2ewbsU= X-Received: by 2002:a67:d91b:: with SMTP id t27mr41509797vsj.55.1634710273296; Tue, 19 Oct 2021 23:11:13 -0700 (PDT) In-Reply-To: <87pms0s0ex.fsf@gnu.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::92e; envelope-from=hongyi.zhao@gmail.com; helo=mail-ua1-x92e.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, FREEMAIL_FROM=0.001, 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: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:133906 Archived-At: On Wed, Oct 20, 2021 at 1:58 PM Tassilo Horn wrote: > > Hongyi Zhao writes: > > >> First, I'd try to isolate where the slowdown happens. The > >> screenshots suggests you are using company-mode with custom hacks to > >> get the numbering of candidates and you are using some fuzzy > >> completion-style. > >> > >> So I'd start with emacs -Q and typing (map in *scratch* to get > >> the *Completions* buffer. That will probably be fast but deliver > >> less results because of the default value of `completion-styles'. > >> Then I'd try out your settings of `completion-styles' (and > > > > `C-h o completion-styles RET' > > > > completion-styles is a variable defined in =E2=80=98minibuffer.el=E2=80= =99. > > > > Its value is (hotfuzz) > > Never heard of it. See here: https://github.com/axelf4/hotfuzz > But is it a suitable catch-all completion style, > i.e., suitable for using it without another more prefix-oriented style > preceeding it? FWIW, when I type "(map", I'm most probably not > interested in having smartparens-mode, or > lsp:document-symbol-capabilities-hierarchical-document-symbol-support? > showing up as the top candidates but more in mapcar, mapc, mapcan, you > name it... Agree with you. > >> Also, using the profiler might shed some light on where the time is > >> spent, see (info "(elisp) Profiling"). > > > > `M-x profiler-start RET cpu and mem RET' > > I think you only need cpu here. Thank you for pointing this out. > > Typeset (map) in scratch buffer, and then > > > > `M-x profiler-report RET', gives the following results: > > > > 262,542,852 87% - command-execute > > 262,542,852 87% - funcall-interactively > > 262,538,196 87% - counsel-M-x > > 262,538,196 87% - let > > 262,355,940 87% - ivy-read > > 262,355,940 87% - apply > > 262,354,884 87% + # > > 182,256 0% + counsel--M-x-externs > > So the bottleneck is in the lambda which you didn't expand. I disabled hotfuzz now, and the following result is obtained by profiling the CPU with the same steps as described above: 472 88% - command-execute 472 88% - funcall-interactively 472 88% - counsel-M-x 472 88% - let 448 84% - ivy-read 448 84% - apply 444 83% + # 4 0% + my/company--transform-candidates 24 4% + counsel--M-x-externs 45 8% + ... 15 2% + redisplay_internal (C function) > But I'm also not sure if you are profiling the right thing because I don'= t think > that in-buffer completion (in terms of `completion-at-point-functions') > starts with M-x (or counsel-M-x). I'm not sure if it's relevant to the following configuration in my `~/.emacs.d/init.el': (use-package counsel :diminish counsel-mode :after helpful :init (setq ivy-use-selectable-prompt t search-default-mode #'char-fold-to-regexp counsel-describe-function-function #'helpful-callable counsel-describe-variable-function #'helpful-variable) :bind (("M-x" . counsel-M-x) ;; https://github.com/alpha2phi/dotfiles/blob/7c8c2c1ac9cf1cf95d60323f= 49c19545cfcef555/config/emacs/elisp/completion.el#L21 ;; ("C-x C-f" . counsel-fzf) ("C-x C-f" . counsel-find-file) ;;https://github.com/abo-abo/swiper/issues/2888#issuecomment-874893794 ("C-x 8 RET" . counsel-unicode-char) ("" . counsel-bookmark) ("s-4" . counsel-bookmark) ("s-r" . counsel-recentf)) :config (counsel-mode 1) (defalias 'recent 'counsel-recentf)) (define-key minibuffer-local-map (kbd "C-r") 'counsel-minibuffer-history) HZ