diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2022-01-23 13:54:18 +0100 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2022-05-07 12:56:10 +0200 |
commit | 9c6ce63819f782c9883b901adbbaebcd161aef55 (patch) | |
tree | 540e012a5c9f842d02341acf49c8d3b2e13aad86 /src/libtracker-sparql/tracker-notifier.c | |
parent | e70d93540b491d294fc2238c7195ba6e2dfe08a2 (diff) | |
download | tracker-9c6ce63819f782c9883b901adbbaebcd161aef55.tar.gz |
libtracker-sparql: Avoid URN queries in DBus endpoint notifications
When a connection is proxied through a TrackerEndpointDBus, there are
possibly 2 levels of TrackerNotifiers, one being used in the service
itself to trigger the DBus signal, and another on any listening client
handling those notifications.
However, both of these are doing an additional query to fetch the URN
for each of the notified elements. Since we only pass ROWIDs in the
DBus signal to make the signal data as compact as possible, we can
avoid this query on the service side. Any client listening to
notifications will perform its own URN queries anyway.
So avoid this piece of pointless busywork in the service side, and
special case that the internal notifiers used by endpoints should not
perform the query for URN data.
This does not make anything noticeably faster (perhaps endpoint signal
emission is a bit more snappy now, if anything) as all querying and
cursor handling happens lazily in a separate thread fairly detached
from the rest of the machinery. However it's still less CPU cycles
used overall.
Diffstat (limited to 'src/libtracker-sparql/tracker-notifier.c')
-rw-r--r-- | src/libtracker-sparql/tracker-notifier.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/libtracker-sparql/tracker-notifier.c b/src/libtracker-sparql/tracker-notifier.c index 01081a75b..86329ce9d 100644 --- a/src/libtracker-sparql/tracker-notifier.c +++ b/src/libtracker-sparql/tracker-notifier.c @@ -74,7 +74,8 @@ struct _TrackerNotifierPrivate { TrackerSparqlStatement *local_statement; GAsyncQueue *queue; gint n_local_statement_slots; - gboolean querying; + guint querying : 1; + guint urn_query_disabled : 1; GMutex mutex; }; @@ -633,7 +634,9 @@ _tracker_notifier_event_cache_flush_events (TrackerNotifierEventCache *cache) cache->first = g_sequence_get_begin_iter (cache->sequence); g_async_queue_lock (priv->queue); - if (priv->querying) { + if (priv->urn_query_disabled) { + tracker_notifier_emit_events_in_idle (cache); + } else if (priv->querying) { g_async_queue_push_unlocked (priv->queue, cache); } else { priv->querying = TRUE; @@ -946,3 +949,12 @@ tracker_notifier_event_get_urn (TrackerNotifierEvent *event) g_return_val_if_fail (event != NULL, NULL); return event->urn; } + +void +tracker_notifier_disable_urn_query (TrackerNotifier *notifier) +{ + TrackerNotifierPrivate *priv; + + priv = tracker_notifier_get_instance_private (notifier); + priv->urn_query_disabled = TRUE; +} |