#ifdef SORT_VAR_DATA
if (sizeof(key) + 2*CPU_PAGE_SIZE + SORT_DATA_SIZE(key) + P(internal_workspace)(&key) > bufsize)
{
- SORT_XTRACE(3, "s-internal: Generating a giant run");
+ SORT_XTRACE(4, "s-internal: Generating a giant run");
struct fastbuf *out = sbuck_write(bout);
P(copy_data)(&key, in, out);
bout->runs++;
}
#endif
- SORT_XTRACE(4, "s-internal: Reading");
+ SORT_XTRACE(5, "s-internal: Reading");
P(internal_item_t) *item_array = ctx->big_buf, *item = item_array, *last_item;
byte *end = (byte *) ctx->big_buf + bufsize;
size_t remains = bufsize - CPU_PAGE_SIZE;
#endif
uns dsize = SORT_DATA_SIZE(key);
uns recsize = ALIGN_TO(ksize_aligned + dsize, CPU_STRUCT_ALIGN);
- size_t totalsize = recsize + sizeof(P(internal_item_t) *) + P(internal_workspace)(&key);
+ size_t totalsize = recsize + sizeof(P(internal_item_t)) + P(internal_workspace)(&key);
if (unlikely(totalsize > remains
#ifdef CPU_64BIT_POINTERS
|| item >= item_array + ~0U // The number of items must fit in an uns
uns count = last_item - item_array;
void *workspace UNUSED = ALIGN_PTR(last_item, CPU_PAGE_SIZE);
- SORT_XTRACE(3, "s-internal: Read %u items (%s items, %s workspace, %s data)",
+ SORT_XTRACE(4, "s-internal: Read %u items (%s items, %s workspace, %s data)",
count,
stk_fsize((byte*)last_item - (byte*)item_array),
stk_fsize(end - (byte*)last_item - remains),
stk_fsize((byte*)ctx->big_buf + bufsize - end));
timestamp_t timer;
init_timer(&timer);
- item_array = P(array_sort)(item_array, count,
+ item_array = P(array_sort)(item_array, count
#ifdef SORT_INTERNAL_RADIX
- workspace, bin->hash_bits
-#else
- NULL, 0
+ , workspace, bin->hash_bits
#endif
);
+ if ((void *)item_array != ctx->big_buf)
+ workspace = ctx->big_buf;
+ last_item = item_array + count;
ctx->total_int_time += get_timer(&timer);
- SORT_XTRACE(4, "s-internal: Writing");
+ SORT_XTRACE(5, "s-internal: Writing");
if (!ctx->more_keys)
bout = bout_only;
struct fastbuf *out = sbuck_write(bout);
#endif
}
#ifdef SORT_UNIFY
- SORT_XTRACE(3, "Merging reduced %u records", merged);
+ SORT_XTRACE(4, "Merging reduced %u records", merged);
#endif
return ctx->more_keys;