Commit: 7cb90a611faa506d7576f1f27f42be6936a45f5e
Author: Campbell Barton
Date: Fri Apr 4 21:20:17 2014 +1100
https://developer.blender.org/rB7cb90a611faa506d7576f1f27f42be6936a45f5e
Optimization for mempool initial chunk allocation
Almost all pools allocated 2 chunks on initialization,
every element needed to be added to the free-list which
would never be used for small pools.
Now allocate only one, gives minor speedup for some bmesh operations.
===================================================================
M source/blender/blenlib/intern/BLI_mempool.c
===================================================================
diff --git a/source/blender/blenlib/intern/BLI_mempool.c
b/source/blender/blenlib/intern/BLI_mempool.c
index 7dc43bb..a37a778 100644
--- a/source/blender/blenlib/intern/BLI_mempool.c
+++ b/source/blender/blenlib/intern/BLI_mempool.c
@@ -121,10 +121,14 @@ struct BLI_mempool {
/**
* \return the number of chunks to allocate based on how many elements are
needed.
+ *
+ * \note for small pools 1 is a good default, the elements need to be
initialized,
+ * adding overhead on creation which is redundant if they aren't used.
+ *
*/
BLI_INLINE unsigned int mempool_maxchunks(const unsigned int totelem, const
unsigned int pchunk)
{
- return totelem / pchunk + 1;
+ return (totelem <= pchunk) ? 1 : ((totelem / pchunk) + 1);
}
static BLI_mempool_chunk *mempool_chunk_alloc(BLI_mempool *pool)
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs