Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feaLib] SingleSub compilation not always optimal #3259

Open
cmyr opened this issue Aug 18, 2023 · 3 comments
Open

[feaLib] SingleSub compilation not always optimal #3259

cmyr opened this issue Aug 18, 2023 · 3 comments
Assignees

Comments

@cmyr
Copy link
Contributor

cmyr commented Aug 18, 2023

This is a slightly vague issue title because I do not know the full extent of the problem, but I do have one specific example, which is demonstrated by the spec5f_ii_4.fea test case in feaLib.

This case involves some inline substitution rules. feaLib combines all of these rules into one SingleSub format 2 subtable, but it is more efficient to put most of the rules in a format 1 subtable; this optimization would would reduce the generated binary from 106 bytes to 52.

I don't have strong feelings about whether or not this is worth fixing; I'm just trying to debug a few of the remaining places where fea-rs and feaLib are generating different ttx, and this is one of those.

@anthrotype
Copy link
Member

anthrotype commented Aug 20, 2023

@cmyr can you share the code in fea-rs which applies this optimization? Maybe we port this over to otlLib

@anthrotype
Copy link
Member

@cmyr
Copy link
Contributor Author

cmyr commented Aug 20, 2023

Yep, that's it. At a high level:

  • we collect all rules into a map of target: (replacement, delta)
  • we then sort them into two groups, based on whether they are eligible for format 1 or not
  • we then go through all the candidate format 1 groups and see if the savings justify the cost, moving items to format 2 where it is beneficial.

There are some possible improvements to this, but I believe any remaining gains are going to be very marginal.

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

No branches or pull requests

3 participants