Received: (at 77684-done) by debbugs.gnu.org; 23 Apr 2025 12:06:31 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Wed Apr 23 08:06:30 2025 Received: from localhost ([127.0.0.1]:55217 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1u7Ys1-0002Vu-Iu for submit <at> debbugs.gnu.org; Wed, 23 Apr 2025 08:06:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51752) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1u7Yrx-0002UF-Dd for 77684-done <at> debbugs.gnu.org; Wed, 23 Apr 2025 08:06:26 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1u7Yrr-0000XW-Dq; Wed, 23 Apr 2025 08:06:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=UEhim9tqNPN228BU+hi58YlhLsbrwCAImIuWZoMkv0U=; b=pnOUU33SUUrQ i3QnqxlRTtLyhwbYGt2FJ//VSgykBwi90tZD1K4Upfl1+zGIkBF1Tp3z2XFIzAbOQsaSXPFhBRIvH 7W60znZXIBEWKJOu3YRmwq/WglNhZ3T0fbXKfYgqwiyZc7atCyWPWKJKC8c9y79WTbEK4P3hFieYc XGpt59IFxkPRvx1yuRIUfJvWvq/Yo3rWMGUInY9jnKGV4+9ftc4Odk1pdObaeUi75PZT+/vBhsmM+ iznXAEZ/FgtIiFCQBAd9VhOHUikzBwBrfB8AZoQ2rSPcW9eoy2V5Of6vh9NBUE4S5kI0BEPLfHqxU Y9H9ZjWBARV43ne1j0eIug==; Date: Wed, 23 Apr 2025 15:06:07 +0300 Message-Id: <86frhz13rk.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: Kristoffer Balintona <krisbalintona@HIDDEN> In-Reply-To: <CANVbq5kykGQsBiitCzPnXpWMc3BXzB2J=KH01O-L6n5BqY8Gxw@HIDDEN> (message from Kristoffer Balintona on Tue, 22 Apr 2025 17:36:32 -0400) Subject: Re: bug#77684: [PATCH] ; * lisp/emacs-lisp/vtable.el (vtable--limit-string): Use binary search References: <CANVbq5=7SGJyjjrsSVxJ6WXssua96iYonyY=bsAYk0Q1X_K9tQ@HIDDEN> <861ptwl8dd.fsf@HIDDEN> <CANVbq5kzNPJaAHr5YhnsAWkzF=YVm_DEkZ7Ei8Mf5CMJ=1gg0w@HIDDEN> <861pttj2wn.fsf@HIDDEN> <CANVbq5kykGQsBiitCzPnXpWMc3BXzB2J=KH01O-L6n5BqY8Gxw@HIDDEN> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77684-done Cc: 77684-done <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Kristoffer Balintona <krisbalintona@HIDDEN> > Date: Tue, 22 Apr 2025 17:36:32 -0400 > Cc: 77684 <at> debbugs.gnu.org > > On Tue, Apr 15 2025, Eli Zaretskii wrote: > > > Perhaps we could still use binary search, but augment it as follows: > > when a match is found by binary search, run an additional loop, which > > adds back one character at a time, as long as string-pixel-width > > returns the same value. The last character added which still yields > > the same value will be the point where to truncate the string. > > > > For long enough strings, this might still be a win, even if characters > > are composed. And for the simple case of characters that are not > > composed, this adds just one extra call to string-pixel-width. > > Thank you for the suggestion, Eli. Unfortunately, I wasn't able to find > an implementation that worked exhaustively. I ran into trouble I > couldn't resolve when the match returned by the binary search landed > within a ligature/emoji (which can span multiple characters without > necessarily changing the pixel width in predictable, monotonic ways). > > Aside from those cases, I think the binary search works quite well. > However, since it doesn't cover all the cases the current implementation > does, I think the current implementation should be kept. > > I may return to this in the future, but for now I think if developers > need performance, they should set the displayer themselves (which I will > do for my own personal projects). Thanks. So let's close this bug for now. If someone has clever ideas how to speed up vtable--limit-string, we can always reopen.
Kristoffer Balintona <krisbalintona@HIDDEN>
:Eli Zaretskii <eliz@HIDDEN>
:Received: (at 77684) by debbugs.gnu.org; 22 Apr 2025 21:36:43 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Apr 22 17:36:43 2025 Received: from localhost ([127.0.0.1]:50304 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1u7LIJ-00029L-1j for submit <at> debbugs.gnu.org; Tue, 22 Apr 2025 17:36:43 -0400 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]:54601) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <krisbalintona@HIDDEN>) id 1u7LIG-00028z-Bv for 77684 <at> debbugs.gnu.org; Tue, 22 Apr 2025 17:36:41 -0400 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-54b0d638e86so6705214e87.1 for <77684 <at> debbugs.gnu.org>; Tue, 22 Apr 2025 14:36:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745357793; x=1745962593; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=chz+RrOgmlZszc137/uieHNCN5ZuSnAy16iA9p/vAS8=; b=bANBU0Kj7GeknDRUiXhGf+5G3WP9tCcUhq/Cukq2Ig3lOysBBqy4vLcd3+1HOFxIOE c7hcQoBTzWo6ELbzFjvWD41tSVBIPXkyM6Z7PIFyYjrzsShELQUps0ck+4Q7fVwdWgCO giZObxqoIWMwfGx1QWriqgHkPmNH9nYLeUiuFG0AR1UKJL2OMqaPQDUJtZq6n2zeN2Fz 2zvjylFp5vrFF0Y87VfGnWDd5QlfGOU2UG4cbDYmNHmlWcqUZ4q7nL+8eiWCY0Q8LE0y 7wOMOKheUD2f1VVC18ShREPMj/gpLnOx0Ye0K05HybvRwXsCZ6a4HILUZymKnhAZ3ZVR o2Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745357793; x=1745962593; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=chz+RrOgmlZszc137/uieHNCN5ZuSnAy16iA9p/vAS8=; b=wZtoZCa0HpWajMqi8ygEiPQlrZFBu4a6q4DArCHagnZClkBT70pNsX9wdx50yj1B5+ g1vWL/6H7d0O8HUlXAQNjB0eeYJ9e68F4wYrC278cmP2PMojCcbkS0jcSs8PSE9FvnL1 iDwbC39QAmzHEYGrornYwaGn8y88kgJanUdGvTkqxNaLxIvS2woUaZyUpQVTEnNZJBxl r+mu6YbH577eoUsmGDmRdtT5HRiwr27RPK+Zv0Dew4sDppxtnUOSSE+Wg2X8nxwqOV4V RuWc34QIMcq4ZNJmQQMlt8UtI+zbI0w6Bs51b9rCVeI8LvhqMaFWipu6ACxMnLl62bRR DxMg== X-Gm-Message-State: AOJu0YzUAYNRVBNwYZsEzzJXvtwjezQ446s6wayNZmDP+gGL0jrP6VYR kbVEth+icn0BNJzgKjyiRWhwAT0PPCoXXvcKB8tzgn9NeI3hnLQYoR94KcZ1DgTWEt4Gpslw9q/ +8tp64+S+0kYjwAmkDLIqHntUFdw= X-Gm-Gg: ASbGncuBFZQuDhu8rVQU3wMCML3nE++e2yZTQd3cDUHVksxGus0/JdTlIZw2g5ueg2z 2R78mHofBeTR65DEbKl/KliGTenvrYegiOdVUWv0qfVOIVvgfOqqQdhwMczCEKd8JzQMbQv8V0M S7pUQtXy+y+IBsqAojHn9lVA== X-Google-Smtp-Source: AGHT+IGY9DybkXLnkh5N1x3uIz7xKrdxy8bp9pOuU6CdBJSWaPlBizmaFw5kWwwbYS9lcFumNQL+3ceVGOCrLZECyoE= X-Received: by 2002:a05:6512:2311:b0:54b:117c:8ef3 with SMTP id 2adb3069b0e04-54d6e676fe3mr4454307e87.54.1745357792508; Tue, 22 Apr 2025 14:36:32 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Tue, 22 Apr 2025 17:36:32 -0400 Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Tue, 22 Apr 2025 17:36:32 -0400 From: Kristoffer Balintona <krisbalintona@HIDDEN> In-Reply-To: <861pttj2wn.fsf@HIDDEN> References: <CANVbq5=7SGJyjjrsSVxJ6WXssua96iYonyY=bsAYk0Q1X_K9tQ@HIDDEN> <861ptwl8dd.fsf@HIDDEN> <CANVbq5kzNPJaAHr5YhnsAWkzF=YVm_DEkZ7Ei8Mf5CMJ=1gg0w@HIDDEN> <861pttj2wn.fsf@HIDDEN> MIME-Version: 1.0 Date: Tue, 22 Apr 2025 17:36:32 -0400 X-Gm-Features: ATxdqUG3N0r3C2ITnZzZdTsVYEdDBFj7ujkbgKEC378mX5aCCk0utVXAhTavOc0 Message-ID: <CANVbq5kykGQsBiitCzPnXpWMc3BXzB2J=KH01O-L6n5BqY8Gxw@HIDDEN> Subject: Re: bug#77684: [PATCH] ; * lisp/emacs-lisp/vtable.el (vtable--limit-string): Use binary search To: Eli Zaretskii <eliz@HIDDEN> Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77684 Cc: 77684 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) On Tue, Apr 15 2025, Eli Zaretskii wrote: > Perhaps we could still use binary search, but augment it as follows: > when a match is found by binary search, run an additional loop, which > adds back one character at a time, as long as string-pixel-width > returns the same value. The last character added which still yields > the same value will be the point where to truncate the string. > > For long enough strings, this might still be a win, even if characters > are composed. And for the simple case of characters that are not > composed, this adds just one extra call to string-pixel-width. Thank you for the suggestion, Eli. Unfortunately, I wasn't able to find an implementation that worked exhaustively. I ran into trouble I couldn't resolve when the match returned by the binary search landed within a ligature/emoji (which can span multiple characters without necessarily changing the pixel width in predictable, monotonic ways). Aside from those cases, I think the binary search works quite well. However, since it doesn't cover all the cases the current implementation does, I think the current implementation should be kept. I may return to this in the future, but for now I think if developers need performance, they should set the displayer themselves (which I will do for my own personal projects). -- In gratitude, Kristoffer
bug-gnu-emacs@HIDDEN
:bug#77684
; Package emacs
.
Full text available.Received: (at 77684) by debbugs.gnu.org; 15 Apr 2025 11:30:28 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Apr 15 07:30:28 2025 Received: from localhost ([127.0.0.1]:50955 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1u4eUl-0003qA-Cw for submit <at> debbugs.gnu.org; Tue, 15 Apr 2025 07:30:28 -0400 Received: from mail-ua1-x935.google.com ([2607:f8b0:4864:20::935]:52646) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <shipmints@HIDDEN>) id 1u4eUi-0003T0-Md for 77684 <at> debbugs.gnu.org; Tue, 15 Apr 2025 07:30:25 -0400 Received: by mail-ua1-x935.google.com with SMTP id a1e0cc1a2514c-86fab198f8eso2241532241.1 for <77684 <at> debbugs.gnu.org>; Tue, 15 Apr 2025 04:30:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744716619; x=1745321419; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=hZgViiV2DnuEhtohJhJQtY1ZmdKVsinrshVjvvS0W58=; b=XJ5tbmAY8n8wDSvT/kKFLgP2vIaBOSs+eBBX+b1FWhWOTL3O/zvx1ebVVRL4N1I8Uv i9KlBKYSJHt/VmCz3eETCYHrHkWN0F+L8nJFtpzG9S0bitxP4oQf9vveRxY11xTGobPv xYOMycT1DQkQi4MPNQpKKsShmNThYFAJges3Zy0Twz89jpaU9HynR8x66uLvRvzuZVW0 efarcGV17s1tC6PIxNLkbzt4jdSv0f+i62BWJVXtJ/a3L+TDX/zI8t6iogA8KYE5IlEU /5CK69umKBw7aUMcQeByS8B9LAmIsFN1p0DfwEzFW6HB+IwbIExyATN5DGOWxmAZcm2u BUwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744716619; x=1745321419; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=hZgViiV2DnuEhtohJhJQtY1ZmdKVsinrshVjvvS0W58=; b=Yw/UwKanD+D9KFTPCiP3KWrZliu4OuyUfFDYGcHCSMKq7y52ZqyWDxbMHAmHQ4WD5A q0XZY7zxFXM9POKpPM4Rj4oQfhzTQY7cFs0RGRc7CSUqYErQR+3f3kWLbq5m/KtPjDv3 7T3CPIP0Niywe0qnCbdWDMuDmDHwSBurejnLD137KjeMGVaC2ILhLP0NN+OmTZcwmkYQ +ixyJq3JogTmEaHNPcuiInRlfz2ot92Iva+K2YZt66HjBlLfTnJqnloCTGOOaiCRhDoE M2T6tormEW2IloTaO34Xy8yq0EeaOt6scq+d9jDwz7MzMHylTyvXC2iHyQEzKJMMbx5M FASQ== X-Forwarded-Encrypted: i=1; AJvYcCWJSbD6HAPNq54oeqf3NXIO3riSr5i3hAnEmtvkB2LQzX8O63bK2Ko9T6Bs8rdDvaIE6NDwww==@debbugs.gnu.org X-Gm-Message-State: AOJu0YwZ0Mkulka+ZcLeI9nWiJAp/5Gz1rpEpV6ehxx7UkZ+kedND4Dq JhczEgvFi6i1sQWjiCzA8YgAnx1fu9ojZk/BYZrvDf3jpFmw46ZJTz0ZTwqouuS/5tmqq/wV7DD 3CAp7t8vs9nLIB10s554XVEMRrVo/kQ== X-Gm-Gg: ASbGnctQ5LAHyhvMRu0NUeQs2+oVROaKGBffHeqeBOIdhl1IHfuKXKfnvOqzG+ru5Hz 1L2tw9tVKZN9UNvUV+69BYpO0lS4Os6tsUsPUyqb8IVV/FHWDXFEKEGWsSjoeAL4yd0RnQyz3I0 wEGAo7ThozokLFrj4opkoIsQ== X-Google-Smtp-Source: AGHT+IGNvkjMfuhvi0RcmkwaVHsdYDrAUYFMEmrmuzIRgVFp8i5xEVnp/d/lh2P08S5GXyUcJ2LXh8F+cNjY+ZcyIDw= X-Received: by 2002:a05:6102:2ad0:b0:4c2:fa6a:7e2d with SMTP id ada2fe7eead31-4c9e4ec05d8mr9207246137.1.1744716618967; Tue, 15 Apr 2025 04:30:18 -0700 (PDT) MIME-Version: 1.0 References: <CANVbq5=7SGJyjjrsSVxJ6WXssua96iYonyY=bsAYk0Q1X_K9tQ@HIDDEN> <861ptwl8dd.fsf@HIDDEN> <CANVbq5kzNPJaAHr5YhnsAWkzF=YVm_DEkZ7Ei8Mf5CMJ=1gg0w@HIDDEN> <861pttj2wn.fsf@HIDDEN> In-Reply-To: <861pttj2wn.fsf@HIDDEN> From: Ship Mints <shipmints@HIDDEN> Date: Tue, 15 Apr 2025 07:30:07 -0400 X-Gm-Features: ATxdqUEDp7eaP-1kL0Vx4RzbwyPqjlfuPPSYhuyAU4t1zXLpvLq7JqsIrFM_gjg Message-ID: <CAN+1Hbq1Qb9WK_Pa0-VNcYS0Ujf9QbEb9SRh8Qy+ZR=1y3Rfbg@HIDDEN> Subject: Re: bug#77684: [PATCH] ; * lisp/emacs-lisp/vtable.el (vtable--limit-string): Use binary search To: Eli Zaretskii <eliz@HIDDEN> Content-Type: multipart/alternative; boundary="0000000000004eb2820632cf7ec0" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77684 Cc: 77684 <at> debbugs.gnu.org, Kristoffer Balintona <krisbalintona@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --0000000000004eb2820632cf7ec0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Apr 15, 2025 at 3:33=E2=80=AFAM Eli Zaretskii <eliz@HIDDEN> wrote: > > From: Kristoffer Balintona <krisbalintona@HIDDEN> > > Date: Mon, 14 Apr 2025 18:35:48 -0700 > > Cc: 77684 <at> debbugs.gnu.org > > > > On Sun, Apr 13 2025, Eli Zaretskii wrote: > > > > > Binary search will only work if adding or removing a character will > > > always change the result of string-pixel-width. But this is not true > > > in general, due to character composition and other Emacs display > > > features. Here's a simple example of such an issue: > > > > > > (string-pixel-width "a") > > > =3D> 9 > > > (string-pixel-width (concat "a" "=CC=81")) > > > =3D> 9 > > > > > > So adding a character doesn't affect the result of string-pixel-width= , > > > in this case because the two characters will be displayed by a single > > > glyph that combines the base character 'a' and the acute accent. > > > > > > Did you try your modified code in such situations, or did you only tr= y > > > it with simple characters that never combine? > > > > I see. I think you're right: the vast majority of characters I tried my > > code against were simple characters. I rarely interact with characters > > that combine so when I wrote my version I hadn't considered how they're > > treated in Emacs. > > > > So I suppose my patch doesn't work. However, then, my question is > > whether vtable--limit-string can be made significantly more performant = to > > begin with, or if we're stuck with string-pixel-width being a potential > > bottleneck. > > Perhaps we could still use binary search, but augment it as follows: > when a match is found by binary search, run an additional loop, which > adds back one character at a time, as long as string-pixel-width > returns the same value. The last character added which still yields > the same value will be the point where to truncate the string. > > For long enough strings, this might still be a win, even if characters > are composed. And for the simple case of characters that are not > composed, this adds just one extra call to string-pixel-width. > Perhaps a binary search would suffice. In vtable's case, a heuristic for the string pixel-fit abbreviator could be hinted. It could start with the column's name length. Just an idea. vtable does not currently consider just the rows that are displayed, but considers the entire row set. In the end, the programmer knows the data and really should consider accommodating strings they suspect or know will need pixel-wise abbreviation. Perhaps the vtable documentation should mention that pixelwise operations can be expensive and to specify column widths and provide "formatters" and "displayers" tuned to their data. -Stephane --0000000000004eb2820632cf7ec0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div dir=3D"ltr"><div class=3D"gmail_default" style=3D"fon= t-family:monospace"><span style=3D"font-family:Arial,Helvetica,sans-serif">= On Tue, Apr 15, 2025 at 3:33=E2=80=AFAM Eli Zaretskii <<a href=3D"mailto= :eliz@HIDDEN">eliz@HIDDEN</a>> wrote:</span></div></div><div class=3D"= gmail_quote gmail_quote_container"><blockquote class=3D"gmail_quote" style= =3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding= -left:1ex">> From: Kristoffer Balintona <<a href=3D"mailto:krisbalint= ona@HIDDEN" target=3D"_blank">krisbalintona@HIDDEN</a>><br> > Date: Mon, 14 Apr 2025 18:35:48 -0700<br> > Cc: <a href=3D"mailto:77684 <at> debbugs.gnu.org" target=3D"_blank">77684@d= ebbugs.gnu.org</a><br> > <br> > On Sun, Apr 13 2025, Eli Zaretskii wrote:<br> > <br> > > Binary search will only work if adding or removing a character wi= ll<br> > > always change the result of string-pixel-width.=C2=A0 But this is= not true<br> > > in general, due to character composition and other Emacs display<= br> > > features.=C2=A0 Here's a simple example of such an issue:<br> > ><br> > >=C2=A0 =C2=A0(string-pixel-width "a")<br> > >=C2=A0 =C2=A0 =3D> 9<br> > >=C2=A0 =C2=A0(string-pixel-width (concat "a" "=CC= =81"))<br> > >=C2=A0 =C2=A0 =3D> 9<br> > ><br> > > So adding a character doesn't affect the result of string-pix= el-width,<br> > > in this case because the two characters will be displayed by a si= ngle<br> > > glyph that combines the base character 'a' and the acute = accent.<br> > ><br> > > Did you try your modified code in such situations, or did you onl= y try<br> > > it with simple characters that never combine?<br> > <br> > I see. I think you're right: the vast majority of characters I tri= ed my<br> > code against were simple characters. I rarely interact with characters= <br> > that combine so when I wrote my version I hadn't considered how th= ey're<br> > treated in Emacs.<br> > <br> > So I suppose my patch doesn't work. However, then, my question is<= br> > whether vtable--limit-string can be made significantly more performant= to<br> > begin with, or if we're stuck with string-pixel-width being a pote= ntial<br> > bottleneck.<br> <br> Perhaps we could still use binary search, but augment it as follows:<br> when a match is found by binary search, run an additional loop, which<br> adds back one character at a time, as long as string-pixel-width<br> returns the same value.=C2=A0 The last character added which still yields<b= r> the same value will be the point where to truncate the string.<br> <br> For long enough strings, this might still be a win, even if characters<br> are composed.=C2=A0 And for the simple case of characters that are not<br> composed, this adds just one extra call to string-pixel-width.<br></blockqu= ote><div><br></div><div class=3D"gmail_default" style=3D"font-family:monosp= ace">Perhaps a binary search would suffice.=C2=A0 In vtable's case, a h= euristic for the string pixel-fit abbreviator could be hinted.=C2=A0 It cou= ld start with the column's name length.=C2=A0 Just an idea.</div><div c= lass=3D"gmail_default" style=3D"font-family:monospace"><br></div><div class= =3D"gmail_default" style=3D"font-family:monospace">vtable does not currentl= y consider just the rows that are displayed, but considers the entire row s= et.</div><div class=3D"gmail_default" style=3D"font-family:monospace"><br><= /div><div class=3D"gmail_default" style=3D"font-family:monospace">In the en= d, the programmer knows the data and really should consider accommodating s= trings they suspect or know will need pixel-wise abbreviation.=C2=A0 Perhap= s the vtable documentation should mention that pixelwise operations can be = expensive and to specify column widths and provide "formatters" a= nd "displayers" tuned to their data.</div><div class=3D"gmail_def= ault" style=3D"font-family:monospace"><br></div><div class=3D"gmail_default= " style=3D"font-family:monospace">-Stephane</div></div></div> --0000000000004eb2820632cf7ec0--
bug-gnu-emacs@HIDDEN
:bug#77684
; Package emacs
.
Full text available.Received: (at 77684) by debbugs.gnu.org; 15 Apr 2025 07:32:39 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Apr 15 03:32:39 2025 Received: from localhost ([127.0.0.1]:50361 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1u4amc-0004fQ-KS for submit <at> debbugs.gnu.org; Tue, 15 Apr 2025 03:32:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51314) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1u4amZ-0004fA-Ki for 77684 <at> debbugs.gnu.org; Tue, 15 Apr 2025 03:32:36 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1u4amS-0005lS-Vb; Tue, 15 Apr 2025 03:32:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=GmguT5c9Hnh59PKtzUvGvEvGIoWM/HisqTlsZy1ZQJI=; b=eb0WYpib02TE6zeYgKFY 3aOqkfQid3iWiBJ1/gHaWFp3oI6EL0SqkcnNUNJW1EKwTIv1nYfrgOtu2xxVsuwaz/PeFhfSDLaLV X0I+0dOJi9FwFygkAVRkf0JMqM3UnYYtDzxhEp4a+WwfysGqSn3fJAcwmhbvJSZW+wU7wvTI4uz93 LMtABdSBWg0wROHSZP+bj2vWgTq6iForUUp6+Agr9CoxumwT4fqJZJV++CSwfPx9cnOx++OS9MRa6 9XmxAhAnVqYdfimzugL84eRMjweJa1eASmIwXWEeq0C1AqRINZbFtgJV9c04HAEfg8NUAuQXis4fe +vni2kumOx4pPw==; Date: Tue, 15 Apr 2025 10:32:24 +0300 Message-Id: <861pttj2wn.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: Kristoffer Balintona <krisbalintona@HIDDEN> In-Reply-To: <CANVbq5kzNPJaAHr5YhnsAWkzF=YVm_DEkZ7Ei8Mf5CMJ=1gg0w@HIDDEN> (message from Kristoffer Balintona on Mon, 14 Apr 2025 18:35:48 -0700) Subject: Re: bug#77684: [PATCH] ; * lisp/emacs-lisp/vtable.el (vtable--limit-string): Use binary search References: <CANVbq5=7SGJyjjrsSVxJ6WXssua96iYonyY=bsAYk0Q1X_K9tQ@HIDDEN> <861ptwl8dd.fsf@HIDDEN> <CANVbq5kzNPJaAHr5YhnsAWkzF=YVm_DEkZ7Ei8Mf5CMJ=1gg0w@HIDDEN> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77684 Cc: 77684 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Kristoffer Balintona <krisbalintona@HIDDEN> > Date: Mon, 14 Apr 2025 18:35:48 -0700 > Cc: 77684 <at> debbugs.gnu.org > > On Sun, Apr 13 2025, Eli Zaretskii wrote: > > > Binary search will only work if adding or removing a character will > > always change the result of string-pixel-width. But this is not true > > in general, due to character composition and other Emacs display > > features. Here's a simple example of such an issue: > > > > (string-pixel-width "a") > > => 9 > > (string-pixel-width (concat "a" "́")) > > => 9 > > > > So adding a character doesn't affect the result of string-pixel-width, > > in this case because the two characters will be displayed by a single > > glyph that combines the base character 'a' and the acute accent. > > > > Did you try your modified code in such situations, or did you only try > > it with simple characters that never combine? > > I see. I think you're right: the vast majority of characters I tried my > code against were simple characters. I rarely interact with characters > that combine so when I wrote my version I hadn't considered how they're > treated in Emacs. > > So I suppose my patch doesn't work. However, then, my question is > whether vtable--limit-string can be made significantly more performant to > begin with, or if we're stuck with string-pixel-width being a potential > bottleneck. Perhaps we could still use binary search, but augment it as follows: when a match is found by binary search, run an additional loop, which adds back one character at a time, as long as string-pixel-width returns the same value. The last character added which still yields the same value will be the point where to truncate the string. For long enough strings, this might still be a win, even if characters are composed. And for the simple case of characters that are not composed, this adds just one extra call to string-pixel-width.
bug-gnu-emacs@HIDDEN
:bug#77684
; Package emacs
.
Full text available.Received: (at 77684) by debbugs.gnu.org; 15 Apr 2025 02:54:19 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 14 22:54:19 2025 Received: from localhost ([127.0.0.1]:49867 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1u4WRG-0004eq-RR for submit <at> debbugs.gnu.org; Mon, 14 Apr 2025 22:54:19 -0400 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]:45093) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <krisbalintona@HIDDEN>) id 1u4WRE-0004eP-Cc for 77684 <at> debbugs.gnu.org; Mon, 14 Apr 2025 22:54:16 -0400 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-54993c68ba0so6315520e87.2 for <77684 <at> debbugs.gnu.org>; Mon, 14 Apr 2025 19:54:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744685650; x=1745290450; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=//2xGC7tPrPbu9PySnooFqVWXwB5DfKeeXFnSRFQmQQ=; b=Qao+MxpDfqsn6mjZBQV/RIggW92MhW+soiDU1YWtKmP4wLNph33DfJozv3z1uwphbS 2fHUJTrDJnmZXXatMW//Eigp/5syF2ICJj+dWBr54SST9CQy8d0CB9H6mcvZl2CDy6Dm TZ2V+ycqwJin7cTDum/uKCJKbuzBj9kYHZieooaHj4M4Y4WBlSeB/X3Eh/aS7hwUCqM9 HAZvIX2MeYAU1jeCYZtmhSqFVMCKKJwla3niCW47ZOz3s0etCHEKvBaxY/z4qDx3e1Am oFm4e1/iWYkF1Av5XTCygdwhGu2xm965QpftIU/JiJ+V6Ubx1Bcob8EGo8Ob/iMnUhJ5 XKnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744685650; x=1745290450; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=//2xGC7tPrPbu9PySnooFqVWXwB5DfKeeXFnSRFQmQQ=; b=iN4HA2bW+gaYiHbD5Z/uWZSi27wNTDdeRAxa1qA1PDwouzooPlx5gXddS4pemY9E3w c/EHmsGWPtTAmsTI6zYksFBnQoCTBUccRToOWc2EIiPtiPtD6Io7Ld71wOvxqD0TmBMH MsHgxMWD8GuV5YxTnEQ4Y1YpYEKz0DhL+n6fY+yrVDhL0hhiBftXpb6e48M5vUEP64g8 XMou3qJe5z9ipnJ/LZYHIx6unwysmgcQVZx2bruR95UnGyHW4J4MYRfVXwj4GlQfekuJ oGlCY4e+yH9NGYoIOpCxWMOztURz1U3h8piqixUtyQcxkhg8OE8xMgRR2cFo9NBYiSTi mcog== X-Gm-Message-State: AOJu0YyOVIfWQHI2cv4QL84092aC6d+Hko0R4A7Y4PVBYNm0J+OEOvOJ 2G/QSJh5O+yUkHCttuhFTewrAVHIee9qYb34130QmiFJz1HvEIIuVjVR5I5kLL0ZwUe4uANYt8Q JPzUoHxff/anHV7t4J5JwrlTRxX4= X-Gm-Gg: ASbGncsp2J5vzGPi+Qw1CyyQsos4UKrWzLMu/hUOfPOk0FUiZKQyOaaCPS2t5cgAuka EgVLBw9l1x+RTKNIUOqldeIWoPcOSAP0cfA68WhI4aYF8CDP7z7Yi5QibwItYE6esWQHe3SHgfj ObutBUWcPgdlpVg+bZtKfAN1UJSYu66c4R X-Google-Smtp-Source: AGHT+IFUfB+ky2ILW2CkhlUdxZb5p5rfe+XPcl/PSCIMfH8baHwft7v92/nJgQl+NoQFW+g+7tITwwKQQNGXEpRZI2s= X-Received: by 2002:a05:6512:33d2:b0:545:f4b:ed58 with SMTP id 2adb3069b0e04-54d45291d5emr4415424e87.18.1744685649836; Mon, 14 Apr 2025 19:54:09 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 14 Apr 2025 19:54:09 -0700 Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 14 Apr 2025 19:54:09 -0700 From: Kristoffer Balintona <krisbalintona@HIDDEN> In-Reply-To: <CAN+1HbrHQUGyg0BEMVQpHocCUNqmW=PsVjLe7mTu8haRa7mk7w@HIDDEN> References: <CANVbq5=7SGJyjjrsSVxJ6WXssua96iYonyY=bsAYk0Q1X_K9tQ@HIDDEN> <861ptwl8dd.fsf@HIDDEN> <CAN+1HbrHQUGyg0BEMVQpHocCUNqmW=PsVjLe7mTu8haRa7mk7w@HIDDEN> MIME-Version: 1.0 Date: Mon, 14 Apr 2025 19:54:09 -0700 X-Gm-Features: ATxdqUGfpDavCzpejJy-BpXFXg0l2cVTg-wh6TBwp13nnvaumn0bAqxs72HOsnA Message-ID: <CANVbq5n0Cko=bQyZBPNkK1dEUoX-=df5MpBYd1yir+3kE0MBwA@HIDDEN> Subject: Re: bug#77684: [PATCH] ; * lisp/emacs-lisp/vtable.el (vtable--limit-string): Use binary search To: Ship Mints <shipmints@HIDDEN>, Eli Zaretskii <eliz@HIDDEN> Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77684 Cc: 77684 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) On Sun, Apr 13 2025, Ship Mints wrote: > You can avoid the cost of this string metric by supplying your own global > displayer function for the table or a column-specific displayer function. > > Apropos timing as I've been spending some time with vtable and I have a > bunch of bug fixes and a few enhancements coming. One will slow down that > function a little more...vtable breaks under remapped fonts; e.g., when > using text-scale-adjust so I've fixed that (I have some pixel adjustments > left on the header which still gets out of alignment a little). Thank you, that's a good idea. I hadn't realized the truncation based on string width happens during the display phase. Based on Eli's remarks, my patch might not be appropriate, but I think modifying the displayer function will do. Though I suppose it'd be nice if the Info manual mentioned that the displayer would be where users could address performance related concerns. -- In gratitude, Kristoffer
bug-gnu-emacs@HIDDEN
:bug#77684
; Package emacs
.
Full text available.Received: (at 77684) by debbugs.gnu.org; 15 Apr 2025 01:35:59 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 14 21:35:59 2025 Received: from localhost ([127.0.0.1]:49765 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1u4VDT-0000xt-Db for submit <at> debbugs.gnu.org; Mon, 14 Apr 2025 21:35:59 -0400 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]:43284) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <krisbalintona@HIDDEN>) id 1u4VDP-0000xb-H4 for 77684 <at> debbugs.gnu.org; Mon, 14 Apr 2025 21:35:56 -0400 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-54991d85f99so6311141e87.1 for <77684 <at> debbugs.gnu.org>; Mon, 14 Apr 2025 18:35:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744680949; x=1745285749; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:from:to:cc:subject:date :message-id:reply-to; bh=wnW0lBb5s8BQWHVila9mQw2li5Q3mckbJPna8va582A=; b=DNht0kbhz5QBULfQ8JSZbr9IrhnKWk6+MwKg2UpNV+/NKF3YW93+Tsr7R1pbk/QL/W M6F8bJHd99pUsZQcTmW5zj9wxQPOrRRxHpJd/7KnUNgvZBaMoXPF19I3wyOGag+eJQYL HS3eW62N9AdwLfhTmsXfJ8St+Qe4qWH6D6wsjpyti7qP8axKwI/AemFDvGIpCgy43F+t 8ODFwKxMSwMnhSHDc3+rQ6VIdLHa+2aDHuMwbXyI2Onksu/bhEhZUq8K7O6+BssqSDCr q8IWnHs7WVuv9MsCwyZuB2X4iLKAAmr328niRL1UmRQW4KnMwTPAmqtmYKdOriDyneoF HyFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744680949; x=1745285749; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=wnW0lBb5s8BQWHVila9mQw2li5Q3mckbJPna8va582A=; b=DpOalTNYdEJLRg6Ro5StE8viGTQ7HRCmXOMldrXdCzaU2qpgd9dAWhMz8v7Uahq0oJ 0AS7h8gJ089u30JzZgn16SR0tEQ681pvE7D0+3zVhItUG8HTOb9H2fo56ZpMNjPLz+Xo ZEE3GVbWqBmRXH5OOf3Xna7Uo+QYxCZBESoagavca1HA8Qgv19hZs3Zn1108Ni3utqVD tQ4hWNzG27PQUomLEqEf3NJlMIsG+EShgGOlc3/A+MFTJDJQktrI6rjI8TfvtCP2x5td ULz/TS5IxSnnaYTEU4MwVDdW27ltrbxUKYddL83Umso6thBoeVSoqXV817OVGRRqos/f ik9A== X-Gm-Message-State: AOJu0YxjPKLr9/qyzpE4ey8Pqreit5pd1S8nXjQDfYWOGFOl9RXkfYif Pvou3jl4Q54mHc9n9kGWzmw4BUOY4U0UXyHoAuxb4Lo2tb0Zef85p49WIx969sYrzxHe+66VN6i t90elzKuwupqY+d00vY2idGFeeqE2xA== X-Gm-Gg: ASbGnctV5ODL2wzSzGn+cdtCBwEiAB2AALr62Wkh4fl/1wcrDneMLpPgNwD7ltkmiQ4 jUlET4pB4H6VVdqGNcVDDh9tBdiiiFlrzVZtvZ86CYJ9SP+lN7QeYG7r7eQGzeNMGhuDGHrSh+A iIMOSuxIcn2SAYNK/Ih4QbuQ== X-Google-Smtp-Source: AGHT+IHY40an/70VwoET7NeYBdUS0rj4nM3Nb8vLfErIHPc9K7RUmBZjBSbWaZQO/7GTAcRisjAEl7dXyPhHA+6uQJI= X-Received: by 2002:a05:6512:2c0a:b0:549:5dcf:a5b with SMTP id 2adb3069b0e04-54d59640905mr498327e87.4.1744680948701; Mon, 14 Apr 2025 18:35:48 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 14 Apr 2025 18:35:48 -0700 Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 14 Apr 2025 18:35:48 -0700 From: Kristoffer Balintona <krisbalintona@HIDDEN> In-Reply-To: <861ptwl8dd.fsf@HIDDEN> References: <CANVbq5=7SGJyjjrsSVxJ6WXssua96iYonyY=bsAYk0Q1X_K9tQ@HIDDEN> <861ptwl8dd.fsf@HIDDEN> MIME-Version: 1.0 Date: Mon, 14 Apr 2025 18:35:48 -0700 X-Gm-Features: ATxdqUFrgWplLXfZANDkOwLbqRx1QdiCM96WEmQDpisV8fGxveLOdvHXfvIjxRE Message-ID: <CANVbq5kzNPJaAHr5YhnsAWkzF=YVm_DEkZ7Ei8Mf5CMJ=1gg0w@HIDDEN> Subject: Re: bug#77684: [PATCH] ; * lisp/emacs-lisp/vtable.el (vtable--limit-string): Use binary search To: Eli Zaretskii <eliz@HIDDEN> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77684 Cc: 77684 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) On Sun, Apr 13 2025, Eli Zaretskii wrote: > Binary search will only work if adding or removing a character will > always change the result of string-pixel-width. But this is not true > in general, due to character composition and other Emacs display > features. Here's a simple example of such an issue: > > (string-pixel-width "a") > =3D> 9 > (string-pixel-width (concat "a" "=CC=81")) > =3D> 9 > > So adding a character doesn't affect the result of string-pixel-width, > in this case because the two characters will be displayed by a single > glyph that combines the base character 'a' and the acute accent. > > Did you try your modified code in such situations, or did you only try > it with simple characters that never combine? I see. I think you're right: the vast majority of characters I tried my code against were simple characters. I rarely interact with characters that combine so when I wrote my version I hadn't considered how they're treated in Emacs. So I suppose my patch doesn't work. However, then, my question is whether vtable--limit-string can be made significantly more performant to begin with, or if we're stuck with string-pixel-width being a potential bottleneck. OTOH, Ship Mints made a suggestion elsewhere in the thread that I'll try. If it suffices, I'll use that for my personal uses instead. --=20 With appreciation, Kristoffer
bug-gnu-emacs@HIDDEN
:bug#77684
; Package emacs
.
Full text available.Received: (at 77684) by debbugs.gnu.org; 13 Apr 2025 11:15:32 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Apr 13 07:15:32 2025 Received: from localhost ([127.0.0.1]:39889 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1u3vJC-0001EW-Pz for submit <at> debbugs.gnu.org; Sun, 13 Apr 2025 07:15:31 -0400 Received: from mail-ua1-x92a.google.com ([2607:f8b0:4864:20::92a]:57749) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <shipmints@HIDDEN>) id 1u3vJA-0001DR-Os for 77684 <at> debbugs.gnu.org; Sun, 13 Apr 2025 07:15:29 -0400 Received: by mail-ua1-x92a.google.com with SMTP id a1e0cc1a2514c-86d5e42c924so2937205241.3 for <77684 <at> debbugs.gnu.org>; Sun, 13 Apr 2025 04:15:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744542923; x=1745147723; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=RMmLB3tC9h/26e6FMkCczpgoL4PfaymyEkG9IGML/EU=; b=mXbtgsMEHQGu60vhXeqWVw7fgy55kSd3UJ82LWBgnTgsfzx8PWsoUvXCTWf6fof+yb ZRrmvo+mferhKtcQ5Mb9O/Ns2Zic3C4RU6wStecDxxGbhpPx0ARAjmQcs8sML3lvzMKC pVelN8Fy2tSwThg9Kjf8HKpD9NlWi/ja3VhRM0UK+oaY8ayDKDiwcGaOuMWnh6vIIGuR ecc2tgdMoU9H43FoQCeNjf2hHIUWzd2BGJ8KTcMKBVhPpzp9s/jxyyZQxUFdvFhclG1I 6cUd1gwFOTyof4XcTwAKWe2Rk1SpJ6V/BWz2bMSW2sO2VCbzUZcHSEXSr2fIoNvAJ+WC mWUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744542923; x=1745147723; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=RMmLB3tC9h/26e6FMkCczpgoL4PfaymyEkG9IGML/EU=; b=VVDIV/D6DYOUpJncoHJmqW8oZNFeZsK/RijsYPQq0fNrVmnfNaTdk8VcuOn537TVoX 5Azonp769rdO69S3CfUdgzKe0ux3zoC3sd3MHXMM7DCZX9TStj4y21YVQYxYINNb6VpH v2YUWqG9YXbkI3eGwQ/VWxQSNfMJknHR18HO6geKkWljdm0PxmADp4xSs1Q+2Td7rREF /cSJPD3RHgeh4lgmpqYMy3DO3uav4Y3ldtkN2XkSkOggJpHuEataEw6gmFipcfS8O+Qd NZ0AR3eXs7FvukMEKuO2nIFkouPzeIqoXZP5Zhoa4NdjIp9AS0GF1YxF+aqMmaFV9Nv9 dYiQ== X-Forwarded-Encrypted: i=1; AJvYcCXhYmZ/AmzqLXTKDEfhdVC2iRZhRxWr9heYJBRGFAeb9TkHrGgS+fu9yLXB/IUD4uuQuajcCg==@debbugs.gnu.org X-Gm-Message-State: AOJu0Yz5joE8UDmUjfI46ANPOV1X1PTLYPq5byeeMYH27GbRtAA2yTyo N6NsZW+cj6ANR5EY9hrepGQe7QnTkiGis3dgyzSdJjD7WSaMj0/LNSuvM6PE2oxlc4yTIY65tI9 Gn7xa+XzR4aWr8ZRDIeQaW7i9jBM= X-Gm-Gg: ASbGncv1wiKkFt4aseUeW77nZjQZB3IcN5xqWsMSaEctwZRajsyymyUyz46TSiarfzE duuEesN2Tf+gNJiqCR4XMNvX7DNa7K11pufO47iXNwHVXIk6sgkPJMHaQtKs02pnooKa11xz+n1 0yL8Pcdrx62VYwEtGZYGe236W082HKvkIl X-Google-Smtp-Source: AGHT+IFVEZotun5fOaPshPsZapNKbSA9Yc/6gFongRoEzccOLA7T8Peo3LhCGKLBm4UKSGlZKh977+yBX7ekhGiS7lM= X-Received: by 2002:a05:6102:fa5:b0:4bb:9b46:3f92 with SMTP id ada2fe7eead31-4c9e4ec68e9mr6506467137.1.1744542922630; Sun, 13 Apr 2025 04:15:22 -0700 (PDT) MIME-Version: 1.0 References: <CANVbq5=7SGJyjjrsSVxJ6WXssua96iYonyY=bsAYk0Q1X_K9tQ@HIDDEN> <861ptwl8dd.fsf@HIDDEN> In-Reply-To: <861ptwl8dd.fsf@HIDDEN> From: Ship Mints <shipmints@HIDDEN> Date: Sun, 13 Apr 2025 07:15:11 -0400 X-Gm-Features: ATxdqUHVbVOk1nyH-vuq8dHJSDfldE5VysqG-uhnPUfkeZmjxpsA2q1xY3p0yXQ Message-ID: <CAN+1HbrHQUGyg0BEMVQpHocCUNqmW=PsVjLe7mTu8haRa7mk7w@HIDDEN> Subject: Re: bug#77684: [PATCH] ; * lisp/emacs-lisp/vtable.el (vtable--limit-string): Use binary search To: Eli Zaretskii <eliz@HIDDEN> Content-Type: multipart/alternative; boundary="00000000000032ec690632a70df7" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77684 Cc: 77684 <at> debbugs.gnu.org, Kristoffer Balintona <krisbalintona@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --00000000000032ec690632a70df7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Apr 13, 2025 at 5:28=E2=80=AFAM Eli Zaretskii <eliz@HIDDEN> wrote: > > From: Kristoffer Balintona <krisbalintona@HIDDEN> > > Date: Wed, 9 Apr 2025 17:13:10 -0700 > > > > Attached is a patch to vtable.el that improves the performance of > > vtable-limit-string. This is because of the expensive calls to > > string-pixel-width. > > > > The current implementation of the function is O(n), whereas the version > > in the attached patch uses a binary search, which has an improved time > > complexity of O(n). > > > > I discovered how expensive vtable-limit-string is when working on a > > personal project of mine that creates vtables with hundreds of rows. > > According to profiler-report, it was by far the largest bottleneck. > > Binary search will only work if adding or removing a character will > always change the result of string-pixel-width. But this is not true > in general, due to character composition and other Emacs display > features. Here's a simple example of such an issue: > > (string-pixel-width "a") > =3D> 9 > (string-pixel-width (concat "a" "=CC=81")) > =3D> 9 > > So adding a character doesn't affect the result of string-pixel-width, > in this case because the two characters will be displayed by a single > glyph that combines the base character 'a' and the acute accent. > > Did you try your modified code in such situations, or did you only try > it with simple characters that never combine? > You can avoid the cost of this string metric by supplying your own global displayer function for the table or a column-specific displayer function. Apropos timing as I've been spending some time with vtable and I have a bunch of bug fixes and a few enhancements coming. One will slow down that function a little more...vtable breaks under remapped fonts; e.g., when using text-scale-adjust so I've fixed that (I have some pixel adjustments left on the header which still gets out of alignment a little). --00000000000032ec690632a70df7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div dir=3D"ltr"><div class=3D"gmail_default" style=3D"fon= t-family:monospace"><span style=3D"font-family:Arial,Helvetica,sans-serif">= On Sun, Apr 13, 2025 at 5:28=E2=80=AFAM Eli Zaretskii <<a href=3D"mailto= :eliz@HIDDEN">eliz@HIDDEN</a>> wrote:</span></div></div><div class=3D"= gmail_quote gmail_quote_container"><blockquote class=3D"gmail_quote" style= =3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding= -left:1ex">> From: Kristoffer Balintona <<a href=3D"mailto:krisbalint= ona@HIDDEN" target=3D"_blank">krisbalintona@HIDDEN</a>><br> > Date: Wed, 9 Apr 2025 17:13:10 -0700<br> > <br> > Attached is a patch to vtable.el that improves the performance of<br> > vtable-limit-string. This is because of the expensive calls to<br> > string-pixel-width.<br> > <br> > The current implementation of the function is O(n), whereas the versio= n<br> > in the attached patch uses a binary search, which has an improved time= <br> > complexity of O(n).<br> > <br> > I discovered how expensive vtable-limit-string is when working on a<br= > > personal project of mine that creates vtables with hundreds of rows.<b= r> > According to profiler-report, it was by far the largest bottleneck.<br= > <br> Binary search will only work if adding or removing a character will<br> always change the result of string-pixel-width.=C2=A0 But this is not true<= br> in general, due to character composition and other Emacs display<br> features.=C2=A0 Here's a simple example of such an issue:<br> <br> =C2=A0 (string-pixel-width "a")<br> =C2=A0 =C2=A0=3D> 9<br> =C2=A0 (string-pixel-width (concat "a" "=CC=81"))<br> =C2=A0 =C2=A0=3D> 9<br> <br> So adding a character doesn't affect the result of string-pixel-width,<= br> in this case because the two characters will be displayed by a single<br> glyph that combines the base character 'a' and the acute accent.<br= > <br> Did you try your modified code in such situations, or did you only try<br> it with simple characters that never combine?<br></blockquote><div><br></di= v><div class=3D"gmail_default" style=3D"font-family:monospace">You can avoi= d the cost of this string metric by supplying your own global displayer fun= ction for the table or a column-specific displayer function.</div><div clas= s=3D"gmail_default" style=3D"font-family:monospace"><br></div><div class=3D= "gmail_default" style=3D"font-family:monospace">Apropos timing as I've = been spending some time with vtable and I have a bunch of bug fixes and a f= ew enhancements coming.=C2=A0 One will slow down that function a little mor= e...vtable breaks under remapped fonts; e.g., when using text-scale-adjust = so I've fixed that (I have some pixel adjustments left on the header wh= ich still gets out of alignment a little).</div></div></div> --00000000000032ec690632a70df7--
bug-gnu-emacs@HIDDEN
:bug#77684
; Package emacs
.
Full text available.Received: (at 77684) by debbugs.gnu.org; 13 Apr 2025 09:27:21 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Apr 13 05:27:21 2025 Received: from localhost ([127.0.0.1]:38943 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1u3tcV-0007rw-Dq for submit <at> debbugs.gnu.org; Sun, 13 Apr 2025 05:27:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51734) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1u3tcG-0007oR-O6 for 77684 <at> debbugs.gnu.org; Sun, 13 Apr 2025 05:27:06 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1u3tcB-0003tL-1i; Sun, 13 Apr 2025 05:26:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=VB/SGZAvpQFQYMM5tfIx5NMWMYa3owI9RFycnUK9RxE=; b=PWw47pcwkuik3BLDOmDl 3l6FrB8PCQhZq6JSIXVUHOQCnewIPrQP082eiLjnLJHuStw1g1VqX0VAf4pOMP94D7SMrhdzyiYC5 RYy/CETPzhdrcuAPF3wLAgSbwJ6xA5xAx6ygUyAjkQPCW4xhsFeOMDK2DZMZDjZja/8KqVKIu6qgI L/YgeSwJYlowbA8VRwIr7s70vogX0sjAoS1VbH1ETz2yDVyYOxGU37HokMk5wY3L+1wM7V+7AnNkX gE1JoSRXums1FlkAJBwGYzll82sP5b5BXzzfsAQ2bMrj3H/uSjL/lfcjsMJvEOGyyXYyP8QW91weK c466CTdxUMGpzg==; Date: Sun, 13 Apr 2025 12:26:54 +0300 Message-Id: <861ptwl8dd.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: Kristoffer Balintona <krisbalintona@HIDDEN> In-Reply-To: <CANVbq5=7SGJyjjrsSVxJ6WXssua96iYonyY=bsAYk0Q1X_K9tQ@HIDDEN> (message from Kristoffer Balintona on Wed, 9 Apr 2025 17:13:10 -0700) Subject: Re: bug#77684: [PATCH] ; * lisp/emacs-lisp/vtable.el (vtable--limit-string): Use binary search References: <CANVbq5=7SGJyjjrsSVxJ6WXssua96iYonyY=bsAYk0Q1X_K9tQ@HIDDEN> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77684 Cc: 77684 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Kristoffer Balintona <krisbalintona@HIDDEN> > Date: Wed, 9 Apr 2025 17:13:10 -0700 > > Attached is a patch to vtable.el that improves the performance of > vtable-limit-string. This is because of the expensive calls to > string-pixel-width. > > The current implementation of the function is O(n), whereas the version > in the attached patch uses a binary search, which has an improved time > complexity of O(n). > > I discovered how expensive vtable-limit-string is when working on a > personal project of mine that creates vtables with hundreds of rows. > According to profiler-report, it was by far the largest bottleneck. Binary search will only work if adding or removing a character will always change the result of string-pixel-width. But this is not true in general, due to character composition and other Emacs display features. Here's a simple example of such an issue: (string-pixel-width "a") => 9 (string-pixel-width (concat "a" "́")) => 9 So adding a character doesn't affect the result of string-pixel-width, in this case because the two characters will be displayed by a single glyph that combines the base character 'a' and the acute accent. Did you try your modified code in such situations, or did you only try it with simple characters that never combine?
bug-gnu-emacs@HIDDEN
:bug#77684
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 10 Apr 2025 00:13:27 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Wed Apr 09 20:13:27 2025 Received: from localhost ([127.0.0.1]:42760 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1u2fXq-0001o6-VE for submit <at> debbugs.gnu.org; Wed, 09 Apr 2025 20:13:27 -0400 Received: from lists.gnu.org ([2001:470:142::17]:36426) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <krisbalintona@HIDDEN>) id 1u2fXn-0001nn-NM for submit <at> debbugs.gnu.org; Wed, 09 Apr 2025 20:13:24 -0400 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 <krisbalintona@HIDDEN>) id 1u2fXh-0005eM-LK for bug-gnu-emacs@HIDDEN; Wed, 09 Apr 2025 20:13:17 -0400 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <krisbalintona@HIDDEN>) id 1u2fXf-0004Gk-Gu for bug-gnu-emacs@HIDDEN; Wed, 09 Apr 2025 20:13:17 -0400 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-5499614d3d2so277278e87.3 for <bug-gnu-emacs@HIDDEN>; Wed, 09 Apr 2025 17:13:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744243992; x=1744848792; darn=gnu.org; h=to:subject:message-id:date:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=5IJfhZrLjjQ2/m7KpOlT6y/uUZT2czLG5wJJ5Gs72EA=; b=LqRxeIJKC++3HhA477Ynga/VT8POzVu/z7oKGlXWDgRT2HRlRv82PKMa+VZFBiBq8v HPyGh1OQF8cQF57ANtk6MtyvB5+4NnqMKWFsCQeBRwJkYzbT/MtH4wXE0NvytRl4e6QQ OYCoog525jiukkDACZ1IkQoaNiYp/CI++PUQs3bTlcD9HrCztTVQIa6NfD0D3Txe471H Gb8n3kNGwecCmFFMLO/JkN2B+JqoKDbVMSel9ytEaZufB3D4H/fCtD7LHgFHWiwooReN AeTd1nftdWWKOz3JQ17Loc5fN+Ly5woCwjZZkwLs5d67v/8VrE5tTt2LrhcvTUObxze7 ySTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744243992; x=1744848792; h=to:subject:message-id:date:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=5IJfhZrLjjQ2/m7KpOlT6y/uUZT2czLG5wJJ5Gs72EA=; b=CJAUrX/UGSaQam2usTPgrGyeXItrOCLhqWgYKYxBuKgVEn6BqjTXu9Od38BqS6HUAi 3iZqSWW5g77E6ch4d1pwL3jC3pFFRH2NHtmbLatFfYrY9uH+b5eyQ8h6LGZMIIdb02NW 1SFQM8ClRe3qfxK9rbQyTdyY6YLtmYzdQXRoLnzUyAY4zEjavKl8CSFk9g6EaB7IynvF IyWJI41G3cJi99UL7HEQUxBx/RXsg580Yc65BroOCBnWRNnHWZxHyk2BxNaQcYNjQwII 3wnC+oEy95gfBvNfCI6u6+BLFQ+7IykgKvbhdKPF22mFlNlq17yVG/v0mC2w9Wuz2XW0 d5Bg== X-Gm-Message-State: AOJu0YzvG55BrXh8ACq8Z5b19KzEYQcNWnjNGigUADr8ChAaS6mFHvC3 Svg6J07Fr/NQ0uT9GMVgzrnQpCi+2h1xj8guNuSO54wP33luDngZ7qJ1jNn1Ja9UwTyEJs/36bN 6uJlqfw8ZIEctN4+asaeKPXA7A+Ud7g== X-Gm-Gg: ASbGncuIhB6u6KkAi70zNMxYv6gqUY/UFkCe/OHSqP5gRbNr2HhBe5yCtvTWRkbutRb 8BQDAuoESlP9A5KweQ/rzDL+Ow0RxUS37pVcPBjyYM3TvEPQI43YWRA+7/091GpA5UgzpYBgTlO re9U+B4OR642t2IcL0ODUlhQ== X-Google-Smtp-Source: AGHT+IGSpLs89BlNPV9Ngl7IbMPnZ4hkV1atPX3gGAONK/zfOz7lhlnFENshUWI3mTtTfZwVOODujlTQ08HNuKG8f6U= X-Received: by 2002:a05:6512:3b8b:b0:54b:117c:118b with SMTP id 2adb3069b0e04-54d3c646691mr54554e87.56.1744243992261; Wed, 09 Apr 2025 17:13:12 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Wed, 9 Apr 2025 17:13:10 -0700 Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Wed, 9 Apr 2025 17:13:10 -0700 From: Kristoffer Balintona <krisbalintona@HIDDEN> MIME-Version: 1.0 Date: Wed, 9 Apr 2025 17:13:10 -0700 X-Gm-Features: ATxdqUH40e5l3gnjl701dLORx0NrDJWbfG3YJf0TQ-9d4ZIQx-CkE5HZ07ZBseA Message-ID: <CANVbq5=7SGJyjjrsSVxJ6WXssua96iYonyY=bsAYk0Q1X_K9tQ@HIDDEN> Subject: [PATCH] ; * lisp/emacs-lisp/vtable.el (vtable--limit-string): Use binary search To: bug-gnu-emacs@HIDDEN Content-Type: multipart/mixed; boundary="0000000000008f99b406326173b5" Received-SPF: pass client-ip=2a00:1450:4864:20::134; envelope-from=krisbalintona@HIDDEN; helo=mail-lf1-x134.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-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.0 (/) --0000000000008f99b406326173b5 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Tags: patch Hello, Attached is a patch to vtable.el that improves the performance of vtable-limit-string. This is because of the expensive calls to string-pixel-width. The current implementation of the function is O(n), whereas the version in the attached patch uses a binary search, which has an improved time complexity of O(n). I discovered how expensive vtable-limit-string is when working on a personal project of mine that creates vtables with hundreds of rows. According to profiler-report, it was by far the largest bottleneck. Below are two basic benchmarks that show the markedly improved performance of the version in the attached patch: (benchmark-run-compiled 10 (let ((buf-name "*temp*")) (get-buffer-create buf-name) ;; The function below is defined by my own project. It creates a vtable ;; in buffer named BUF-NAME (org-roam-folgezettel-list buf-name) (kill-buffer buf-name))) ;; Original (with GC): (16.77486223 17 6.687552347000008) ;; Proposed (with GC): (4.469360591 5 1.919122549000008) (let ((gc-cons-threshold most-positive-fixnum)) (benchmark-run-compiled 10 (let ((buf-name "*temp*")) (get-buffer-create buf-name) ;; The function below is defined by my own project. It creates a vtable ;; in buffer named BUF-NAME (org-roam-folgezettel-list buf-name) (kill-buffer buf-name)))) ;; Original (no GC): (10.767429898 0 0.0) ;; Proposed (no GC): (2.299831031 0 0.0) This is my first patch to Emacs, so please let me know if I=E2=80=99ve miss= ed any conventions for properly contributing. In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.49, cairo version 1.18.4) of 2025-03-31 built on UnoriginalName Windowing system distributor 'Microsoft Corporation', version 11.0.12010000 System Description: Arch Linux Configured using: 'configure 'CFLAGS=3D-O2 -march=3Dnative -mtune=3Dnative -fomit-frame-pointer' --with-mailutils --with-gtk --with-dbus --with-native-compilation' --=20 With appreciation, Kristoffer --0000000000008f99b406326173b5 Content-Type: text/patch; charset="US-ASCII"; name="0001-lisp-emacs-lisp-vtable.el-vtable-limit-string-Use-bi.patch" Content-Disposition: attachment; filename="0001-lisp-emacs-lisp-vtable.el-vtable-limit-string-Use-bi.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: 49a071b019e95f75_0.1 RnJvbSA0MWEyNWYxNGMzMGI2NzI0MTU2YzNhNWFjYzM5N2NhYTZmM2FlYWM1IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBLcmlzdG9mZmVyIEJhbGludG9uYSA8a3Jpc2JhbGludG9uYUBn bWFpbC5jb20+CkRhdGU6IFdlZCwgOSBBcHIgMjAyNSAxODo1MDo0OCAtMDUwMApTdWJqZWN0OiBb UEFUQ0hdIDsgKiBsaXNwL2VtYWNzLWxpc3AvdnRhYmxlLmVsICh2dGFibGUtLWxpbWl0LXN0cmlu Zyk6IFVzZQogYmluYXJ5IHNlYXJjaC4KCi0tLQogbGlzcC9lbWFjcy1saXNwL3Z0YWJsZS5lbCB8 IDE5ICsrKysrKysrKysrKysrKy0tLS0KIDEgZmlsZSBjaGFuZ2VkLCAxNSBpbnNlcnRpb25zKCsp LCA0IGRlbGV0aW9ucygtKQoKZGlmZiAtLWdpdCBhL2xpc3AvZW1hY3MtbGlzcC92dGFibGUuZWwg Yi9saXNwL2VtYWNzLWxpc3AvdnRhYmxlLmVsCmluZGV4IDAwNzg1MTEzZWRiLi4yNjY1Nzc0NDJm OCAxMDA2NDQKLS0tIGEvbGlzcC9lbWFjcy1saXNwL3Z0YWJsZS5lbAorKysgYi9saXNwL2VtYWNz LWxpc3AvdnRhYmxlLmVsCkBAIC04NDAsMTAgKzg0MCwyMSBAQCB2dGFibGUtLXNldC1oZWFkZXIt bGluZQogICAodnRhYmxlLWhlYWRlci1tb2RlIDEpKQogCiAoZGVmdW4gdnRhYmxlLS1saW1pdC1z dHJpbmcgKHN0cmluZyBwaXhlbHMpCi0gICh3aGlsZSAoYW5kIChsZW5ndGg+IHN0cmluZyAwKQot ICAgICAgICAgICAgICAoPiAoc3RyaW5nLXBpeGVsLXdpZHRoIHN0cmluZykgcGl4ZWxzKSkKLSAg ICAoc2V0cSBzdHJpbmcgKHN1YnN0cmluZyBzdHJpbmcgMCAoMS0gKGxlbmd0aCBzdHJpbmcpKSkp KQotICBzdHJpbmcpCisgICJSZXR1cm4gdGhlIGxvbmdlc3QgcHJlZml4IG9mIFNUUklORyB3aG9z ZSBwaXhlbCB3aWR0aCBpcyA8PSBQSVhFTFMuIgorICA7OyBQZXJmb3JtIGEgYmluYXJ5IHNlYXJj aC4gIFRoaXMgaXMgbW9yZSBwZXJmb3JtYW50IHRoYW4gaXRlcmF0aW5nCisgIDs7IHRocm91Z2gg ZWFjaCBjaGFyYWN0ZXIgaW4gc2VxdWVuY2UuCisgIChsZXQgKChsb3cgMCkKKyAgICAgICAgKGhp Z2ggKDEtIChsZW5ndGggc3RyaW5nKSkpCisgICAgICAgIHJlc3VsdCkKKyAgICAod2hpbGUgKDw9 IGxvdyBoaWdoKQorICAgICAgKGxldCogKChtaWQgKGZsb29yICgrIGxvdyBoaWdoKSAyKSkKKyAg ICAgICAgICAgICAoY2FuZGlkYXRlIChzdWJzdHJpbmcgc3RyaW5nIDAgbWlkKSkKKyAgICAgICAg ICAgICAod2lkdGggKHN0cmluZy1waXhlbC13aWR0aCBjYW5kaWRhdGUpKSkKKyAgICAgICAgKGlm ICg8PSB3aWR0aCBwaXhlbHMpCisgICAgICAgICAgICAoc2V0cSByZXN1bHQgY2FuZGlkYXRlCisg ICAgICAgICAgICAgICAgICBsb3cgKDErIG1pZCkpCisgICAgICAgICAgKHNldHEgaGlnaCAoMS0g bWlkKSkpKSkKKyAgICByZXN1bHQpKQogCiAoZGVmdW4gdnRhYmxlLS1jaGFyLXdpZHRoICh0YWJs ZSkKICAgKHN0cmluZy1waXhlbC13aWR0aCAocHJvcGVydGl6ZSAieCIgJ2ZhY2UgKHZ0YWJsZS1m YWNlIHRhYmxlKSkpKQotLSAKMi40OS4wCgo= --0000000000008f99b406326173b5--
Kristoffer Balintona <krisbalintona@HIDDEN>
:bug-gnu-emacs@HIDDEN
.
Full text available.bug-gnu-emacs@HIDDEN
:bug#77684
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.