From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] master b0e318d 2/2: Score flex-style completions according to match tightness Date: Mon, 18 Mar 2019 19:18:57 +0200 Message-ID: References: <20190213212413.868.40960@vcs0.savannah.gnu.org> <20190213212415.148B9209D7@vcs0.savannah.gnu.org> <0ba3ca47-c7d6-a608-536e-94784ba3384b@yandex.ru> <4f4e9ccd-b152-2b37-cad2-6c96b0a64d84@yandex.ru> <646c8d35-89a7-b12f-8a78-b05e6d8f781c@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="218123"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 Cc: Stefan Monnier , emacs-devel To: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Mar 18 18:31:42 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h5w6v-000uc8-IC for ged-emacs-devel@m.gmane.org; Mon, 18 Mar 2019 18:31:42 +0100 Original-Received: from localhost ([127.0.0.1]:44871 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h5w6u-0004Zg-CA for ged-emacs-devel@m.gmane.org; Mon, 18 Mar 2019 13:31:40 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:55380) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h5w4p-0003ms-AV for emacs-devel@gnu.org; Mon, 18 Mar 2019 13:29:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h5vul-0005wb-1D for emacs-devel@gnu.org; Mon, 18 Mar 2019 13:19:08 -0400 Original-Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:40404) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h5vuk-0005t3-Bm for emacs-devel@gnu.org; Mon, 18 Mar 2019 13:19:06 -0400 Original-Received: by mail-wr1-x432.google.com with SMTP id t5so17977107wri.7 for ; Mon, 18 Mar 2019 10:19:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=eBDkf5YdgH+yk/lzs/JzgwuHgV6+eMhA5iwXNUmsGtM=; b=C+g3jZS8EXglqMtKJEd+dIDRFFms8unR1sFk3wFv49WZqsgFBufcMosJK8rlULK89n 1XEuosGRfPD+tkUu83Hmxk+DyiTH1yXyyfZSVt8QTDVmx+uexRwzLSgSQDfRdiCRwv14 iIT8O4T0ue5j58b7wvJ0rCkr0nI0MfXHtG+TZCjBIxJVGPo7mLymNiJuNHUMkdYX2Ly1 bPswxVmgrutp6N9AejT0ulCpR9A1sO2pbQhJhgPUj8byXuKKdSiKrhSguAQ+VJbzUGCW cUsxsmh75hlHXFG8sTZRh9ayqaek36oZUoB2tiThSUJFxJclAR+ZandfTeJPU2Sj/fcP ieLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=eBDkf5YdgH+yk/lzs/JzgwuHgV6+eMhA5iwXNUmsGtM=; b=o9eqYkbhWRw3KkyWrPOJ2Ous6emL3DJmDHz81u4dlcMPCXuDstUVobjBa0xhWk4VXj nomFjh/stb52gxrmWTGLeyOaipDYcDr3MePn20kFo7nnWh4lGTwYCwjIX/6d6dCdxq4x nEgPZrCFjqzgFtf+47gMzkqV859z2Sm7dZsyDd+doC7km/xAlTvwqleTZ+TokP+Cs1KB lGoRlaJcuPENBIArzq5DCyWrTUhFVnctLK8FwILyyaSoXH88XbbFgbVLieEDlu9JTFJc kV39MiA/jsTOKZBViAigStyTFE5q4tWS7hjuZDNKUN3CjBgBEwj+hPV5zrenN1UaklZR goHA== X-Gm-Message-State: APjAAAWhJjjCHcUH/901HDMUgNjXNcd5kgqJmWmFqbfb9LJH2YHzZ7gg udB3GdS3AI2t1RKbEnaZnX8PCZRU X-Google-Smtp-Source: APXvYqy4CiS5oNAcBXlpsYvSZcdTqc9l3994zQiyK2Xc7T4ETlRVM6f/+5pfoZVE2OV2LdZ/E+PEvQ== X-Received: by 2002:a5d:6b12:: with SMTP id v18mr9187279wrw.27.1552929544431; Mon, 18 Mar 2019 10:19:04 -0700 (PDT) Original-Received: from [192.168.0.195] ([109.110.245.170]) by smtp.googlemail.com with ESMTPSA id y7sm16545126wmi.34.2019.03.18.10.19.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Mar 2019 10:19:02 -0700 (PDT) In-Reply-To: Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::432 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:234334 Archived-At: On 18.03.2019 16:51, João Távora wrote: >> Try a smaller input, like just 'k'. The difference is more stark in that >> case, and the lists of completions are longer. >> >> For the same reason (lots of matches), I'm afraid simply moving matching >> to C won't bring a noticeable improvement. > > You're partly right. With shorter input, the burden shifts considerably > from completion-pcm--all-completions (the matching) to > completion-pcm--hilit-commonality (the hilighting and scoring), but > according to the CPU profiler, the former is still dominant, so even a > modest improvement there could still have a large impact. I was actually comparing flex vs basic in this scenario, and the former was 2x slower. Which is, IDK, could be noticeable. > Capping max matches (after sorting) might bring more improvements > to parts of the code that I'm not profiling (like stuff that iterates all > matches, though I'm not sure what), or by releasing large parts of the > list early for the GC to reap. Capping max matches is what all completion systems do in other editors, AFAIK. That feels kind of dirty, but could bring the most bang for the effort expended. As long as we don't confuse any caches by doing this. Also, the limit has to come *after* scoring and sorting, so for the performance improvement to arrive, it seems a lot of things would need to migrate to C. > As can other techniques like deferring the completion with an idle > timer which is reset on every keystroke. I'm reasonably confortable > with this last technique and it is usually desirable regardless of other > speed improvements, so I might have a look at that first. It's worth a try. But if filtering will happen right away after the user has stopped typing, that might mean higher CPU usage and lower battery life on a laptop. Just something to be on a lookout for.