From 9281a826f1f80b0e6d423f296ef5639aa48a331a Mon Sep 17 00:00:00 2001 From: kailiu Date: Thu, 2 Jan 2014 10:29:48 -0800 Subject: [PATCH 1/7] Hotfix the bug in table cache's GetSliceForFileNumber Forgot to fix this problem in master branch. Already fixed it in performance branch. --- db/table_cache.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db/table_cache.cc b/db/table_cache.cc index 20eb68e4b8..593352ddea 100644 --- a/db/table_cache.cc +++ b/db/table_cache.cc @@ -29,9 +29,9 @@ static void UnrefEntry(void* arg1, void* arg2) { cache->Release(h); } -static Slice GetSliceForFileNumber(uint64_t file_number) { - return Slice(reinterpret_cast(&file_number), - sizeof(file_number)); +static Slice GetSliceForFileNumber(uint64_t* file_number) { + return Slice(reinterpret_cast(file_number), + sizeof(*file_number)); } TableCache::TableCache(const std::string& dbname, @@ -55,7 +55,7 @@ Status TableCache::FindTable(const EnvOptions& toptions, Cache::Handle** handle, bool* table_io, const bool no_io) { Status s; - Slice key = GetSliceForFileNumber(file_number); + Slice key = GetSliceForFileNumber(&file_number); *handle = cache_->Lookup(key); if (*handle == nullptr) { if (no_io) { // Dont do IO and return a not-found status @@ -168,7 +168,7 @@ bool TableCache::PrefixMayMatch(const ReadOptions& options, } void TableCache::Evict(uint64_t file_number) { - cache_->Erase(GetSliceForFileNumber(file_number)); + cache_->Erase(GetSliceForFileNumber(&file_number)); } } // namespace rocksdb From 46950597d0100ef78024b3e9f55100d583228773 Mon Sep 17 00:00:00 2001 From: Kai Liu Date: Mon, 30 Dec 2013 16:40:08 -0800 Subject: [PATCH 2/7] Automate the preparation step for a new release Summary: Added a script that prepares the repo for facebook's new rocksdb release, which will automatically do some necessary work to make sure this repo is ready for 3rdparty release. Test Plan: Run this script and observed: * new version was created (both in local and remote repo) as a git tag. * build_version.cc was updated * build_detect_platform was changed so that it won't create any new change. Reviewers: haobo, dhruba, sdong, igor CC: leveldb Differential Revision: https://reviews.facebook.net/D15003 --- build_tools/make_new_version.sh | 61 +++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 build_tools/make_new_version.sh diff --git a/build_tools/make_new_version.sh b/build_tools/make_new_version.sh new file mode 100755 index 0000000000..ca8a212628 --- /dev/null +++ b/build_tools/make_new_version.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# Copyright (c) 2013, Facebook, Inc. All rights reserved. +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. An additional grant +# of patent rights can be found in the PATENTS file in the same directory. + +set -e +# Print out the colored progress info so that it can be brainlessly +# distinguished by users. +function title() { + echo -e "\033[1;32m$*\033[0m" +} + +usage="Create new rocksdb version and prepare it for the release process\n" +usage+="USAGE: ./make_new_version.sh " + +# -- Pre-check +if [[ $# < 1 ]]; then + echo -e $usage + exit 1 +fi + +ROCKSDB_VERSION=$1 + +GIT_BRANCH=`git rev-parse --abbrev-ref HEAD` +if [ $GIT_BRANCH != "master" ]; then + echo "Error: Current branch is '$GIT_BRANCH', Please switch to master branch." +fi + +# --Step 1: cutting new tag +title "Adding new tag for this release ..." +git tag -a "$ROCKSDB_VERSION.fb" -m "Rocksdb $ROCKSDB_VERSION" + +# Setting up the proxy for remote repo access +export http_proxy=http://172.31.255.99:8080 +export https_proxy="$http_proxy"; + +title "Pushing new tag to remote repo ..." +proxycmd.sh git push origin --tags + +# --Step 2: Update README.fb +title "Updating the latest version info in README.fb ..." +sed -i "s/Latest release is [0-9]\+.[0-9]\+.fb/Latest release is $ROCKSDB_VERSION.fb/" README.fb +git commit README.fb -m "update the latest version in README.fb to $ROCKSDB_VERSION" +proxycmd.sh git push + +# --Step 3: Prepare this repo for 3rd release +title "Cleaning up repo ..." +make clean +git clean -fxd + +title "Generating the build info ..." +# Comment out the call of `build_detection_version` so that the SHA number and build date of this +# release will remain constant. Otherwise everytime we run "make" util/build_version.cc will be +# overridden. +sed -i 's/^\$PWD\/build_tools\/build_detect_version$//' build_tools/build_detect_platform + +# Generate util/build_version.cc +build_tools/build_detect_version + +title "Done!" From 463086bce8cef64433c4c32089b7731579255651 Mon Sep 17 00:00:00 2001 From: Kai Liu Date: Thu, 2 Jan 2014 13:26:38 -0800 Subject: [PATCH 3/7] Add clang-format rules Summary: The rule file is forked from that in Facebook's repo. I'll add format file for now and team members can tune the rules later. In this patch, I made only two changes in order to be consistent with existing coding style `SpacesBeforeTrailingComments: 2` `ColumnLimit: 80` Test Plan: N/A Reviewers: igor CC: leveldb Differential Revision: https://reviews.facebook.net/D15015 --- .clang-format | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000000..a1e9a48e40 --- /dev/null +++ b/.clang-format @@ -0,0 +1,47 @@ +# Complete list of style options can be found at: +# http://clang.llvm.org/docs/ClangFormatStyleOptions.html +--- +BasedOnStyle: Google +AccessModifierOffset: -1 +ConstructorInitializerIndentWidth: 4 +AlignEscapedNewlinesLeft: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakTemplateDeclarations: true +AlwaysBreakBeforeMultilineStrings: true +BreakBeforeBinaryOperators: false +BreakConstructorInitializersBeforeComma: false +BinPackParameters: false +ColumnLimit: 80 +ConstructorInitializerAllOnOneLineOrOnePerLine: true +DerivePointerBinding: true +ExperimentalAutoDetectBinPacking: true +IndentCaseLabels: false +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCSpaceBeforeProtocolList: false +PenaltyBreakBeforeFirstCallParameter: 10 +PenaltyBreakComment: 60 +PenaltyBreakString: 1000 +PenaltyBreakFirstLessLess: 20 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerBindsToType: true +SpacesBeforeTrailingComments: 2 +Cpp11BracedListStyle: true +Standard: Cpp11 +IndentWidth: 2 +TabWidth: 8 +UseTab: Never +BreakBeforeBraces: Attach +IndentFunctionDeclarationAfterType: false +SpacesInParentheses: false +SpacesInAngles: false +SpaceInEmptyParentheses: false +SpacesInCStyleCastParentheses: false +SpaceAfterControlStatementKeyword: true +SpaceBeforeAssignmentOperators: true +ContinuationIndentWidth: 4 +... From 8f6e31951e77f727c2c25a40bb96954d6ccff06d Mon Sep 17 00:00:00 2001 From: Kai Liu Date: Sat, 4 Jan 2014 23:47:44 -0800 Subject: [PATCH 4/7] Add a hack to build_detect_platform so it works in all types of fb-servers --- build_tools/build_detect_platform | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build_tools/build_detect_platform b/build_tools/build_detect_platform index 87c4c871dc..93eac07e06 100755 --- a/build_tools/build_detect_platform +++ b/build_tools/build_detect_platform @@ -172,7 +172,11 @@ echo "MEMENV_SOURCES=helpers/memenv/memenv.cc" >> $OUTPUT if [ "$CROSS_COMPILE" = "true" -o "$FBCODE_BUILD" = "true" ]; then # Cross-compiling; do not try any compilation tests. # Also don't need any compilation tests if compiling on fbcode - true + # TODO(kailiu) For some fb-supported environments, they have trouble finding + # symbols from gflags if -lgflags wasn't specified. As a temporary resort, + # we added it to PLATFORM_LDFLAGS although for some environments it is + # unnecessary. + PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -gflags" else # do fPIC on 64 bit in non-fbcode environment case "$TARGET_OS" in From d800dc567aa072b865f445a7a984b3740ed8ba3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dog=CC=86an=20C=CC=A7ec=CC=A7en?= Date: Sun, 5 Jan 2014 22:52:19 +0200 Subject: [PATCH 5/7] Refactor build_tools/build_detect_version --- .gitignore | 1 - build_tools/build_detect_version | 42 +++++++++----------------------- 2 files changed, 11 insertions(+), 32 deletions(-) diff --git a/.gitignore b/.gitignore index 1c2d2b3780..03a5f1761a 100644 --- a/.gitignore +++ b/.gitignore @@ -19,5 +19,4 @@ sst_dump util/build_version.cc build_tools/VALGRIND_LOGS/ coverage/COVERAGE_REPORT -util/build_version.cc.tmp .gdbhistory diff --git a/build_tools/build_detect_version b/build_tools/build_detect_version index 3ee6c92bd2..f7d711f0dd 100755 --- a/build_tools/build_detect_version +++ b/build_tools/build_detect_version @@ -5,38 +5,18 @@ # is then built as a regular source file as part of the compilation process. # One can run "strings executable_filename | grep _build_" to find the version of # the source that we used to build the executable file. -# -# create git version file -VFILE=$PWD/util/build_version.cc.tmp -trap "rm $VFILE" EXIT +OUTFILE="$PWD/util/build_version.cc" -# check to see if git is in the path -which git > /dev/null - -if [ "$?" = 0 ]; then - env -i git rev-parse HEAD 2>&1 | - awk ' - BEGIN { - print "#include \"build_version.h\"\n" - } - { print "const char* rocksdb_build_git_sha = \"rocksdb_build_git_sha:" $0"\";" } - ' > ${VFILE} -else - echo "git not found" | - awk ' - BEGIN { - print "#include \"build_version.h\"" - } - { print "const char* rocksdb_build_git_sha = \"rocksdb_build_git_sha:git not found\";" } - ' > ${VFILE} +GIT_SHA="" +if command -v git >/dev/null 2>&1; then + GIT_SHA=$(git rev-parse HEAD 2>/dev/null) fi -echo "const char* rocksdb_build_git_datetime = \"rocksdb_build_git_datetime:$(date)\";" >> ${VFILE} -echo "const char* rocksdb_build_compile_date = __DATE__;" >> ${VFILE} -echo "const char* rocksdb_build_compile_time = __TIME__;" >> ${VFILE} - -OUTFILE=$PWD/util/build_version.cc -if [ ! -e $OUTFILE ] || ! cmp -s $VFILE $OUTFILE; then - cp $VFILE $OUTFILE -fi +cat > "${OUTFILE}" < Date: Mon, 6 Jan 2014 11:11:19 -0800 Subject: [PATCH 6/7] Fix issue #57 --- util/autovector_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/autovector_test.cc b/util/autovector_test.cc index 6d709a374b..eb244aabf9 100644 --- a/util/autovector_test.cc +++ b/util/autovector_test.cc @@ -17,7 +17,7 @@ using namespace std; class AutoVectorTest { }; -const size_t kSize = 8; +const unsigned long kSize = 8; TEST(AutoVectorTest, PushBackAndPopBack) { autovector vec; ASSERT_TRUE(vec.empty()); From c370f5597a799af69e92da0bc5b721dddb64b589 Mon Sep 17 00:00:00 2001 From: kailiu Date: Mon, 6 Jan 2014 11:53:19 -0800 Subject: [PATCH 7/7] Revert change in 8f6e319. --- build_tools/build_detect_platform | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/build_tools/build_detect_platform b/build_tools/build_detect_platform index 93eac07e06..87c4c871dc 100755 --- a/build_tools/build_detect_platform +++ b/build_tools/build_detect_platform @@ -172,11 +172,7 @@ echo "MEMENV_SOURCES=helpers/memenv/memenv.cc" >> $OUTPUT if [ "$CROSS_COMPILE" = "true" -o "$FBCODE_BUILD" = "true" ]; then # Cross-compiling; do not try any compilation tests. # Also don't need any compilation tests if compiling on fbcode - # TODO(kailiu) For some fb-supported environments, they have trouble finding - # symbols from gflags if -lgflags wasn't specified. As a temporary resort, - # we added it to PLATFORM_LDFLAGS although for some environments it is - # unnecessary. - PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -gflags" + true else # do fPIC on 64 bit in non-fbcode environment case "$TARGET_OS" in