[Bf-blender-cvs] [a7ef3e1] temp-ghash-basis: Add comment about load factor, 'hide' stats ghash functions behind an ifdef in header.

Bastien Montagne noreply at git.blender.org
Thu Mar 19 15:33:59 CET 2015


Commit: a7ef3e14274857ed33cb3bee7c6d3917f2c719cc
Author: Bastien Montagne
Date:   Thu Mar 19 15:28:42 2015 +0100
Branches: temp-ghash-basis
https://developer.blender.org/rBa7ef3e14274857ed33cb3bee7c6d3917f2c719cc

Add comment about load factor, 'hide' stats ghash functions behind an ifdef in header.

===================================================================

M	source/blender/blenlib/BLI_ghash.h
M	source/blender/blenlib/intern/BLI_ghash.c

===================================================================

diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h
index 0243ed6..89bf5cf 100644
--- a/source/blender/blenlib/BLI_ghash.h
+++ b/source/blender/blenlib/BLI_ghash.h
@@ -255,6 +255,8 @@ BLI_INLINE bool BLI_gsetIterator_done(GSetIterator *gsi) { return BLI_ghashItera
 	     BLI_gsetIterator_done(&gs_iter_) == false;                           \
 	     BLI_gsetIterator_step(&gs_iter_), i_++)
 
+#ifdef GHASH_INTERNAL_API
+
 int BLI_ghash_buckets_size(GHash *gh);
 int BLI_gset_buckets_size(GSet *gs);
 
@@ -267,6 +269,8 @@ double BLI_gset_calc_quality_ex(
 double BLI_ghash_calc_quality(GHash *gh);
 double BLI_gset_calc_quality(GSet *gs);
 
+#endif
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c
index 6a37aa1..be2c296 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -65,6 +65,12 @@ const unsigned int hashsizes[] = {
 #  define GHASH_BUCKET_BIT_MAX 28  /* About 268M of buckets... */
 #endif
 
+/* Note: Max load (GHASH_LIMIT_GROW) used to be 3.
+ *       Python uses 0.6666, tommyhaslib even goes down to 0.5.
+ *       Reducing our from 3 to 0.75 gives huge speedup (about twice quicker pure GHash insertions/lookup,
+ *       about 25% - 30% quicker dyntopo stroke drawing e.g.).
+ *       Min load (GHASH_LIMIT_SHRINK) is a quarter of max load, to avoid resizing to quickly.
+ */
 #define GHASH_LIMIT_GROW(_nbkt) ((_nbkt) * 3) / 4
 #define GHASH_LIMIT_SHRINK(_nbkt) ((_nbkt) * 3) / 16
 
@@ -1271,6 +1277,22 @@ GSet *BLI_gset_pair_new(const char *info)
 
 #include "BLI_math.h"
 
+#ifndef GHASH_INTERNAL_API
+
+int BLI_ghash_buckets_size(GHash *gh);
+int BLI_gset_buckets_size(GSet *gs);
+
+double BLI_ghash_calc_quality_ex(
+        GHash *gh, double *r_load, double *r_variance,
+        double *r_prop_empty_buckets, double *r_prop_overloaded_buckets, int *r_biggest_bucket);
+double BLI_gset_calc_quality_ex(
+        GSet *gs, double *r_load, double *r_variance,
+        double *r_prop_empty_buckets, double *r_prop_overloaded_buckets, int *r_biggest_bucket);
+double BLI_ghash_calc_quality(GHash *gh);
+double BLI_gset_calc_quality(GSet *gs);
+
+#endif
+
 /**
  * \return number of buckets in the GHash.
  */




More information about the Bf-blender-cvs mailing list