X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=inline;f=lib%2Fsorter%2Fsbuck.c;h=e506e3189161d905ca4a1408df789f799b4c86bc;hb=54833f693e97cc4c3d5b8c28e6816e8d1ce5192e;hp=515115e282533e9ed00454b23e771ae13c76a4e9;hpb=ae3892dc4f3c3a759315969e2ab5156f034707b2;p=libucw.git diff --git a/lib/sorter/sbuck.c b/lib/sorter/sbuck.c index 515115e2..e506e318 100644 --- a/lib/sorter/sbuck.c +++ b/lib/sorter/sbuck.c @@ -69,10 +69,7 @@ sbuck_swap_in(struct sort_bucket *b) { if (b->flags & SBF_SWAPPED_OUT) { - if (sorter_stream_bufsize) /* FIXME: Needs better configuration, probably semi-automatic one */ - b->fb = bopen(b->filename, O_RDWR, sorter_stream_bufsize); - else - b->fb = fbdir_open(b->filename, O_RDWR, NULL); + b->fb = bopen_file(b->filename, O_RDWR, &sorter_fb_params); /* FIXME: Something different for small buckets? */ if (b->flags & SBF_OPEN_WRITE) bseek(b->fb, 0, SEEK_END); bconfig(b->fb, BCONFIG_IS_TEMP_FILE, 1); @@ -107,10 +104,7 @@ sbuck_write(struct sort_bucket *b) else { ASSERT(!(b->flags & (SBF_OPEN_READ | SBF_DESTROYED))); - if (sorter_stream_bufsize) - b->fb = bopen_tmp(sorter_stream_bufsize); - else - b->fb = fbdir_open_tmp(NULL); + b->fb = bopen_tmp_file(&sorter_fb_params); if (sorter_debug & SORT_DEBUG_KEEP_BUCKETS) bconfig(b->fb, BCONFIG_IS_TEMP_FILE, 0); b->flags |= SBF_OPEN_WRITE; @@ -137,10 +131,10 @@ sbuck_swap_out(struct sort_bucket *b) void sorter_prepare_buf(struct sort_context *ctx) { - u64 bs = MAX(sorter_bufsize/2, 1); + u64 bs = sorter_bufsize; bs = ALIGN_TO(bs, (u64)CPU_PAGE_SIZE); - ctx->big_buf_size = 2*bs; - ctx->big_buf_half_size = bs; + bs = MAX(bs, 2*(u64)CPU_PAGE_SIZE); + ctx->big_buf_size = bs; } void @@ -149,8 +143,7 @@ sorter_alloc_buf(struct sort_context *ctx) if (ctx->big_buf) return; ctx->big_buf = big_alloc(ctx->big_buf_size); - ctx->big_buf_half = ((byte*) ctx->big_buf) + ctx->big_buf_half_size; - SORT_XTRACE(2, "Allocated sorting buffer (2*%s)", stk_fsize(ctx->big_buf_half_size)); + SORT_XTRACE(2, "Allocated sorting buffer (%s)", stk_fsize(ctx->big_buf_size)); } void