From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#47711: bug#48841: bug#47711: bug#48841: bug#47711: [PATCH VERSION 2] Add new `completion-filter-completions` API and deferred highlighting Date: Sun, 29 Oct 2023 23:12:36 +0000 Message-ID: <8734xtauqj.fsf@gmail.com> References: <3d3f894f-a6fa-53ae-5d50-c3aa9bffc73e@daniel-mendler.de> <56ab18b1-4348-9b2c-85bb-af9b76cd429a@daniel-mendler.de> <328f87eb-6474-1442-e1ca-9ae8deb2a84a@yandex.ru> <83fsvcbio7.fsf@gnu.org> <9f432d18-e70f-54c1-0173-1899fb66d176@gutov.dev> <877cnafv39.fsf@gmail.com> <9447dde3-b8e7-2ec0-9a9c-72c4cf9d12a8@gutov.dev> <7d14bc13-4419-816c-5708-c42988c39c02@gutov.dev> <5d0a78cc-4fa0-ef04-3462-1826f17d7d56@gutov.dev> <877cn8asud.fsf@gmail.com> 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="40494"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Daniel Mendler , Eli Zaretskii , Stefan Monnier , 47711@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Oct 30 00:10:54 2023 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 1qxEvl-000APL-RN for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 30 Oct 2023 00:10:53 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qxEvP-0002IQ-MM; Sun, 29 Oct 2023 19:10:31 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qxEvN-0002IC-N5 for bug-gnu-emacs@gnu.org; Sun, 29 Oct 2023 19:10:29 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qxEvN-00023F-F2 for bug-gnu-emacs@gnu.org; Sun, 29 Oct 2023 19:10:29 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qxEvt-0007L3-Uo for bug-gnu-emacs@gnu.org; Sun, 29 Oct 2023 19:11:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 29 Oct 2023 23:11:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47711 X-GNU-PR-Package: emacs Original-Received: via spool by 47711-submit@debbugs.gnu.org id=B47711.169862102228154 (code B ref 47711); Sun, 29 Oct 2023 23:11:01 +0000 Original-Received: (at 47711) by debbugs.gnu.org; 29 Oct 2023 23:10:22 +0000 Original-Received: from localhost ([127.0.0.1]:43996 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qxEvF-0007K1-VP for submit@debbugs.gnu.org; Sun, 29 Oct 2023 19:10:22 -0400 Original-Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:53304) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qxEvC-0007Jl-Dm for 47711@debbugs.gnu.org; Sun, 29 Oct 2023 19:10:20 -0400 Original-Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-31fa15f4cc6so2793657f8f.2 for <47711@debbugs.gnu.org>; Sun, 29 Oct 2023 16:09:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698620979; x=1699225779; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6aMavgiqBpr9zBflN1DM1z02n5HlJVd9IxOJhgBeqP0=; b=l6FYtU7z2OmGrHC5vbi/OKNH0EbIRqIiUVIiQ28fh4u8XC0lWmzP7yfvhKvKlaNpux IWa1DswhpV5egyTmqgC0YMInAaQPMhU2For4rTBqjxTWO2WtUFlapps2wARooRR8Ijzg lLqdICzE0pyz9S5ADlf29Hlz8LEvaYtLe7aHssTJQFg6Er7Iv8ELX6jw6M+L2UIcMODC 2wivmUvB+dVdVUW7Wp1YWsjJ/V0SO0Rpr1MSVBNglmm5dClpu9u204z/tY01SKW8DmGW KQaN7mqGFNX0XtT/PPUU6vkFIGgle+Gj4IN6AfpYVKZWPXuD++toK0Yp4ILqbWD3LIM6 KT4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698620979; x=1699225779; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=6aMavgiqBpr9zBflN1DM1z02n5HlJVd9IxOJhgBeqP0=; b=ceDV3pR1tt493BKHdkp0sKAmoDhvD5hRt9au6hEkAVJE7nTPUDwrS1ILj7/Mxx2tpT sd1mjOzwUUYoMdcHtEuTaX1HL8EJlAjCIS4v8jdT1ny20iF1F3pXeh0EPU8nc8Sj2LFZ K+R8871W1wX5Zu8JwXNd7CheMCK02Bye0bDQkOgg9/2rO+bKfOg3eqPoLHYgqs9O1C4U Vbz/chzRcYBMgRBiQjBW2OjTC4Z2jS5fAOV063Zw2/f58oE62D965QWsQBWM+p6+JpfO BP6FwYePI/3xPS864bboPvZazjh4+PmlEDKqCHM7/eDZB/fhAOi96Tao2C/3RRgNmLMV 7cKQ== X-Gm-Message-State: AOJu0Yy5IcBXMd5uSz/xHWOw2UvOfGICeOiWULJEiU2uNSqA8+7sRHfw MAfn4iY/keJ8vdantL8EAiqk0g1ibHi7WA== X-Google-Smtp-Source: AGHT+IE9rKReEAlCXT8WRt/Hf0/zHMTAUVzPl43HlO6Q36YAJ+n/l742lBgs3GvMWFb34fNd98Xsxg== X-Received: by 2002:a5d:5186:0:b0:32d:b06c:d30b with SMTP id k6-20020a5d5186000000b0032db06cd30bmr5962332wrv.55.1698620978886; Sun, 29 Oct 2023 16:09:38 -0700 (PDT) Original-Received: from krug (87-196-72-1.net.novis.pt. [87.196.72.1]) by smtp.gmail.com with ESMTPSA id s4-20020a5d69c4000000b0032d829e10c0sm6890488wrw.28.2023.10.29.16.09.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Oct 2023 16:09:38 -0700 (PDT) In-Reply-To: (Dmitry Gutov's message of "Sun, 29 Oct 2023 01:24:50 +0300") 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:273535 Archived-At: Dmitry Gutov writes: > On 27/10/2023 20:16, Jo=C3=A3o T=C3=A1vora wrote: > Thanks. My measurements are similar, except the difference switch the > other way a little bit. It might depend on the particulars of the > individual machine anyway. Yes, it could, but I've reproduced this in different hardware. Check that you're taking enough samples, I take about 15-20 samples. Maybe the lazy-hilit patch pays a an extra cost upfront for the very first C-h v or completing-read, to create the properties keys on the strings, which are then reused. This cost is ammortized very quickly, of course, but if you're taking the measurement immediately after Emacs -Q and with few samples, it skews the numbers. > All averages made using 'M-x calc-grab-region' followed by 'u M'. Wow, thanks for this tip. I wondered if there was an easier way than M-x cua-rectangle-mark-mode + hand rolled avg function. > I just meant that your version will be easier to use in > company--match-from-capf-face (because it works on individual > completions). Ah, that was my intution too. I misunderstood you then, I thought you meant the list version would be easier and I found that odd. >>> Third, it made a principled stance to avoid altering the original >>> strings, even the non-visual text properties. This approach could be >>> adopted piecewise from Daniel's patch, especially if the performance >>> ends up the same or insignificantly different in practical usage. >> If we really wanted to, we could also adopt the non-propertizing >> approach in my lazy-hilit patch, by calculating the score "just in >> time", much like Daniel's patch does it. But it should be clear that >> what we save in allocation in completion-pcm--hilit-commonality, we'll >> pay for in the same amount in consing later. So no performance benefit. > > Not for performance, no. Although the way it separates the sorting > into its own phase makes it easier to reason about that particular > cost. And for 300000 symbols, scoring and sorting really take the most > time, e.g. about 2/3rds. Which might help with optimizing it further > down in the future, somehow, I think further optimization would be localized to the scoring function itself, not to the place where it is performed. > But if course it would be nice to avoid the wart, so if you have any > better ideas, they are welcome. I'm not saying it would necessarily spread even further, but if you want to do scoring "just in time" like I suggested -- presumably to completely avoid propertizing strings -- that particular wart spreads a little more and thus becomes something that is slightly harder to remove later on. > So far you advocated toward avoiding breaking changes while > implementing the present performance improvement. Both patches do that, so what I've been arguing for is simplicity and coherence. I don't think completion-sorted-completions and the complexity it brings to minibuffer.el is a step in the rigth direction, and the performance benefits it does undeniably bring can be achieved with less drastic means. Jo=C3=A3o