Mesa (master): util/set: Fix the _mesa_set_clear function to not leave tombstones.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Nov 10 22:40:06 UTC 2020


Module: Mesa
Branch: master
Commit: 2afdd94f86149295f3e9422672c4501092f671d6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2afdd94f86149295f3e9422672c4501092f671d6

Author: Eric Anholt <eric at anholt.net>
Date:   Tue Oct 20 14:37:10 2020 -0700

util/set: Fix the _mesa_set_clear function to not leave tombstones.

This implementation was broken and should have just been the same as the
hash_table_clear() one, which I copied over here.  It was setting all
formerly-present entries to deleted, yet also setting deleted_entries to
0.  This meant that all new searches or additions after clearing would
have to reprobe the whole table until a rehash happened, and that rehash
would be delayed because we violated the deleted_entries invariant.

No statistically significant performance difference on softpipe
KHR-GL33.texture_swizzle.functional runtime (n=18)

Fixes: 5c075b085585 ("util/set: add a set_clear function")
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7244>

---

 src/util/set.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/util/set.c b/src/util/set.c
index 006d5d2a502..f10694537c1 100644
--- a/src/util/set.c
+++ b/src/util/set.c
@@ -223,13 +223,17 @@ _mesa_set_clear(struct set *set, void (*delete_function)(struct set_entry *entry
    if (!set)
       return;
 
-   set_foreach (set, entry) {
-      if (delete_function)
+   struct set_entry *entry;
+
+   for (entry = set->table; entry != set->table + set->size; entry++) {
+      if (entry_is_present(entry) && delete_function != NULL)
          delete_function(entry);
-      entry->key = deleted_key;
+
+      entry->key = NULL;
    }
 
-   set->entries = set->deleted_entries = 0;
+   set->entries = 0;
+   set->deleted_entries = 0;
 }
 
 /**



More information about the mesa-commit mailing list