Commit 66fb8ffe authored by John Esmet's avatar John Esmet

FT-309 Change the way padded-fit allocation alignment works

parent 30f97ccd
...@@ -158,23 +158,23 @@ block_allocator_strategy::best_fit(struct block_allocator::blockpair *blocks_arr ...@@ -158,23 +158,23 @@ block_allocator_strategy::best_fit(struct block_allocator::blockpair *blocks_arr
return best_bp; return best_bp;
} }
static uint64_t desired_fragmentation_divisor = 10; static uint64_t padded_fit_alignment = 64 * 1024;
// TODO: These compiler specific directives should be abstracted in a portability header // TODO: These compiler specific directives should be abstracted in a portability header
// portability/toku_compiler.h? // portability/toku_compiler.h?
__attribute__((__constructor__)) __attribute__((__constructor__))
static void determine_padded_fit_divisor_from_env(void) { static void determine_padded_fit_alignment_from_env(void) {
// TODO: Should be in portability as 'toku_os_getenv()?' // TODO: Should be in portability as 'toku_os_getenv()?'
const char *s = getenv("TOKU_BA_PADDED_FIT_DIVISOR"); const char *s = getenv("TOKU_BA_PADDED_FIT_ALIGNMENT");
if (s != nullptr) { if (s != nullptr) {
const int64_t divisor = strtoll(s, nullptr, 10); const int64_t alignment = strtoll(s, nullptr, 10);
if (divisor < 0) { if (alignment < 0) {
fprintf(stderr, "tokuft: error: block allocator padded fit divisor found in environment (%s), " fprintf(stderr, "tokuft: error: block allocator padded fit alignment found in environment (%s), "
"but it's out of range (should be an integer > 0). defaulting to 10\n", s); "but it's out of range (should be an integer > 0). defaulting to 10\n", s);
desired_fragmentation_divisor = 10; padded_fit_alignment = 64 * 1024;
} else { } else {
fprintf(stderr, "tokuft: setting block allocator padded fit divisor to %s\n", s); padded_fit_alignment = _next_power_of_two(alignment);
desired_fragmentation_divisor = divisor; fprintf(stderr, "tokuft: setting block allocator padded fit alignment to %" PRIu64 "\n", padded_fit_alignment);
} }
} }
} }
...@@ -185,10 +185,7 @@ static void determine_padded_fit_divisor_from_env(void) { ...@@ -185,10 +185,7 @@ static void determine_padded_fit_divisor_from_env(void) {
struct block_allocator::blockpair * struct block_allocator::blockpair *
block_allocator_strategy::padded_fit(struct block_allocator::blockpair *blocks_array, block_allocator_strategy::padded_fit(struct block_allocator::blockpair *blocks_array,
uint64_t n_blocks, uint64_t size, uint64_t alignment) { uint64_t n_blocks, uint64_t size, uint64_t alignment) {
static const uint64_t absolute_max_padding = 128 * 1024; return _first_fit(blocks_array, n_blocks, size, alignment, true, padded_fit_alignment);
uint64_t desired_padding = size / desired_fragmentation_divisor;
desired_padding = std::min(_next_power_of_two(desired_padding), absolute_max_padding);
return _first_fit(blocks_array, n_blocks, size, alignment, true, desired_padding);
} }
static double hot_zone_threshold = 0.85; static double hot_zone_threshold = 0.85;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment