Skip to content

sugar3.graphics.icon has a tiny LRU cache for SVGs and surfaces #374

@quozl

Description

@quozl

Icon class has a very small LRU cache for SVGs and surfaces.

SVGs are not being cached; the cache attribute is not set by the callers.

Up to 50 surfaces are cached.

Initial demand is about 10 surfaces for the toolbar standard UI items. Each additional UI object with an SVG brings the activity closer to the limit. Once the limit is reached, the LRU cache can lose critical surfaces, and several user actions cause re-read and reprocessing of SVGs, resulting in slow response in the user interface. Effectively trading memory usage for CPU usage.

Icon class is used by many other classes.

  • double the cache sizes and test on oldest used hardware, aaea860,
  • set up an intentionally limited virtual machine, or old hardware,
  • make performance measurements with varying cache sizes,
  • recommend a changed cache size,
  • recommend a changed cache algorithm (e.g. use reference counters).

Discovered while experimenting with the Icon class for the Chat activity smiley window. When more than 50 instances of Icon were created, hiding and showing the window took ten seconds, and scrolling took five seconds. Gtk.Image was used instead, see sugarlabs/chat@0f09a26.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions