]> mj.ucw.cz Git - libucw.git/commitdiff
Fix bucket estimator.
authorMartin Mares <mj@ucw.cz>
Sat, 10 Feb 2007 19:45:59 +0000 (20:45 +0100)
committerMartin Mares <mj@ucw.cz>
Sat, 10 Feb 2007 19:45:59 +0000 (20:45 +0100)
lib/sorter/govern.c

index c1ef332ca4d8c210cf2c598e4156b004ca31199a..8380f926572a21f1fc3cf5eb25d186d925569a08 100644 (file)
@@ -178,13 +178,12 @@ sorter_radix_bits(struct sort_context *ctx, struct sort_bucket *b)
 
   u64 in = sbuck_size(b);
   u64 mem = ctx->internal_estimate(ctx, b);
-  if (in < mem)
+  if (in <= mem)
     return 0;
 
-  uns n;
-  for (n = sorter_min_radix_bits; n < sorter_max_radix_bits && n < b->hash_bits; n++)
-    if ((in >> n) < mem)
-      break;
+  uns n = sorter_min_radix_bits;
+  while (n < sorter_max_radix_bits && n < b->hash_bits && (in >> n) > mem)
+    n++;
   return n;
 }
 
@@ -192,7 +191,7 @@ static void
 sorter_radix(struct sort_context *ctx, struct sort_bucket *b, uns bits)
 {
   uns nbuck = 1 << bits;
-  SORT_XTRACE(2, "Running radix sort on %s with %d bits of %d (expected size %s)",
+  SORT_XTRACE(2, "Running radix split on %s with hash %d bits of %d (expecting %s buckets)",
              F_BSIZE(b), bits, b->hash_bits, stk_fsize(sbuck_size(b) / nbuck));
   sorter_start_timer(ctx);