Skip to content

Commit 66fb8ff

Browse files
committed
FT-309 Change the way padded-fit allocation alignment works
1 parent 30f97cc commit 66fb8ff

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

ft/serialize/block_allocator_strategy.cc

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -158,23 +158,23 @@ block_allocator_strategy::best_fit(struct block_allocator::blockpair *blocks_arr
158158
return best_bp;
159159
}
160160

161-
static uint64_t desired_fragmentation_divisor = 10;
161+
static uint64_t padded_fit_alignment = 64 * 1024;
162162

163163
// TODO: These compiler specific directives should be abstracted in a portability header
164164
// portability/toku_compiler.h?
165165
__attribute__((__constructor__))
166-
static void determine_padded_fit_divisor_from_env(void) {
166+
static void determine_padded_fit_alignment_from_env(void) {
167167
// TODO: Should be in portability as 'toku_os_getenv()?'
168-
const char *s = getenv("TOKU_BA_PADDED_FIT_DIVISOR");
168+
const char *s = getenv("TOKU_BA_PADDED_FIT_ALIGNMENT");
169169
if (s != nullptr) {
170-
const int64_t divisor = strtoll(s, nullptr, 10);
171-
if (divisor < 0) {
172-
fprintf(stderr, "tokuft: error: block allocator padded fit divisor found in environment (%s), "
170+
const int64_t alignment = strtoll(s, nullptr, 10);
171+
if (alignment < 0) {
172+
fprintf(stderr, "tokuft: error: block allocator padded fit alignment found in environment (%s), "
173173
"but it's out of range (should be an integer > 0). defaulting to 10\n", s);
174-
desired_fragmentation_divisor = 10;
174+
padded_fit_alignment = 64 * 1024;
175175
} else {
176-
fprintf(stderr, "tokuft: setting block allocator padded fit divisor to %s\n", s);
177-
desired_fragmentation_divisor = divisor;
176+
padded_fit_alignment = _next_power_of_two(alignment);
177+
fprintf(stderr, "tokuft: setting block allocator padded fit alignment to %" PRIu64 "\n", padded_fit_alignment);
178178
}
179179
}
180180
}
@@ -185,10 +185,7 @@ static void determine_padded_fit_divisor_from_env(void) {
185185
struct block_allocator::blockpair *
186186
block_allocator_strategy::padded_fit(struct block_allocator::blockpair *blocks_array,
187187
uint64_t n_blocks, uint64_t size, uint64_t alignment) {
188-
static const uint64_t absolute_max_padding = 128 * 1024;
189-
uint64_t desired_padding = size / desired_fragmentation_divisor;
190-
desired_padding = std::min(_next_power_of_two(desired_padding), absolute_max_padding);
191-
return _first_fit(blocks_array, n_blocks, size, alignment, true, desired_padding);
188+
return _first_fit(blocks_array, n_blocks, size, alignment, true, padded_fit_alignment);
192189
}
193190

194191
static double hot_zone_threshold = 0.85;

0 commit comments

Comments
 (0)