should be probably calculated from the former.
o Buffer sizing in shep-export.
o Problems with thread stack limit in radix-sorting of arrays.
-o Prediction of destination buffer in array radix-sorts.
-
-Improvements:
-o Switching between direct and normal I/O. Should use normal I/O if the input is small enough.
Users of lib/sorter/array.h which might use radix-sorting:
indexer/chewer.c
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;
-extern u64 sorter_bufsize;
-extern struct fb_params sorter_fb_params;
+extern u64 sorter_bufsize, sorter_small_input;
+extern struct fb_params sorter_fb_params, sorter_small_fb_params;
#define SORT_TRACE(x...) do { if (sorter_trace) msg(L_DEBUG, x); } while(0)
#define SORT_XTRACE(level, x...) do { if (sorter_trace >= level) msg(L_DEBUG, x); } while(0)
struct fastbuf *out_fb;
uns hash_bits;
u64 in_size;
+ struct fb_params *fb_params;
struct mempool *pool;
clist bucket_list;
#include "lib/sorter/common.h"
uns sorter_trace;
-uns sorter_stream_bufsize = 65536;
u64 sorter_bufsize = 65536;
uns sorter_debug;
uns sorter_min_radix_bits;
uns sorter_thread_chunk = 4096;
uns sorter_radix_threshold = 4096;
struct fb_params sorter_fb_params;
+struct fb_params sorter_small_fb_params;
+u64 sorter_small_input;
static struct cf_section sorter_config = {
CF_ITEMS {
CF_UNS("Trace", &sorter_trace),
- CF_UNS("StreamBuffer", &sorter_stream_bufsize),
CF_SECTION("FileAccess", &sorter_fb_params, &fbpar_cf),
+ CF_SECTION("SmallFileAccess", &sorter_fb_params, &fbpar_cf),
+ CF_U64("SmallInput", &sorter_small_input),
CF_U64("SortBuffer", &sorter_bufsize),
CF_UNS("Debug", &sorter_debug),
CF_UNS("MinRadixBits", &sorter_min_radix_bits),
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);
{
if (b->flags & SBF_SWAPPED_OUT)
{
- b->fb = bopen_file(b->filename, O_RDWR, &sorter_fb_params); /* FIXME: Something different for small buckets? */
+ b->fb = bopen_file(b->filename, O_RDWR, b->ctx->fb_params);
if (b->flags & SBF_OPEN_WRITE)
bseek(b->fb, 0, SEEK_END);
bconfig(b->fb, BCONFIG_IS_TEMP_FILE, 1);
else
{
ASSERT(!(b->flags & (SBF_OPEN_READ | SBF_DESTROYED)));
- b->fb = bopen_tmp_file(&sorter_fb_params);
+ b->fb = bopen_tmp_file(b->ctx->fb_params);
if (sorter_debug & SORT_DEBUG_KEEP_BUCKETS)
bconfig(b->fb, BCONFIG_IS_TEMP_FILE, 0);
b->flags |= SBF_OPEN_WRITE;