Alpine Linux Build (#990)

* Musl libc does not provide adaptive mutex. Added feature test for PTHREAD_MUTEX_ADAPTIVE_NP.

* Musl libc does not provide backtrace(3). Added a feature check for backtrace(3).

* Fixed compiler error.

* Musl libc does not implement backtrace(3). Added platform check for libexecinfo.

* Alpine does not appear to support gcc -pg option. By default (gcc has PIE option enabled) it fails with:

gcc: error: -pie and -pg|p|profile are incompatible when linking

When -fno-PIE and -nopie are used it fails with:

/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find gcrt1.o: No such file or directory

Added gcc -pg platform test and output PROFILING_FLAGS accordingly. Replaced pg var in Makefile with PROFILING_FLAGS.

* fix segfault when TEST_IOCTL_FRIENDLY_TMPDIR is undefined and default candidates are not suitable

* use ASSERT_DOUBLE_EQ instead of ASSERT_EQ

* When compiled with ROCKSDB_MALLOC_USABLE_SIZE UniversalCompactionFourPaths and UniversalCompactionSecondPathRatio tests fail due to premature memtable flushes on systems with 16-byte alignment. Arena runs out of block space before GenerateNewFile() completes.

Increased options.write_buffer_size.
This commit is contained in:
dx9 2016-04-22 19:49:12 -04:00 committed by Siying Dong
parent 90ffed1f93
commit b71c4e613f
7 changed files with 62 additions and 14 deletions

View File

@ -171,9 +171,7 @@ ifdef COMPILE_WITH_TSAN
PLATFORM_CXXFLAGS += -fsanitize=thread -fPIC -DROCKSDB_TSAN_RUN PLATFORM_CXXFLAGS += -fsanitize=thread -fPIC -DROCKSDB_TSAN_RUN
# Turn off -pg when enabling TSAN testing, because that induces # Turn off -pg when enabling TSAN testing, because that induces
# a link failure. TODO: find the root cause # a link failure. TODO: find the root cause
pg = PROFILING_FLAGS =
else
pg = -pg
endif endif
# USAN doesn't work well with jemalloc. If we're compiling with USAN, we should use regular malloc. # USAN doesn't work well with jemalloc. If we're compiling with USAN, we should use regular malloc.
@ -918,7 +916,7 @@ db_table_properties_test: db/db_table_properties_test.o db/db_test_util.o $(LIBO
$(AM_LINK) $(AM_LINK)
log_write_bench: util/log_write_bench.o $(LIBOBJECTS) $(TESTHARNESS) log_write_bench: util/log_write_bench.o $(LIBOBJECTS) $(TESTHARNESS)
$(AM_LINK) $(pg) $(AM_LINK) $(PROFILING_FLAGS)
plain_table_db_test: db/plain_table_db_test.o $(LIBOBJECTS) $(TESTHARNESS) plain_table_db_test: db/plain_table_db_test.o $(LIBOBJECTS) $(TESTHARNESS)
$(AM_LINK) $(AM_LINK)
@ -927,7 +925,7 @@ comparator_db_test: db/comparator_db_test.o $(LIBOBJECTS) $(TESTHARNESS)
$(AM_LINK) $(AM_LINK)
table_reader_bench: table/table_reader_bench.o $(LIBOBJECTS) $(TESTHARNESS) table_reader_bench: table/table_reader_bench.o $(LIBOBJECTS) $(TESTHARNESS)
$(AM_LINK) $(pg) $(AM_LINK) $(PROFILING_FLAGS)
perf_context_test: db/perf_context_test.o $(LIBOBJECTS) $(TESTHARNESS) perf_context_test: db/perf_context_test.o $(LIBOBJECTS) $(TESTHARNESS)
$(AM_V_CCLD)$(CXX) $^ $(EXEC_LDFLAGS) -o $@ $(LDFLAGS) $(AM_V_CCLD)$(CXX) $^ $(EXEC_LDFLAGS) -o $@ $(LDFLAGS)

View File

@ -322,6 +322,55 @@ EOF
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
COMMON_FLAGS="$COMMON_FLAGS -DROCKSDB_MALLOC_USABLE_SIZE" COMMON_FLAGS="$COMMON_FLAGS -DROCKSDB_MALLOC_USABLE_SIZE"
fi fi
# Test whether PTHREAD_MUTEX_ADAPTIVE_NP mutex type is available
$CXX $CFLAGS -x c++ - -o /dev/null 2>/dev/null <<EOF
#include <pthread.h>
int main() {
int x = PTHREAD_MUTEX_ADAPTIVE_NP;
return 0;
}
EOF
if [ "$?" = 0 ]; then
COMMON_FLAGS="$COMMON_FLAGS -DROCKSDB_PTHREAD_ADAPTIVE_MUTEX"
fi
# Test whether backtrace is available
$CXX $CFLAGS -x c++ - -o /dev/null 2>/dev/null <<EOF
#include <execinfo.h>>
int main() {
void* frames[1];
backtrace_symbols(frames, backtrace(frames, 1));
return 0;
}
EOF
if [ "$?" = 0 ]; then
COMMON_FLAGS="$COMMON_FLAGS -DROCKSDB_BACKTRACE"
else
# Test whether execinfo library is installed
$CXX $CFLAGS -lexecinfo -x c++ - -o /dev/null 2>/dev/null <<EOF
#include <execinfo.h>
int main() {
void* frames[1];
backtrace_symbols(frames, backtrace(frames, 1));
}
EOF
if [ "$?" = 0 ]; then
COMMON_FLAGS="$COMMON_FLAGS -DROCKSDB_BACKTRACE"
PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lexecinfo"
JAVA_LDFLAGS="$JAVA_LDFLAGS -lexecinfo"
fi
fi
# Test if -pg is supported
$CXX $CFLAGS -pg -x c++ - -o /dev/null 2>/dev/null <<EOF
int main() {
return 0;
}
EOF
if [ "$?" = 0 ]; then
PROFILING_FLAGS=-pg
fi
fi fi
# TODO(tec): Fix -Wshorten-64-to-32 errors on FreeBSD and enable the warning. # TODO(tec): Fix -Wshorten-64-to-32 errors on FreeBSD and enable the warning.
@ -402,3 +451,5 @@ echo "ROCKSDB_MINOR=$ROCKSDB_MINOR" >> "$OUTPUT"
echo "ROCKSDB_PATCH=$ROCKSDB_PATCH" >> "$OUTPUT" echo "ROCKSDB_PATCH=$ROCKSDB_PATCH" >> "$OUTPUT"
echo "CLANG_SCAN_BUILD=$CLANG_SCAN_BUILD" >> "$OUTPUT" echo "CLANG_SCAN_BUILD=$CLANG_SCAN_BUILD" >> "$OUTPUT"
echo "CLANG_ANALYZER=$CLANG_ANALYZER" >> "$OUTPUT" echo "CLANG_ANALYZER=$CLANG_ANALYZER" >> "$OUTPUT"
echo "PROFILING_FLAGS=$PROFILING_FLAGS" >> "$OUTPUT"

View File

@ -955,7 +955,7 @@ TEST_P(DBTestUniversalCompaction, UniversalCompactionFourPaths) {
new SpecialSkipListFactory(KNumKeysByGenerateNewFile - 1)); new SpecialSkipListFactory(KNumKeysByGenerateNewFile - 1));
options.compaction_style = kCompactionStyleUniversal; options.compaction_style = kCompactionStyleUniversal;
options.compaction_options_universal.size_ratio = 5; options.compaction_options_universal.size_ratio = 5;
options.write_buffer_size = 110 << 10; // 105KB options.write_buffer_size = 111 << 10; // 114KB
options.arena_block_size = 4 << 10; options.arena_block_size = 4 << 10;
options.level0_file_num_compaction_trigger = 2; options.level0_file_num_compaction_trigger = 2;
options.num_levels = 1; options.num_levels = 1;
@ -1153,8 +1153,7 @@ TEST_P(DBTestUniversalCompaction, UniversalCompactionSecondPathRatio) {
options.db_paths.emplace_back(dbname_ + "_2", 1024 * 1024 * 1024); options.db_paths.emplace_back(dbname_ + "_2", 1024 * 1024 * 1024);
options.compaction_style = kCompactionStyleUniversal; options.compaction_style = kCompactionStyleUniversal;
options.compaction_options_universal.size_ratio = 5; options.compaction_options_universal.size_ratio = 5;
options.write_buffer_size = 110 << 10; // 105KB options.write_buffer_size = 111 << 10; // 114KB
options.arena_block_size = 4 * 1024;
options.arena_block_size = 4 << 10; options.arena_block_size = 4 << 10;
options.level0_file_num_compaction_trigger = 2; options.level0_file_num_compaction_trigger = 2;
options.num_levels = 1; options.num_levels = 1;

View File

@ -35,7 +35,7 @@ static int PthreadCall(const char* label, int result) {
} }
Mutex::Mutex(bool adaptive) { Mutex::Mutex(bool adaptive) {
#ifdef OS_LINUX #ifdef ROCKSDB_PTHREAD_ADAPTIVE_MUTEX
if (!adaptive) { if (!adaptive) {
PthreadCall("init mutex", pthread_mutex_init(&mu_, nullptr)); PthreadCall("init mutex", pthread_mutex_init(&mu_, nullptr));
} else { } else {
@ -48,9 +48,9 @@ Mutex::Mutex(bool adaptive) {
PthreadCall("destroy mutex attr", PthreadCall("destroy mutex attr",
pthread_mutexattr_destroy(&mutex_attr)); pthread_mutexattr_destroy(&mutex_attr));
} }
#else // ignore adaptive for non-linux platform #else
PthreadCall("init mutex", pthread_mutex_init(&mu_, nullptr)); PthreadCall("init mutex", pthread_mutex_init(&mu_, nullptr));
#endif // OS_LINUX #endif // ROCKSDB_PTHREAD_ADAPTIVE_MUTEX
} }
Mutex::~Mutex() { PthreadCall("destroy mutex", pthread_mutex_destroy(&mu_)); } Mutex::~Mutex() { PthreadCall("destroy mutex", pthread_mutex_destroy(&mu_)); }

View File

@ -5,7 +5,7 @@
// //
#include "port/stack_trace.h" #include "port/stack_trace.h"
#if defined(ROCKSDB_LITE) || !(defined(OS_LINUX) || defined(OS_MACOSX)) || \ #if defined(ROCKSDB_LITE) || !(defined(ROCKSDB_BACKTRACE) || defined(OS_MACOSX)) || \
defined(CYGWIN) defined(CYGWIN)
// noop // noop

View File

@ -514,7 +514,7 @@ class IoctlFriendlyTmpdir {
} else { } else {
// Diagnose ioctl-related failure only if this is the // Diagnose ioctl-related failure only if this is the
// directory specified via that envvar. // directory specified via that envvar.
if (tmp == d) { if (tmp && tmp == d) {
fprintf(stderr, "TEST_IOCTL_FRIENDLY_TMPDIR-specified directory is " fprintf(stderr, "TEST_IOCTL_FRIENDLY_TMPDIR-specified directory is "
"not suitable: %s\n", d.c_str()); "not suitable: %s\n", d.c_str());
} }

View File

@ -46,7 +46,7 @@ void AssertField(const JSONDocument& json, const std::string& field,
double expected) { double expected) {
ASSERT_TRUE(json.Contains(field)); ASSERT_TRUE(json.Contains(field));
ASSERT_TRUE(json[field].IsDouble()); ASSERT_TRUE(json[field].IsDouble());
ASSERT_EQ(expected, json[field].GetDouble()); ASSERT_DOUBLE_EQ(expected, json[field].GetDouble());
} }
} // namespace } // namespace