summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2022-01-23 13:54:18 +0100
committerCarlos Garnacho <carlosg@gnome.org>2022-05-07 12:56:10 +0200
commit9c6ce63819f782c9883b901adbbaebcd161aef55 (patch)
tree540e012a5c9f842d02341acf49c8d3b2e13aad86
parente70d93540b491d294fc2238c7195ba6e2dfe08a2 (diff)
downloadtracker-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.
-rw-r--r--src/libtracker-sparql/tracker-endpoint-dbus.c2
-rw-r--r--src/libtracker-sparql/tracker-notifier-private.h2
-rw-r--r--src/libtracker-sparql/tracker-notifier.c16
3 files changed, 18 insertions, 2 deletions
diff --git a/src/libtracker-sparql/tracker-endpoint-dbus.c b/src/libtracker-sparql/tracker-endpoint-dbus.c
index fa840e0e3..c6735603d 100644
--- a/src/libtracker-sparql/tracker-endpoint-dbus.c
+++ b/src/libtracker-sparql/tracker-endpoint-dbus.c
@@ -43,6 +43,7 @@
#include "tracker-endpoint-dbus.h"
#include "tracker-notifier.h"
+#include "tracker-notifier-private.h"
#include "tracker-private.h"
#include <gio/gio.h>
@@ -1008,6 +1009,7 @@ tracker_endpoint_dbus_initable_init (GInitable *initable,
conn = tracker_endpoint_get_sparql_connection (endpoint);
endpoint_dbus->notifier = tracker_sparql_connection_create_notifier (conn);
+ tracker_notifier_disable_urn_query (endpoint_dbus->notifier);
g_signal_connect (endpoint_dbus->notifier, "events",
G_CALLBACK (notifier_events_cb), endpoint);
diff --git a/src/libtracker-sparql/tracker-notifier-private.h b/src/libtracker-sparql/tracker-notifier-private.h
index aabe9f1bc..e808be1e2 100644
--- a/src/libtracker-sparql/tracker-notifier-private.h
+++ b/src/libtracker-sparql/tracker-notifier-private.h
@@ -39,4 +39,6 @@ _tracker_notifier_event_cache_push_event (TrackerNotifierEventCache *cache,
void _tracker_notifier_event_cache_flush_events (TrackerNotifierEventCache *cache);
+void tracker_notifier_disable_urn_query (TrackerNotifier *notifier);
+
#endif /* __TRACKER_NOTIFIER_PRIVATE_H__ */
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;
+}