[tracker/wip/carlosg/update-perf: 45/65] core: Replace hashtable with list
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/update-perf: 45/65] core: Replace hashtable with list
- Date: Tue, 23 Aug 2022 09:32:53 +0000 (UTC)
commit c49483f0dba1e078f2c490a2ab6e7786cb664bc5
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Aug 18 16:21:09 2022 +0200
core: Replace hashtable with list
When preparing update statements, we can possibly end up with multiple
coalesced single-valued property updates for the same property. In that
case we attempt to just push the last update as it is the one that will
prevail.
But the amount of properties to be grouped for a same graph/resource/class
tuple is not usually high enough. As this is a very hot path during
updates, using a hashtable to track and avoid repeatedly updating the
same property has an intrinsic cost that timidly shows up in profiles.
As the amount of elements to iterate is not too high, this can be replaced
with a GList which esentially drops these lookups from showing in profiles.
src/libtracker-sparql/core/tracker-data-update.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
---
diff --git a/src/libtracker-sparql/core/tracker-data-update.c
b/src/libtracker-sparql/core/tracker-data-update.c
index 1c90115c6..5419f52e9 100644
--- a/src/libtracker-sparql/core/tracker-data-update.c
+++ b/src/libtracker-sparql/core/tracker-data-update.c
@@ -1140,14 +1140,12 @@ tracker_data_flush_log (TrackerData *data,
entry->table.multivalued.change_idx);
statement_bind_gvalue (stmt, 1, &property_entry->value);
} else {
- GHashTable *visited_properties;
+ GList *visited_properties = NULL;
gint param, property_idx;
tracker_db_statement_bind_int (stmt, 0, entry->id);
param = 1;
- visited_properties = g_hash_table_new (NULL, NULL);
-
property_idx = entry->table.class.last_property_idx;
while (property_idx >= 0) {
@@ -1158,7 +1156,7 @@ tracker_data_flush_log (TrackerData *data,
property_idx);
property_idx = property_entry->prev;
- if (g_hash_table_contains (visited_properties, property_entry->property))
+ if (g_list_find (visited_properties, property_entry->property))
continue;
if (G_VALUE_TYPE (&property_entry->value) == G_TYPE_INVALID) {
@@ -1168,10 +1166,10 @@ tracker_data_flush_log (TrackerData *data,
statement_bind_gvalue (stmt, param++, &property_entry->value);
}
- g_hash_table_add (visited_properties, property_entry->property);
+ visited_properties = g_list_prepend (visited_properties,
property_entry->property);
}
- g_hash_table_unref (visited_properties);
+ g_list_free (visited_properties);
}
tracker_db_statement_execute (stmt, &inner_error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]