googlefonts / googlefonts/fontmake

Some profiling findings

Open
#611 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
888
Forks
97
Avg merge
4d 52m
Merged PRs (30d)
1

Description

I found https://github.com/nvdv/vprof and ran it on two scripts.

Script 1 with booleanOperations (Cantarell from https://gitlab.gnome.org/GNOME/cantarell-fonts/tree/b3a2f068612933765af7696f46c3c2d544d5d3f9/src):

```Python
import ufoLib2
import ufo2ft

u = ufoLib2.Font.open("Cantarell-Regular.ufo")
f = ufo2ft.compileOTF(u, inplace=True, removeOverlaps=True)
f.save("a.otf")
```

Script 2 with skia-pathops:
```Python
import ufoLib2
import ufo2ft

u = ufoLib2.Font.open("Cantarell-Regular.ufo")
f = ufo2ft.compileOTF(u, inplace=True, removeOverlaps=True, overlapsBackend="pathops")
f.save("a.otf")
```

1. On my Fedora 31 x64 with Python 3.7.5, Ryzen 1700, pathops speeds up the runtime from 10s (bOps) to ~7.6s (pathops).
2. booleanOperations spends A LOT of time in `convertPointsToSegment`
![Bildschirmfoto vom 2019-12-05 19-39-21](https://user-images.githubusercontent.com/380829/70269630-ab9fcb00-179a-11ea-8597-a11666a6d834.png)
3. pathops presents a more even flame graph:
![grafik](https://user-images.githubusercontent.com/380829/70269720-d5f18880-179a-11ea-91ec-2bd3ef4b467b.png)
4. Memory usage: a lot of `Point`s. Quite a few `Glyph`s and `Anchor`s:
![Bildschirmfoto vom 2019-12-05 19-43-52](https://user-images.githubusercontent.com/380829/70269747-e4d83b00-179a-11ea-8f19-d839164d9c7d.png)
5. In the code heatmap, `logging` and `re` saw a lot of action for some reason:
![Bildschirmfoto vom 2019-12-05 20-12-02](https://user-images.githubusercontent.com/380829/70270116-97100280-179b-11ea-9a09-f49f25371921.png)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the two profiling runs through ufo2ft.compileOTF with removeOverlaps enabled, comparing the default booleanOperations backend with overlapsBackend="pathops". Review the reported time in booleanOperations.convertPointsToSegment and the observed Point, Glyph, Anchor, logging, and re activity; the issue does not define a specific optimization or acceptance criterion, so scope must be clarified before implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
performance
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.