From 9d9c5f728fc131aff8b450da6bce4a0d4414b8ff Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sat, 10 Feb 2007 12:20:09 +0100 Subject: [PATCH] Minor improvements of debug messages. --- lib/sorter/govern.c | 17 ++++++++++------- lib/sorter/sbuck.c | 6 ++++-- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/sorter/govern.c b/lib/sorter/govern.c index 297692c5..b6dea908 100644 --- a/lib/sorter/govern.c +++ b/lib/sorter/govern.c @@ -102,7 +102,7 @@ sorter_twoway(struct sort_context *ctx, struct sort_bucket *b) if (!(sorter_debug & SORT_DEBUG_NO_PRESORT) || (b->flags & SBF_CUSTOM_PRESORT)) { - SORT_XTRACE(2, "%s", ((b->flags & SBF_CUSTOM_PRESORT) ? "Custom presorting" : "Presorting")); + SORT_XTRACE(3, "%s", ((b->flags & SBF_CUSTOM_PRESORT) ? "Custom presorting" : "Presorting")); sorter_start_timer(ctx); ins[0] = sbuck_new(ctx); if (!sorter_presort(ctx, b, ins[0], join ? : ins[0])) @@ -132,7 +132,7 @@ sorter_twoway(struct sort_context *ctx, struct sort_bucket *b) ins[0] = b; } - SORT_XTRACE(2, "Main sorting"); + SORT_XTRACE(3, "Main sorting"); uns pass = 0; do { ++pass; @@ -140,12 +140,14 @@ sorter_twoway(struct sort_context *ctx, struct sort_bucket *b) if (ins[0]->runs == 1 && ins[1]->runs == 1 && join) { // This is guaranteed to produce a single run, so join if possible + sh_off_t join_size = sbuck_size(join); outs[0] = join; outs[1] = NULL; ctx->twoway_merge(ctx, ins, outs); - ASSERT(outs[0]->runs == 2); - outs[0]->runs--; - SORT_TRACE("Mergesort pass %d (final run, %s, %dMB/s)", pass, F_BSIZE(outs[0]), sorter_speed(ctx, sbuck_size(outs[0]))); + ASSERT(join->runs == 2); + join->runs--; + join_size = sbuck_size(join) - join_size; + SORT_TRACE("Mergesort pass %d (final run, %s, %dMB/s)", pass, F_SIZE(join_size), sorter_speed(ctx, join_size)); sbuck_drop(ins[0]); sbuck_drop(ins[1]); return; @@ -223,10 +225,10 @@ sorter_run(struct sort_context *ctx) else bin->fb = ctx->in_fb; bin->ident = "in"; - bin->size = ctx->in_size; /* Sizes should be either sh_off_t or u64, not both; beware of ~0U */ + bin->size = ctx->in_size; /* FIXME: Sizes should be either sh_off_t or u64, not both; beware of ~0U */ bin->hash_bits = ctx->hash_bits; clist_add_tail(&ctx->bucket_list, &bin->n); - SORT_XTRACE(2, "Input size: %s", (ctx->in_size == ~(u64)0 ? (byte*)"unknown" : F_BSIZE(bin))); + SORT_XTRACE(2, "Input size: %s", F_BSIZE(bin)); // Create bucket for the output struct sort_bucket *bout = sbuck_new(ctx); @@ -240,6 +242,7 @@ sorter_run(struct sort_context *ctx) struct sort_bucket *b; while (bout = clist_head(&ctx->bucket_list), b = clist_next(&ctx->bucket_list, &bout->n)) { + SORT_XTRACE(2, "Next block: %s, %d hash bits", F_BSIZE(b), b->hash_bits); if (!sbuck_have(b)) sbuck_drop(b); else if (b->runs == 1) diff --git a/lib/sorter/sbuck.c b/lib/sorter/sbuck.c index 53dfed31..287827ee 100644 --- a/lib/sorter/sbuck.c +++ b/lib/sorter/sbuck.c @@ -144,7 +144,7 @@ sorter_alloc_buf(struct sort_context *ctx) ctx->big_buf_size = 2*bs; ctx->big_buf_half = ((byte*) ctx->big_buf) + bs; ctx->big_buf_half_size = bs; - SORT_XTRACE(2, "Allocated sorting buffer (%jd bytes)", (uintmax_t) bs); + SORT_XTRACE(2, "Allocated sorting buffer (2*%jd bytes)", (uintmax_t) bs); } void @@ -170,6 +170,8 @@ format_size(byte *buf, u64 x) sprintf(buf, "%dM", (int)(x/(1<<20))); else if (x < (u64)10<<30) sprintf(buf, "%.1fG", (double)x/(1<<30)); - else + else if (x != ~(u64)0) sprintf(buf, "%dG", (int)(x/(1<<30))); + else + strcpy(buf, "unknown"); } -- 2.39.2