pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/devel/glib2 Revert GHashTable improvements



details:   https://anonhg.NetBSD.org/pkgsrc/rev/50f57a60a209
branches:  trunk
changeset: 397387:50f57a60a209
user:      prlw1 <prlw1%pkgsrc.org@localhost>
date:      Fri Jun 21 20:20:59 2019 +0000

description:
Revert GHashTable improvements
https://gitlab.gnome.org/GNOME/glib/merge_requests/208

to fix PR pkg/54310

For the record, the patch was created with:
git checkout -f 2.60.4
git revert --no-edit 86c6f7e2b..3bed8a13b
git revert --no-edit 75f8ec1df9b48b0c3a13a9125f2c7d7c5adf5159
git revert --no-edit 603fb5958..d3074a748
git revert --no-edit 0b45ddc55..0600dd322
git diff 2.60.4

diffstat:

 devel/glib2/Makefile                               |    4 +-
 devel/glib2/distinfo                               |    5 +-
 devel/glib2/patches/patch-gio_tests_gdbus-export.c |   70 +
 devel/glib2/patches/patch-glib_ghash.c             |  873 +++++++++++++++++++++
 devel/glib2/patches/patch-glib_tests_hash.c        |   60 +
 5 files changed, 1009 insertions(+), 3 deletions(-)

diffs (truncated from 1050 to 300 lines):

diff -r 7ee4c99c36ee -r 50f57a60a209 devel/glib2/Makefile
--- a/devel/glib2/Makefile      Fri Jun 21 17:10:43 2019 +0000
+++ b/devel/glib2/Makefile      Fri Jun 21 20:20:59 2019 +0000
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.253 2019/06/16 15:28:11 leot Exp $
+# $NetBSD: Makefile,v 1.254 2019/06/21 20:20:59 prlw1 Exp $
 
 .include "Makefile.common"
 
-PKGREVISION=   1
+PKGREVISION=   2
 CATEGORIES=    devel gnome
 COMMENT=       Some useful routines for C programming (glib2)
 
diff -r 7ee4c99c36ee -r 50f57a60a209 devel/glib2/distinfo
--- a/devel/glib2/distinfo      Fri Jun 21 17:10:43 2019 +0000
+++ b/devel/glib2/distinfo      Fri Jun 21 20:20:59 2019 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.247 2019/06/18 13:05:14 jperkin Exp $
+$NetBSD: distinfo,v 1.248 2019/06/21 20:20:59 prlw1 Exp $
 
 SHA1 (glib-2.60.4.tar.xz) = f76ef7339fef5784d79520478110caa4c5054806
 RMD160 (glib-2.60.4.tar.xz) = e8520dd0da7c37e6bb18b24a3b3ec308a6fa6aa0
@@ -12,8 +12,11 @@
 SHA1 (patch-gio_gunixmounts.c) = 13af07fffe898457edd0d8db4296a60fccba913d
 SHA1 (patch-gio_inotify_inotify-kernel.c) = 24deec33a1ad5e3c1a4f2d1397440d26b0f23b84
 SHA1 (patch-gio_meson.build) = a0dcda4e9d05ed83b7fb11102945821eea27b81d
+SHA1 (patch-gio_tests_gdbus-export.c) = 59d85ca079d02b52e33153c7d2ac1cc48c26707a
+SHA1 (patch-glib_ghash.c) = 938135c3a71199e61d1cd1dffa6e1d63864150d6
 SHA1 (patch-glib_gmain.c) = 2ab4b59e438d9f764bee62e0c1fa8bbd231b6e8d
 SHA1 (patch-glib_meson.build) = 119e48efd8aaabf06b62c6e1897261b470cf7355
+SHA1 (patch-glib_tests_hash.c) = e928b22926ad917a7a201882a5105b25533554ae
 SHA1 (patch-gmodule_gmodule-ar.c) = e382a0ada232e083d51cbede7f689a50ebeff4d8
 SHA1 (patch-gmodule_gmodule-dl.c) = b678a04debbc79ebb67d91db7716990658e76da4
 SHA1 (patch-gmodule_gmodule-dyld.c) = 5adf62970d9cff22d451307aaa0b00d975dab138
