Skip to content

[read-fonts] Inline AAT lookup format dispatch - #2109

Open
behdad wants to merge 1 commit into
mainfrom
perf/inline-aat-lookup-read
Open

[read-fonts] Inline AAT lookup format dispatch#2109
behdad wants to merge 1 commit into
mainfrom
perf/inline-aat-lookup-read

Conversation

@behdad

@behdad behdad commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Motivation

HarfRust repeatedly reconstructs AAT class-lookup views while applying
morx subtables. The generated Lookup::read_with_args format switch is
small, but without an inline hint it remains opaque across the
read-fonts crate boundary.

Add an opt-in #[read_inline] codegen annotation and use it only for the
AAT Lookup format group. I tested adding the hint to every format group,
but that caused a measurable regression in an OpenType workload, so this
keeps the change narrowly scoped.

Performance

With release LTO builds of HarfRust and benchmark-harf:

Workload Before After
GeezaPro / fa-words.txt 11.2 ms 10.7 ms
LucidaGrande / en-thelittleprince.txt 4.58 ms 4.51 ms
Menlo / en-thelittleprince.txt 3.35 ms 3.32 ms

On Devanagari Sangam / hi-words.txt, fixed-iteration hardware counters
dropped from 891,866,354 to 879,745,089 instructions. Cycles are sensitive
to final code layout but were about 1–3% lower in repeated runs.

Testing

cargo test --workspace

Allow format-group inputs to request an inline FontRead dispatcher, and
use it for AAT Lookup. This exposes the small format switch across the
read-fonts crate boundary without affecting OpenType format groups.

Assisted-by: OpenAI Codex <codex@openai.com>
@behdad
behdad force-pushed the perf/inline-aat-lookup-read branch from 8061d37 to 0f545d7 Compare September 6, 2026 21:57
@dfrg

dfrg commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Interesting that adding inline on all format groups causes a regression. I can only guess that LTO is choosing not to inline coverage and classdef reads as I believe those are the only ones we touch on the OT hot path. Was the regression on Amiri?

@behdad

behdad commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Interesting that adding inline on all format groups causes a regression. I can only guess that LTO is choosing not to inline coverage and classdef reads as I believe those are the only ones we touch on the OT hot path. Was the regression on Amiri?

Yeah as I pushed agents to close more gaps between HB & HR, code gen & inlining decisions showed more and more. I'm open to either option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants