defcon icon indicating copy to clipboard operation
defcon copied to clipboard

Optimize

Open typesupply opened this issue 8 years ago • 15 comments

This is a general issue for ideas on optimizing the overall speed of the objects.

typesupply avatar Jul 28 '16 11:07 typesupply

FWIW defcon master if almost as fast as robofab. It's the ufo3 branch of defcon that is twice slower.

behdad avatar Aug 02 '16 01:08 behdad

Can we merge ufo3 branch first, then start optimization work?

behdad avatar Aug 02 '16 01:08 behdad

Yeah, let's do the switch. This has made me nervous for years, but I guess it is time. I'll try to start the process right now.

typesupply avatar Aug 02 '16 16:08 typesupply

Done. Yikes, I hope I did that correctly. I'll delete the ufo3 branch in a few days after I feel a little more confident that I didn't break everything.

What can I do to facilitate some optimization experimentation? Would a "optimize" branch be useful?

cc @adrientetar @typemytype @anthrotype @moyogo @jamesgk

typesupply avatar Aug 02 '16 17:08 typesupply

For me I just need to know which branch to spend my time on :). A local benchmark, as well as a strong test suite help. Not much else needed really. Thanks!

behdad avatar Aug 02 '16 17:08 behdad

Cool! The same merge could be done for extractor and fontMath, I think.

adrientetar avatar Aug 02 '16 17:08 adrientetar

Cool! The same merge could be done for extractor and fontMath, I think.

Yeah. There are a lot of others. Let me make sure my strategy worked and then I'll merge those. I started this ufo3 branch five years ago and I've been dreading this moment since then. I am literally shaking. There were so many changes.

typesupply avatar Aug 02 '16 17:08 typesupply

Awesome!

anthrotype avatar Aug 02 '16 17:08 anthrotype

https://travis-ci.org/typesupply/defcon and https://ci.appveyor.com/project/typesupply/defcon look good.

moyogo avatar Aug 02 '16 17:08 moyogo

It all will be okay! Let's not go for a 5-year UFO-4 then. Gradual improvements FTW...

behdad avatar Aug 02 '16 17:08 behdad

+1 for also merging fontMath/ufo3 branch.

It's the last of fontmake's requirements in a branch different from master.

anthrotype avatar Aug 03 '16 16:08 anthrotype

+1 for also merging fontMath/ufo3 branch.

Done.

typesupply avatar Aug 05 '16 17:08 typesupply

Thanks! 👍

anthrotype avatar Aug 05 '16 17:08 anthrotype

All of my repositories should be switched to ufo3 now.

typesupply avatar Aug 05 '16 17:08 typesupply

Uh... we got a little off track here!

Back on the topic of optimization, I noticed a pretty deep nesting of notification-related calls when I ctrl-C'd fontmake today:

Traceback (most recent call last):
  File "/usr/local/bin/fontmake", line 9, in <module>
    load_entry_point('fontmake', 'console_scripts', 'fontmake')()
  File "/home/jamesgk/code/fontmake/Lib/fontmake/__main__.py", line 89, in main
    project.run_from_glyphs(glyphs_path, **args)
  File "/home/jamesgk/code/fontmake/Lib/fontmake/font_project.py", line 275, in run_from_glyphs
    glyphs_file, interpolate, masters_as_instances, family_name)
  File "/home/jamesgk/code/fonttools/Lib/fontTools/misc/loggingTools.py", line 372, in wrapper
    return func(*args, **kwds)
  File "/home/jamesgk/code/fontmake/Lib/fontmake/font_project.py", line 92, in build_ufos
    glyphs_path, master_dir, instance_dir, family_name=family_name))
  File "/home/jamesgk/code/glyphsLib/Lib/glyphsLib/__init__.py", line 100, in build_instances
    filename, include_instances=True, family_name=family_name)
  File "/home/jamesgk/code/glyphsLib/Lib/glyphsLib/__init__.py", line 63, in load_to_ufos
    family_name=family_name, debug=debug)
  File "/home/jamesgk/code/glyphsLib/Lib/glyphsLib/builder.py", line 142, in to_ufos
    load_glyph(glyph, layer, glyph_data)
  File "/home/jamesgk/code/glyphsLib/Lib/glyphsLib/builder.py", line 610, in load_glyph
    draw_paths(pen, layer.get('paths', []))
  File "/home/jamesgk/code/glyphsLib/Lib/glyphsLib/builder.py", line 628, in draw_paths
    pen.endPath()
  File "/home/jamesgk/code/defcon/Lib/defcon/pens/glyphObjectPointPen.py", line 21, in endPath
    self._glyph.appendContour(self._contour)
  File "/home/jamesgk/code/defcon/Lib/defcon/objects/glyph.py", line 548, in appendContour
    self.insertContour(len(self), contour)
  File "/home/jamesgk/code/defcon/Lib/defcon/objects/glyph.py", line 575, in insertContour
    self.postNotification(notification="Glyph.ContoursChanged")
  File "/home/jamesgk/code/defcon/Lib/defcon/objects/base.py", line 222, in postNotification
    dispatcher.postNotification(notification=notification, observable=self, data=data)
  File "/home/jamesgk/code/defcon/Lib/defcon/tools/notifications.py", line 198, in postNotification
    callback(notificationObj)
  File "/home/jamesgk/code/defcon/Lib/defcon/objects/component.py", line 386, in baseGlyphDataChangedNotificationCallback
    self.postNotification("Component.BaseGlyphDataChanged")
  File "/home/jamesgk/code/defcon/Lib/defcon/objects/base.py", line 222, in postNotification
    dispatcher.postNotification(notification=notification, observable=self, data=data)
  File "/home/jamesgk/code/defcon/Lib/defcon/tools/notifications.py", line 198, in postNotification
    callback(notificationObj)
  File "/home/jamesgk/code/defcon/Lib/defcon/objects/glyph.py", line 1235, in _componentBaseGlyphDataChanged
    self.postNotification(notification="Glyph.ComponentsChanged")
  File "/home/jamesgk/code/defcon/Lib/defcon/objects/base.py", line 222, in postNotification
    dispatcher.postNotification(notification=notification, observable=self, data=data)
  File "/home/jamesgk/code/defcon/Lib/defcon/tools/notifications.py", line 198, in postNotification
    callback(notificationObj)
  File "/home/jamesgk/code/defcon/Lib/defcon/objects/component.py", line 386, in baseGlyphDataChangedNotificationCallback
    self.postNotification("Component.BaseGlyphDataChanged")
  File "/home/jamesgk/code/defcon/Lib/defcon/objects/base.py", line 222, in postNotification
    dispatcher.postNotification(notification=notification, observable=self, data=data)
  File "/home/jamesgk/code/defcon/Lib/defcon/tools/notifications.py", line 198, in postNotification
    callback(notificationObj)
  File "/home/jamesgk/code/defcon/Lib/defcon/objects/glyph.py", line 1236, in _componentBaseGlyphDataChanged
    self.postNotification(notification=self.changeNotificationName)
  File "/home/jamesgk/code/defcon/Lib/defcon/objects/base.py", line 222, in postNotification
    dispatcher.postNotification(notification=notification, observable=self, data=data)
  File "/home/jamesgk/code/defcon/Lib/defcon/tools/notifications.py", line 198, in postNotification
    callback(notificationObj)
  File "/home/jamesgk/code/defcon/Lib/defcon/objects/layer.py", line 738, in _glyphDirtyStateChange
    self.dirty = True
  File "/home/jamesgk/code/defcon/Lib/defcon/objects/base.py", line 413, in _set_dirty
    self.postNotification(self.changeNotificationName)
  File "/home/jamesgk/code/defcon/Lib/defcon/objects/base.py", line 222, in postNotification
    dispatcher.postNotification(notification=notification, observable=self, data=data)
  File "/home/jamesgk/code/defcon/Lib/defcon/tools/notifications.py", line 198, in postNotification
    callback(notificationObj)
  File "/home/jamesgk/code/defcon/Lib/defcon/objects/layerSet.py", line 352, in _layerDirtyStateChange
    self.dirty = True
  File "/home/jamesgk/code/defcon/Lib/defcon/objects/base.py", line 413, in _set_dirty
    self.postNotification(self.changeNotificationName)
  File "/home/jamesgk/code/defcon/Lib/defcon/objects/base.py", line 222, in postNotification
    dispatcher.postNotification(notification=notification, observable=self, data=data)
  File "/home/jamesgk/code/defcon/Lib/defcon/tools/notifications.py", line 154, in postNotification
    if key not in self._registry:
KeyboardInterrupt

Over half of the stack trace is devoted wholly to notifications! Just thought this was interesting and wanted to leave it here for reference.

jamesgk avatar Aug 15 '16 23:08 jamesgk