mopidy/mopidy — pull request #261 by jodal (2012-11-23 20:01:12+00:00)
Title: spotify: Reuse artist, album, and track models

This adds a module-level cache of artist, album, and track models, whose
content is almost entirely static. This cache is used when we convert from
pyspotify to Mopidy objects.

Previously, an album with 15 tracks would create 15 track objects, 15 artists
objects on the tracks, 15 album objects on the tracks, and 15 artist objects on
the 15 album objects, in total 60 objects. With this change, we only create 15
track objects, 1 album object, and 1 artist object, in total 17 objects.

Measurements with 90 playlists containing about 6500 tracks in total shows that
this reduces the number of Artist objects from 13600 to 3800, and the number of
Album objects from 6500 to 4500 objects.

An unscientific measurement of memory usage using ps(1) indicated a reduction
in RSS from 71MB to 65MB, measured right after the Spotify playlists was loaded
the first time.