Selaa lähdekoodia

hashindex: explain hash_sizes

Thomas Waldmann 9 vuotta sitten
vanhempi
sitoutus
5cb47cbedd
1 muutettua tiedostoa jossa 9 lisäystä ja 1 poistoa
  1. 9 1
      borg/_hashindex.c

+ 9 - 1
borg/_hashindex.c

@@ -40,7 +40,15 @@ typedef struct {
     int upper_limit;
 } HashIndex;
 
-/* prime (or w/ big prime factors) hash table sizes - otherwise performance breaks down! */
+/* prime (or w/ big prime factors) hash table sizes
+ * not sure we need primes for borg's usage (as we have a hash function based
+ * on sha256, we can assume an even, seemingly random distribution of values),
+ * but OTOH primes don't harm.
+ * also, growth of the sizes starts with fast-growing 2x steps, but slows down
+ * more and more down to 1.1x. this is to avoid huge jumps in memory allocation,
+ * like e.g. 4G -> 8G.
+ * these values are generated by hash_sizes.py.
+ */
 static int hash_sizes[] = {
     1031, 2053, 4099, 8209, 16411, 32771, 65537, 131101, 262147, 445649,
     757607, 1287917, 2189459, 3065243, 4291319, 6007867, 8410991,