diff -r 7ee4c99c36ee -r 50f57a60a209 devel/glib2/patches/patch-gio_tests_gdbus-export.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/glib2/patches/patch-gio_tests_gdbus-export.c        Fri Jun 21 20:20:59 2019 +0000
@@ -0,0 +1,70 @@
+$NetBSD: patch-gio_tests_gdbus-export.c,v 1.1 2019/06/21 20:21:00 prlw1 Exp $
+
+Revert GHashTable improvements
+https://gitlab.gnome.org/GNOME/glib/merge_requests/208
+
+to fix PR pkg/54310
+
+--- gio/tests/gdbus-export.c.orig      2019-06-10 17:47:20.000000000 +0000
++++ gio/tests/gdbus-export.c
+@@ -337,22 +337,6 @@ introspect_callback (GDBusProxy   *proxy
+   g_main_loop_quit (loop);
+ }
+ 
+-static gint
+-compare_strings (gconstpointer a,
+-                 gconstpointer b)
+-{
+-  const gchar *sa = *(const gchar **) a;
+-  const gchar *sb = *(const gchar **) b;
+-
+-  /* Array terminator must sort last */
+-  if (sa == NULL)
+-    return 1;
+-  if (sb == NULL)
+-    return -1;
+-
+-  return strcmp (sa, sb);
+-}
+-
+ static gchar **
+ get_nodes_at (GDBusConnection  *c,
+               const gchar      *object_path)
+@@ -406,9 +390,6 @@ get_nodes_at (GDBusConnection  *c,
+   g_free (xml_data);
+   g_dbus_node_info_unref (node_info);
+ 
+-  /* Nodes are semantically unordered; sort array so tests can rely on order */
+-  g_ptr_array_sort (p, compare_strings);
+-
+   return (gchar **) g_ptr_array_free (p, FALSE);
+ }
+ 
+@@ -1259,9 +1240,9 @@ test_object_registration (void)
+   nodes = get_nodes_at (c, "/foo/dyna");
+   g_assert (nodes != NULL);
+   g_assert_cmpint (g_strv_length (nodes), ==, 3);
+-  g_assert_cmpstr (nodes[0], ==, "cat");
+-  g_assert_cmpstr (nodes[1], ==, "cheezburger");
+-  g_assert_cmpstr (nodes[2], ==, "lol");
++  g_assert_cmpstr (nodes[0], ==, "lol");
++  g_assert_cmpstr (nodes[1], ==, "cat");
++  g_assert_cmpstr (nodes[2], ==, "cheezburger");
+   g_strfreev (nodes);
+   g_assert_cmpint (count_interfaces (c, "/foo/dyna/lol"), ==, 4);
+   g_assert_cmpint (count_interfaces (c, "/foo/dyna/cat"), ==, 4);
+@@ -1272,10 +1253,10 @@ test_object_registration (void)
+   nodes = get_nodes_at (c, "/foo/dyna");
+   g_assert (nodes != NULL);
+   g_assert_cmpint (g_strv_length (nodes), ==, 4);
+-  g_assert_cmpstr (nodes[0], ==, "cat");
+-  g_assert_cmpstr (nodes[1], ==, "cheezburger");
+-  g_assert_cmpstr (nodes[2], ==, "dynamicallycreated");
+-  g_assert_cmpstr (nodes[3], ==, "lol");
++  g_assert_cmpstr (nodes[0], ==, "lol");
++  g_assert_cmpstr (nodes[1], ==, "cat");
++  g_assert_cmpstr (nodes[2], ==, "cheezburger");
++  g_assert_cmpstr (nodes[3], ==, "dynamicallycreated");
+   g_strfreev (nodes);
+   g_assert_cmpint (count_interfaces (c, "/foo/dyna/dynamicallycreated"), ==, 4);
+ 
diff -r 7ee4c99c36ee -r 50f57a60a209 devel/glib2/patches/patch-glib_ghash.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/glib2/patches/patch-glib_ghash.c    Fri Jun 21 20:20:59 2019 +0000
@@ -0,0 +1,873 @@
+$NetBSD: patch-glib_ghash.c,v 1.1 2019/06/21 20:21:00 prlw1 Exp $
+
+Revert GHashTable improvements
+https://gitlab.gnome.org/GNOME/glib/merge_requests/208
+
+to fix PR pkg/54310
+
+--- glib/ghash.c.orig  2019-06-10 17:47:20.000000000 +0000
++++ glib/ghash.c
+@@ -38,26 +38,6 @@
+ #include "gtestutils.h"
+ #include "gslice.h"
+ #include "grefcount.h"
+-#include "gvalgrind.h"
+-
+-/* The following #pragma is here so we can do this...
+- *
+- *   #ifndef USE_SMALL_ARRAYS
+- *     is_big = TRUE;
+- *   #endif
+- *     return is_big ? *(((gpointer *) a) + index) : GUINT_TO_POINTER (*(((guint *) a) + index));
+- *
+- * ...instead of this...
+- *
+- *   #ifndef USE_SMALL_ARRAYS
+- *     return *(((gpointer *) a) + index);
+- *   #else
+- *     return is_big ? *(((gpointer *) a) + index) : GUINT_TO_POINTER (*(((guint *) a) + index));
+- *   #endif
+- *
+- * ...and still compile successfully when -Werror=duplicated-branches is passed. */
+-
+-#pragma GCC diagnostic ignored "-Wduplicated-branches"
+ 
+ /**
+  * SECTION:hash_tables
+@@ -233,18 +213,6 @@
+ #define HASH_IS_TOMBSTONE(h_) ((h_) == TOMBSTONE_HASH_VALUE)
+ #define HASH_IS_REAL(h_) ((h_) >= 2)
+ 
+-/* If int is smaller than void * on our arch, we start out with
+- * int-sized keys and values and resize to pointer-sized entries as
+- * needed. This saves a good amount of memory when the HT is being
+- * used with e.g. GUINT_TO_POINTER(). */
+-
+-#define BIG_ENTRY_SIZE (SIZEOF_VOID_P)
+-#define SMALL_ENTRY_SIZE (SIZEOF_INT)
+-
+-#if SMALL_ENTRY_SIZE < BIG_ENTRY_SIZE
+-# define USE_SMALL_ARRAYS
+-#endif
+-
+ struct _GHashTable
+ {
+   gint             size;
+@@ -253,12 +221,9 @@ struct _GHashTable
+   gint             nnodes;
+   gint             noccupied;  /* nnodes + tombstones */
+ 
+-  guint            have_big_keys : 1;
+-  guint            have_big_values : 1;
+-
+-  gpointer         keys;
++  gpointer        *keys;
+   guint           *hashes;
+-  gpointer         values;
++  gpointer        *values;
+ 
+   GHashFunc        hash_func;
+   GEqualFunc       key_equal_func;
+@@ -332,15 +297,19 @@ static const gint prime_mod [] =
+ static void
+ g_hash_table_set_shift (GHashTable *hash_table, gint shift)
+ {
++  gint i;
++  guint mask = 0;
++
+   hash_table->size = 1 << shift;
+   hash_table->mod  = prime_mod [shift];
+ 
+-  /* hash_table->size is always a power of two, so we can calculate the mask
+-   * by simply subtracting 1 from it. The leading assertion ensures that
+-   * we're really dealing with a power of two. */
++  for (i = 0; i < shift; i++)
++    {
++      mask <<= 1;
++      mask |= 1;
++    }
+ 
+-  g_assert ((hash_table->size & (hash_table->size - 1)) == 0);
+-  hash_table->mask = hash_table->size - 1;
++  hash_table->mask = mask;
+ }
+ 
+ static gint
+@@ -365,67 +334,6 @@ g_hash_table_set_shift_from_size (GHashT
+   g_hash_table_set_shift (hash_table, shift);
+ }
+ 
+-static inline gpointer
+-g_hash_table_realloc_key_or_value_array (gpointer a, guint size, G_GNUC_UNUSED gboolean is_big)
+-{
+-#ifdef USE_SMALL_ARRAYS
+-  return g_realloc (a, size * (is_big ? BIG_ENTRY_SIZE : SMALL_ENTRY_SIZE));
+-#else
+-  return g_renew (gpointer, a, size);
+-#endif
+-}
+-
+-static inline gpointer
+-g_hash_table_fetch_key_or_value (gpointer a, guint index, gboolean is_big)
+-{
+-#ifndef USE_SMALL_ARRAYS
+-  is_big = TRUE;
+-#endif
+-  return is_big ? *(((gpointer *) a) + index) : GUINT_TO_POINTER (*(((guint *) a) + index));
+-}
+-
+-static inline void
+-g_hash_table_assign_key_or_value (gpointer a, guint index, gboolean is_big, gpointer v)
+-{
+-#ifndef USE_SMALL_ARRAYS
+-  is_big = TRUE;
+-#endif
+-  if (is_big)
+-    *(((gpointer *) a) + index) = v;
+-  else
+-    *(((guint *) a) + index) = GPOINTER_TO_UINT (v);
+-}
+-
+-static inline gpointer
+-g_hash_table_evict_key_or_value (gpointer a, guint index, gboolean is_big, gpointer v)
+-{
+-#ifndef USE_SMALL_ARRAYS
+-  is_big = TRUE;
+-#endif
+-  if (is_big)
+-    {
+-      gpointer r = *(((gpointer *) a) + index);
+-      *(((gpointer *) a) + index) = v;
+-      return r;
+-    }
+-  else
+-    {
+-      gpointer r = GUINT_TO_POINTER (*(((guint *) a) + index));
+-      *(((guint *) a) + index) = GPOINTER_TO_UINT (v);
+-      return r;
+-    }
+-}
+-
+-static inline guint
+-g_hash_table_hash_to_index (GHashTable *hash_table, guint hash)
+-{
+-  /* Multiply the hash by a small prime before applying the modulo. This
+-   * prevents the table from becoming densely packed, even with a poor hash
+-   * function. A densely packed table would have poor performance on
+-   * workloads with many failed lookups or a high degree of churn. */
+-  return (hash * 11) % hash_table->mod;
+-}
+-
+ /*
+  * g_hash_table_lookup_node:
+  * @hash_table: our #GHashTable
+@@ -474,7 +382,7 @@ g_hash_table_lookup_node (GHashTable    
+ 
+   *hash_return = hash_value;
+ 
+-  node_index = g_hash_table_hash_to_index (hash_table, hash_value);
++  node_index = hash_value % hash_table->mod;
+   node_hash = hash_table->hashes[node_index];
+ 
+   while (!HASH_IS_UNUSED (node_hash))
+@@ -485,7 +393,7 @@ g_hash_table_lookup_node (GHashTable    
+        */
+       if (node_hash == hash_value)
+         {
+-          gpointer node_key = g_hash_table_fetch_key_or_value (hash_table->keys, node_index, hash_table->have_big_keys);
++          gpointer node_key = hash_table->keys[node_index];
+ 
+           if (hash_table->key_equal_func)
+             {
+@@ -535,15 +443,15 @@ g_hash_table_remove_node (GHashTable   *
+   gpointer key;
+   gpointer value;
+ 
+-  key = g_hash_table_fetch_key_or_value (hash_table->keys, i, hash_table->have_big_keys);
+-  value = g_hash_table_fetch_key_or_value (hash_table->values, i, hash_table->have_big_values);



Home | Main Index | Thread Index | Old Index