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 768766 - base-item: Improve and simplify the tracking of the nie:DataSource
base-item: Improve and simplify the tracking of the nie:DataSource
Status: RESOLVED OBSOLETE
Product: gnome-photos
Classification: Applications
Component: general
3.21.x
Other All
: Normal normal
: ---
Assigned To: GNOME photos maintainer(s)
GNOME photos maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2016-07-13 10:32 UTC by Debarshi Ray
Modified: 2018-01-23 10:05 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
base-item: Simplify tracking the nie:DataSource (23.43 KB, patch)
2016-07-13 10:33 UTC, Debarshi Ray
none Details | Review

Description Debarshi Ray 2016-07-13 10:32:08 UTC
We can be a bit clever in the way each BaseItem tracks its Source/nie:DataSource.

Currently we keep a copy of the URN representing the nie:DataSource in Tracker as a string. Usually we will have a large number of BaseItems pointing to a small number of nie:DataSources. The URNs of these nie:DataSources look like:
     - gd:goa-account:account_1442355024_0
     - urn:nepomuk:datasource:d289a99b2854ad9e9d19d497c112f6d9
    
This means that there will be several copies of a handful of strings. Memory is fragmented and wasted.
    
Most of the time we want the online Source of the BaseItem, if any, and not the nie:DataSource's URN. It is unnecessary work to go via the SourceManager to resolve the URN.

(Note that for online BaseItems, the Source:id is the same as the URN of the nie:DataSource, and are prefixed by "gd:goa-account:". This isn't true for local BaseItems because Tracker might have several local nie:DataSources, and the Source:id is "local".)

Therefore, let's just keep a reference to the Source if the URN points to an online nie:DataSource, and a GQuark to track the URN itself. That means we replace a pointer and heap allocated string with two pointers and a 32-bit integer. Some sub-classes were using one of those two pointers anyway for the SourceManager [*]. We can't say how much memory or fragmentation we save without actual measurements, but it isn't any worse and it does simplify the rest of the code. The little extra work while reading the TrackerSparqlCursor data will be masked by the disk I/O and IPC involved.

[*] I think we can avoid keeping a pointer to singletons for every instance by tracking them at the class-level. But, let's not bother about it in this bug.
Comment 1 Debarshi Ray 2016-07-13 10:33:45 UTC
Created attachment 331399 [details] [review]
base-item: Simplify tracking the nie:DataSource
Comment 2 GNOME Infrastructure Team 2018-01-23 10:05:11 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gnome-photos/issues/49.