@@ -88,6 +88,8 @@ PATENT RIGHTS GRANT:
88
88
89
89
#include < algorithm>
90
90
91
+ #include < string.h>
92
+
91
93
#include " portability/toku_assert.h"
92
94
93
95
#include " ft/serialize/block_allocator_strategy.h"
@@ -96,7 +98,7 @@ static uint64_t _align(uint64_t value, uint64_t ba_alignment) {
96
98
return ((value + ba_alignment - 1 ) / ba_alignment) * ba_alignment;
97
99
}
98
100
99
- static uint64_t _next_power_of_two (uint64_t value) {
101
+ static uint64_t _roundup_to_power_of_two (uint64_t value) {
100
102
uint64_t r = 4096 ;
101
103
while (r < value) {
102
104
r *= 2 ;
@@ -158,23 +160,24 @@ block_allocator_strategy::best_fit(struct block_allocator::blockpair *blocks_arr
158
160
return best_bp;
159
161
}
160
162
161
- static uint64_t padded_fit_alignment = 64 * 1024 ;
163
+ static uint64_t padded_fit_alignment = 4096 ;
162
164
163
165
// TODO: These compiler specific directives should be abstracted in a portability header
164
166
// portability/toku_compiler.h?
165
167
__attribute__ ((__constructor__))
166
168
static void determine_padded_fit_alignment_from_env(void ) {
167
169
// TODO: Should be in portability as 'toku_os_getenv()?'
168
170
const char *s = getenv (" TOKU_BA_PADDED_FIT_ALIGNMENT" );
169
- if (s != nullptr ) {
171
+ if (s != nullptr && strlen (s) > 0 ) {
170
172
const int64_t alignment = strtoll (s, nullptr , 10 );
171
- if (alignment < 0 ) {
173
+ if (alignment <= 0 ) {
172
174
fprintf (stderr, " tokuft: error: block allocator padded fit alignment found in environment (%s), "
173
- " but it's out of range (should be an integer > 0). defaulting to 10 \n " , s);
174
- padded_fit_alignment = 64 * 1024 ;
175
+ " but it's out of range (should be an integer > 0). defaulting to % " PRIu64 " \n " ,
176
+ s, padded_fit_alignment) ;
175
177
} else {
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);
178
+ padded_fit_alignment = _roundup_to_power_of_two (alignment);
179
+ fprintf (stderr, " tokuft: setting block allocator padded fit alignment to %" PRIu64 " \n " ,
180
+ padded_fit_alignment);
178
181
}
179
182
}
180
183
}
@@ -196,7 +199,7 @@ __attribute__((__constructor__))
196
199
static void determine_hot_zone_threshold_from_env(void ) {
197
200
// TODO: Should be in portability as 'toku_os_getenv()?'
198
201
const char *s = getenv (" TOKU_BA_HOT_ZONE_THRESHOLD" );
199
- if (s != nullptr ) {
202
+ if (s != nullptr && strlen (s) > 0 ) {
200
203
const double hot_zone = strtod (s, nullptr );
201
204
if (hot_zone < 1 || hot_zone > 99 ) {
202
205
fprintf (stderr, " tokuft: error: block allocator hot zone threshold found in environment (%s), "
0 commit comments