After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 342333 - reduce size of RhythmDBEntry
reduce size of RhythmDBEntry
Status: RESOLVED OBSOLETE
Product: rhythmbox
Classification: Other
Component: general
HEAD
Other Linux
: Normal normal
: ---
Assigned To: RhythmBox Maintainers
RhythmBox Maintainers
Depends on:
Blocks:
 
 
Reported: 2006-05-19 10:33 UTC by Jonathan Matthew
Modified: 2010-05-22 11:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (4.13 KB, patch)
2006-05-19 10:36 UTC, Jonathan Matthew
committed Details | Review

Description Jonathan Matthew 2006-05-19 10:33:33 UTC
Currently we store a pointer to a GDate in RhythmDBEntry, only allocating a GDate for entries that actually have date information.  We could store the GDate itself in the db entry, as the structure contents are public, saving one malloc per entry with a date, wasting the difference between the size of the date structure and the size of a pointer for each entry without.

sizeof(GDate) is 8 bytes on a 32bit machine.  The proportion of entries with date data doesn't have to be all that high for 8 bytes per entry to be less than 4 bytes per entry + (8 bytes + malloc overhead) per entry with a date.  I'm not sure how this adds up on 64bit machines, though.
Comment 1 Jonathan Matthew 2006-05-19 10:36:15 UTC
Created attachment 65815 [details] [review]
patch

also changes the query preprocess function to use a GDate on the stack, but that doesn't really achieve anything.
Comment 2 James "Doc" Livingston 2006-05-19 11:15:16 UTC
(In reply to comment #0)
> Currently we store a pointer to a GDate in RhythmDBEntry, only allocating a
> GDate for entries that actually have date information.  We could store the
> GDate itself in the db entry, as the structure contents are public, saving one
> malloc per entry with a date, wasting the difference between the size of the
> date structure and the size of a pointer for each entry without.

Removing this kind of thing is probably very beneficial, since I've seen massif reporting that 10-20% of RB's heap is taken up with heap-management overhead. Reducing the number of objects pointlessly allocated in the heap would be good. The patch looks sane to me.


> sizeof(GDate) is 8 bytes on a 32bit machine.  The proportion of entries with
> date data doesn't have to be all that high for 8 bytes per entry to be less
> than 4 bytes per entry + (8 bytes + malloc overhead) per entry with a date. 
> I'm not sure how this adds up on 64bit machines, though.

The glib docs state that GDate uses a bitfield because it should be able to be packed into an int on 64 bit machines. So assuming that pointers are also 64 bits, it would be break-even if nothing has dates, and gain for anything else.



On a related note (which should probably be a separate bug), there are several easy things we could do to shrink the side of RhythmDBEntry:

1) make the replaygain values be float instead of double, the extra precision is fairly pointless here.
2) rating doesn't need to be a double either. If we really wanted, we could even use a unsigned char and scale the values into 0-255.
3) use a bitfield instead of gbooleans
4) reorder the fields to get better packing
Comment 3 Jonathan Matthew 2006-05-20 02:03:34 UTC
I've committed the patch.  We might as well leave this bug open for the other entry size reduction ideas.
Comment 4 René Stadler 2006-09-24 06:36:23 UTC
Looks like entries are allocated with plain g_malloc.  Isn't this a perfect job for the slice allocator?

About shrinking replaygain values: The gains even fit into 14 bits since the analysis precision is just 0.01 dB, range -55.18...+64.82 dB.  Should do absolutely no harm to store the peaks in just 16 bits also (or even 15).
Comment 5 Jonathan Matthew 2010-05-22 11:55:14 UTC
Not much point keeping this open.