From f02db1c118dd691409b9d60dfbc7978ca1c22fb0 Mon Sep 17 00:00:00 2001 From: Chip Turner Date: Wed, 6 Feb 2013 17:12:43 -0800 Subject: [PATCH] Add zlib to our builds and tweak histogram output Summary: $SUBJECT -- cosmetic fix for histograms, print P75/P99, and make sure zlib is enabled for our command line tools. Test Plan: compile, test db_bench with --compression_type=zlib Reviewers: heyongqiang Reviewed By: heyongqiang CC: adsharma, leveldb Differential Revision: https://reviews.facebook.net/D8445 --- fbcode.gcc471.sh | 12 ++++++++---- util/histogram.cc | 6 +++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/fbcode.gcc471.sh b/fbcode.gcc471.sh index c6d94eb23..5a20dce03 100644 --- a/fbcode.gcc471.sh +++ b/fbcode.gcc471.sh @@ -23,6 +23,10 @@ fi SNAPPY_INCLUDE=" -I $TOOLCHAIN_LIB_BASE/snappy/snappy-1.0.3/7518bbe/include" SNAPPY_LIBS=" $TOOLCHAIN_LIB_BASE/snappy/snappy-1.0.3/7518bbe/lib/libsnappy.a" +# location of zlib headers and libraries +ZLIB_INCLUDE=" -I $TOOLCHAIN_LIB_BASE/zlib/zlib-1.2.5/91ddd43/include" +ZLIB_LIBS=" $TOOLCHAIN_LIB_BASE/zlib/zlib-1.2.5/91ddd43/lib/libz.a" + # location of boost headers and libraries THRIFT_INCLUDE=" -I $TOOLCHAIN_LIB_BASE/boost/boost-1.48.0/bef9365/include -std=gnu++0x" THRIFT_INCLUDE+=" -I./thrift -I./thrift/gen-cpp -I./thrift/lib/cpp" @@ -36,7 +40,7 @@ LIBEVENT_LIBS=" -L $TOOLCHAIN_LIB_BASE/libevent/libevent-1.4.14b/91ddd43/lib" export USE_SSE=" -msse -msse4.2 " CC="$TOOLCHAIN_EXECUTABLES/gcc/gcc-4.7.1-glibc-2.14.1/bin/gcc" -CXX="$TOOLCHAIN_EXECUTABLES/gcc/gcc-4.7.1-glibc-2.14.1/bin/g++ $JINCLUDE $SNAPPY_INCLUDE $THRIFT_INCLUDE $LIBEVENT_INCLUDE" +CXX="$TOOLCHAIN_EXECUTABLES/gcc/gcc-4.7.1-glibc-2.14.1/bin/g++ $JINCLUDE $SNAPPY_INCLUDE $ZLIB_INCLUDE $THRIFT_INCLUDE $LIBEVENT_INCLUDE" AR=$TOOLCHAIN_EXECUTABLES/binutils/binutils-2.21.1/da39a3e/bin/ar RANLIB=$TOOLCHAIN_EXECUTABLES/binutils/binutils-2.21.1/da39a3e/bin/ranlib @@ -45,11 +49,11 @@ CFLAGS+=" -I $TOOLCHAIN_LIB_BASE/jemalloc/$TOOL_JEMALLOC/include -DHAVE_JEMALLOC EXEC_LDFLAGS=" -Wl,--whole-archive $TOOLCHAIN_LIB_BASE/jemalloc/$TOOL_JEMALLOC/lib/libjemalloc.a" EXEC_LDFLAGS+=" -Wl,--no-whole-archive $TOOLCHAIN_LIB_BASE/libunwind/libunwind-20100812_experimental/91ddd43/lib/libunwind.a" -EXEC_LDFLAGS+=" $HDFSLIB $SNAPPY_LIBS $THRIFT_LIBS $LIBEVENT_LIBS" +EXEC_LDFLAGS+=" $HDFSLIB $SNAPPY_LIBS $ZLIB_LIBS $THRIFT_LIBS $LIBEVENT_LIBS" PLATFORM_LDFLAGS="-L$TOOLCHAIN_LIB_BASE/libgcc/libgcc-4.7.1/afc21dc/lib -L$TOOLCHAIN_LIB_BASE/glibc/glibc-2.14.1/99df8fc/lib" -EXEC_LDFLAGS_SHARED="$SNAPPY_LIBS" -SNAPPY_LDFLAGS="$SNAPPY_LIBS" +EXEC_LDFLAGS_SHARED="$SNAPPY_LIBS $ZLIB_LIBS" +SNAPPY_LDFLAGS="$SNAPPY_LIBS $ZLIB_LIBS" export CC CXX AR RANLIB CFLAGS EXEC_LDFLAGS EXEC_LDFLAGS_SHARED SNAPPY_LDFLAGS diff --git a/util/histogram.cc b/util/histogram.cc index 089789cd6..422bc1fda 100644 --- a/util/histogram.cc +++ b/util/histogram.cc @@ -150,6 +150,10 @@ std::string Histogram::ToString() const { "Min: %.4f Median: %.4f Max: %.4f\n", (num_ == 0.0 ? 0.0 : min_), Median(), max_); r.append(buf); + snprintf(buf, sizeof(buf), + "Percentiles: P50: %.2f P75: %.2f P99: %.2f P99.9: %.2f\n", + Percentile(50), Percentile(75), Percentile(99), Percentile(99.9)); + r.append(buf); r.append("------------------------------------------------------\n"); const double mult = 100.0 / num_; double sum = 0; @@ -157,7 +161,7 @@ std::string Histogram::ToString() const { if (buckets_[b] <= 0.0) continue; sum += buckets_[b]; snprintf(buf, sizeof(buf), - "[ %ld, %ld ) %ld %7.3f%% %7.3f%% ", + "[ %7ld, %7ld ) %8ld %7.3f%% %7.3f%% ", ((b == 0) ? 0 : bucketMapper.BucketLimit(b-1)), // left bucketMapper.BucketLimit(b), // right buckets_[b], // count