summaryrefslogtreecommitdiff
path: root/hv.h
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2014-03-01 17:31:53 +0100
committerYves Orton <demerphq@gmail.com>2014-03-18 08:37:04 +0100
commit32dfa2a7022d23efefa78556ec78725b0d2d4373 (patch)
treeb9feb23236ba6cd041619b749db09d6fa8f3463c /hv.h
parentbea177f3c4412e3250a860c64abed7595ae6373a (diff)
downloadperl-32dfa2a7022d23efefa78556ec78725b0d2d4373.tar.gz
Preallocate HvAUX() structures for large bucket arrays
The assumption is that the time/space tradeoff of not allocating the HvAUX() structure goes away for a large bucket array where the size of the allocated buffer is much larger than the nonallocated HvAUX() "extension". This should make keys() and each() on larger hashes faster, but still preserve the essence of the original space conservation, where the assumption is a lot of small hash based objects which will never be traversed.
Diffstat (limited to 'hv.h')
-rw-r--r--hv.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/hv.h b/hv.h
index 5b52f98460..8ff1d140f3 100644
--- a/hv.h
+++ b/hv.h
@@ -238,6 +238,16 @@ C<SV*>.
*/
#define PERL_HASH_DEFAULT_HvMAX 7
+/* HvMAX(hv)+1 is >= to this we preallocate the HvAUX() struct during hsplit()
+ * The assumption being that we are using so much space anyway we might
+ * as well allocate the extra bytes and speed up later keys()
+ * or each() operations. We don't do this to small hashes as we assume
+ * that a) it will be easy/fast to resize them to add the iterator, and b) that
+ * many of them will be objects which won't be traversed. Larger hashes however
+ * will take longer to extend, and the size of the aux struct is swamped by the
+ * overall length of the bucket array.
+ * */
+#define PERL_HV_ALLOC_AUX_SIZE (1 << 9)
/* these hash entry flags ride on hent_klen (for use only in magic/tied HVs) */
#define HEf_SVKEY -2 /* hent_key is an SV* */