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

Do less #674

Merged
merged 9 commits into from
Sep 22, 2021
Merged

Do less #674

merged 9 commits into from
Sep 22, 2021

Conversation

simoncozens
Copy link
Collaborator

This skips over steps which are not necessary for font conversion when generating UFO files. See #673

Copy link
Member

@anthrotype anthrotype left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

can you fix the lint failure before merge?

Also can you tell us what the speed savings are for an average font?


If minimal is True, it is assumed that the UFOs will only be used in
font production, and unnecessary steps (e.g. converting background layers)
will be skipped.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe list exactly what is dropped

@simoncozens
Copy link
Collaborator Author

import glyphsLib
from timeit import timeit

def convert_minimal():
    glyphsLib.load_to_ufos("SofiaSans-VF-New.glyphs", minimal=True)

def convert_maximal():
    glyphsLib.load_to_ufos("SofiaSans-VF-New.glyphs", minimal=False)

minimal = timeit(convert_minimal, number=15)
maximal = timeit(convert_maximal, number=15)
print("minimal=True: %f" % minimal)
print("minimal=False: %f" % maximal)
minimal=True: 68.512878
minimal=False: 44.625200

Yes, that's right. Avoiding running unnecessary code takes 54% longer. I don't understand it either.

@simoncozens
Copy link
Collaborator Author

Looks like it's caching/data locality issues with the parser. Here's another test:

import glyphsLib
from timeit import timeit

parsed = glyphsLib.GSFont("SofiaSans-VF-New.glyphs")

def convert_minimal():
    glyphsLib.to_ufos(parsed, minimal=True)

def convert_maximal():
    glyphsLib.to_ufos(parsed, minimal=False)

maximal = timeit(convert_maximal, number=10)
minimal = timeit(convert_minimal, number=10)
print("minimal=True: %f" % minimal)
print("minimal=False: %f" % maximal)

# Try other order, just to make sure.
minimal = timeit(convert_minimal, number=10)
maximal = timeit(convert_maximal, number=10)
print("minimal=True: %f" % minimal)
print("minimal=False: %f" % maximal)
minimal=True: 21.209306
minimal=False: 22.644560
minimal=True: 20.398469
minimal=False: 21.063948

So what - 5% faster generating UFOs?

@simoncozens
Copy link
Collaborator Author

I'd like to get this merged, but it's kind of a breaking change.

For the majority use case (building fonts), it makes things faster and it also avoids certain stupid bugs: I have a build failing because there's a background glyph with a non-existent component - which shouldn't make any difference to the build process, but means that complete UFOs can't be generated, which stops everything dead.

But for the glyphs<->UFO<->glyphs workflow, changing the default to be "minimal=True" might muck things up. So I would like to check with @belluzj and @madig before merging.

(An obvious alternative is that we set default to "minimal=False" and turn on "minimal=True" in build systems. Yeah, that's clearly better...)

@anthrotype
Copy link
Member

turn on "minimal=True" in build systems

I believe that's preferable

@simoncozens simoncozens merged commit 9ec0a30 into googlefonts:main Sep 22, 2021
@simoncozens simoncozens deleted the do-less branch September 22, 2021 11:25
@anthrotype
Copy link
Member

LGTM thanks

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