]> mj.ucw.cz Git - libucw.git/commitdiff
Another minor optimization: Added AddRadixBits.
authorMartin Mares <mj@ucw.cz>
Tue, 11 Sep 2007 12:49:31 +0000 (14:49 +0200)
committerMartin Mares <mj@ucw.cz>
Tue, 11 Sep 2007 12:49:31 +0000 (14:49 +0200)
lib/sorter/common.h
lib/sorter/config.c
lib/sorter/govern.c

index 50cbf34b789bf0b72475d50a61b20274de45d7fe..a97b4dd2feab25a992ea147a5d806b1067a81958 100644 (file)
@@ -14,7 +14,7 @@
 
 /* Configuration, some of the variables are used by the old sorter, too. */
 extern uns sorter_trace, sorter_stream_bufsize;
-extern uns sorter_debug, sorter_min_radix_bits, sorter_max_radix_bits;
+extern uns sorter_debug, sorter_min_radix_bits, sorter_max_radix_bits, sorter_add_radix_bits;
 extern uns sorter_min_multiway_bits, sorter_max_multiway_bits;
 extern uns sorter_threads, sorter_thread_threshold, sorter_thread_chunk;
 extern uns sorter_radix_threshold;
index cc4bb3e66afb1ccd6f37974929179ad47dabb638..d12a65bd8c81cd56ee6aeedac75a35f16c68d14c 100644 (file)
@@ -18,6 +18,7 @@ u64 sorter_bufsize = 65536;
 uns sorter_debug;
 uns sorter_min_radix_bits;
 uns sorter_max_radix_bits;
+uns sorter_add_radix_bits;
 uns sorter_min_multiway_bits;
 uns sorter_max_multiway_bits;
 uns sorter_threads;
@@ -35,6 +36,7 @@ static struct cf_section sorter_config = {
     CF_UNS("Debug", &sorter_debug),
     CF_UNS("MinRadixBits", &sorter_min_radix_bits),
     CF_UNS("MaxRadixBits", &sorter_max_radix_bits),
+    CF_UNS("AddRadixBits", &sorter_add_radix_bits),
     CF_UNS("MinMultiwayBits", &sorter_min_multiway_bits),
     CF_UNS("MaxMultiwayBits", &sorter_max_multiway_bits),
     CF_UNS("Threads", &sorter_threads),
index 826417d1f6e3207c91eda5cc2a53efbb76390190..619b351d4690db9d4d4ad124d1c1afc7c8f81943 100644 (file)
@@ -283,6 +283,9 @@ sorter_multiway(struct sort_context *ctx, struct sort_bucket *b)
 static void
 sorter_radix(struct sort_context *ctx, struct sort_bucket *b, uns bits)
 {
+  // Add more bits if requested and allowed.
+  bits = MIN(bits + sorter_add_radix_bits, sorter_max_radix_bits);
+
   uns nbuck = 1 << bits;
   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));