X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fsorter%2Fgovern.c;h=5ce884732a4209a44c962890c0df3de90d594804;hb=a5ff98a53789157a6c96e58b2385bb898d688a22;hp=13fc7a61404f801d5125f081423960cb9de0bebc;hpb=cd5c8bf5fbdb894ec44c130488c5e74eaef440a9;p=libucw.git diff --git a/lib/sorter/govern.c b/lib/sorter/govern.c index 13fc7a61..5ce88473 100644 --- a/lib/sorter/govern.c +++ b/lib/sorter/govern.c @@ -48,6 +48,11 @@ sorter_presort(struct sort_context *ctx, struct sort_bucket *in, struct sort_buc sorter_alloc_buf(ctx); if (in->flags & SBF_CUSTOM_PRESORT) { + /* + * The trick with automatic joining, which we use for the normal presorter, + * is not necessary with the custom presorter, because the custom presorter + * is never called in the middle of the sorted data. + */ struct fastbuf *f = sbuck_write(out); out->runs++; return ctx->custom_presort(f, ctx->big_buf, ctx->big_buf_size); @@ -278,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)); @@ -405,6 +413,7 @@ sorter_run(struct sort_context *ctx) bin->hash_bits = ctx->hash_bits; clist_add_tail(&ctx->bucket_list, &bin->n); SORT_XTRACE(2, "Input size: %s, %d hash bits", F_BSIZE(bin), bin->hash_bits); + ctx->fb_params = (bin->size < sorter_small_input) ? &sorter_small_fb_params : &sorter_fb_params; // Create bucket for the output struct sort_bucket *bout = sbuck_new(ctx);