Re: speeding up auto-hinter start-up
Behdad Esfahbod <[email protected]> Sun, 15 Jun 2025 12:05:43 -0600
| Newsgroups | gmane.comp.fonts.freetype.devel |
|---|---|
| Message-ID | <CAF63+7UqZbyG-3jMBi4Xz__szNmQC5DA-6Pr0AWu68T6t3EsaA@mail.gmail.com> |
--0000000000004eb1dd0637a02262
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
So, this will be the prototype:
HB_EXTERN hb_map_t *
hb_ot_layout_lookup_get_glyphs_alternates (hb_face_t *face,
unsigned lookup_index);
behdad
http://behdad.org/
On Sun, Jun 15, 2025 at 11:40=E2=80=AFAM Behdad Esfahbod <[email protected]=
> wrote:
> Hi Werner,
>
> I have an idea. Similar in essence to `af_map_lookup`, just using another
> style to avoid extra allocations.
>
> Basically, to get gid's variants, you will check `gid + (i << 24)` for i
> being 0, 1, 2, ... until you hit a miss.
>
> This allows for just one hash table to be returned. Allows for 24bit
> gid's. Its only limitation is 8bit of alternates, but if you see gid has
> alternate at index 255, you can use to the slower API to get all the
> remaining alternates.
>
> Does that sound good to you? I can go ahead and prototype it.
> behdad
> http://behdad.org/
>
>
> On Sun, Jun 15, 2025 at 1:00=E2=80=AFAM Werner LEMBERG <[email protected]> wrote=
:
>
>>
>> I've just submitted a Merge Request to speed up the auto-hinter
>> start-up. The previous code using HarfBuzz functions was far too slow
>> to be acceptable =E2=80=93 HarfBuzz (currently) doesn't exactly provide =
what
>> we need, causing way to much overhead.
>>
>> To speed things up it was necessary to (partially) parse, validate and
>> access the GSUB table. I really tried to avoid that, but...
>>
>> Please have a look! The speed-up is really impressive, I think; the
>> old code slowed down the start-up time by more than 300% (in
>> comparison to a commit before introducing vertical accent
>> positioning), while the new code only adds about 25%.
>>
>> https://gitlab.freedesktop.org/freetype/freetype/-/merge_requests/381
>>
>> Ideally, I would like to get rid of the GSUB code since it doesn't fit
>> conceptually into FreeType (and HarfBuzz does it anyway). Behdad, do
>> you have ideas whether something similar to `af_map_lookup` could be
>> added to HarfBuzz? This would be a long-term solution, since even if
>> HarfBuzz gets fitting functionality I don't want to make FreeType
>> depend on the newest HarfBuzz version...
>>
>>
>> Werner
>>
>
--0000000000004eb1dd0637a02262
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>So, this will be the prototype:</div><div><br></div><=
div><font face=3D"monospace">HB_EXTERN hb_map_t * <br>hb_ot_layout_lookup_g=
et_glyphs_alternates (hb_face_t *face, <br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0unsigned =C2=A0 lookup_inde=
x);</font></div><div>=C2=A0</div><div><div dir=3D"ltr" class=3D"gmail_signa=
ture" data-smartmail=3D"gmail_signature">behdad<br><a href=3D"http://behdad=
.org/" target=3D"_blank">http://behdad.org/</a></div></div><br></div><br><d=
iv class=3D"gmail_quote gmail_quote_container"><div dir=3D"ltr" class=3D"gm=
ail_attr">On Sun, Jun 15, 2025 at 11:40=E2=80=AFAM Behdad Esfahbod <<a h=
ref=3D"mailto:[email protected]">[email protected]</a>> wrote:<br></div>=
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div>Hi =
Werner,</div><div><br></div><div>I have an idea. Similar in essence to `af_=
map_lookup`, just using another style to avoid extra allocations.</div><div=
><br></div><div>Basically, to get gid's variants, you will check `gid=
=C2=A0+ (i << 24)` for i being 0, 1, 2, ... until you hit a miss.</di=
v><div><br></div><div>This allows for just one hash table to be returned. A=
llows for 24bit gid's. Its only limitation is 8bit of alternates, but i=
f you see gid=C2=A0has alternate at index 255, you can use to the slower AP=
I to get all the remaining alternates.</div><div><br></div><div>Does that s=
ound good to you? I can go ahead and prototype it.</div><div><div dir=3D"lt=
r" class=3D"gmail_signature">behdad<br><a href=3D"http://behdad.org/" targe=
t=3D"_blank">http://behdad.org/</a></div></div><br></div><br><div class=3D"=
gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Sun, Jun 15, 2025 at =
1:00=E2=80=AFAM Werner LEMBERG <<a href=3D"mailto:[email protected]" target=3D"=
_blank">[email protected]</a>> wrote:<br></div><blockquote class=3D"gmail_quote=
" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);=
padding-left:1ex"><br>
I've just submitted a Merge Request to speed up the auto-hinter<br>
start-up.=C2=A0 The previous code using HarfBuzz functions was far too slow=
<br>
to be acceptable =E2=80=93 HarfBuzz (currently) doesn't exactly provide=
what<br>
we need, causing way to much overhead.<br>
<br>
To speed things up it was necessary to (partially) parse, validate and<br>
access the GSUB table.=C2=A0 I really tried to avoid that, but...<br>
<br>
Please have a look!=C2=A0 The speed-up is really impressive, I think; the<b=
r>
old code slowed down the start-up time by more than 300% (in<br>
comparison to a commit before introducing vertical accent<br>
positioning), while the new code only adds about 25%.<br>
<br>
=C2=A0 <a href=3D"https://gitlab.freedesktop.org/freetype/freetype/-/merge_=
requests/381" rel=3D"noreferrer" target=3D"_blank">https://gitlab.freedeskt=
op.org/freetype/freetype/-/merge_requests/381</a><br>
<br>
Ideally, I would like to get rid of the GSUB code since it doesn't fit<=
br>
conceptually into FreeType (and HarfBuzz does it anyway).=C2=A0 Behdad, do<=
br>
you have ideas whether something similar to `af_map_lookup` could be<br>
added to HarfBuzz?=C2=A0 This would be a long-term solution, since even if<=
br>
HarfBuzz gets fitting functionality I don't want to make FreeType<br>
depend on the newest HarfBuzz version...<br>
<br>
<br>
=C2=A0 =C2=A0 Werner<br>
</blockquote></div>
</blockquote></div>
--0000000000004eb1dd0637a02262--