在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:kudu开源软件地址:https://gitee.com/DengMingChen/kudu开源软件介绍:Kudu Developer DocumentationBuilding and installing KuduFollow the steps in thedocumentationto build and install Kudu from source Building Kudu out of treeA single Kudu source tree may be used for multiple builds, each with itsown build directory. Build directories may be placed anywhere in thefilesystem with the exception of the root directory of the source tree. TheKudu build is invoked with a working directory of the build directoryitself, so you must ensure it exists (i.e. create it with mkdir -p). It’srecommended to place all build directories within the build subdirectory;build/latest will be symlinked to most recently created one. The rest of this document assumes the build directory<root directory of kudu source tree>/build/debug. Automatic rebuilding of dependenciesThe script To disable the automatic invocation of $ cd build/debug$ NO_REBUILD_THIRDPARTY=1 cmake ../.. This can be particularly useful when trying to run tools like Building Kudu itself# Add <root of kudu tree>/thirdparty/installed/common/bin to your $PATH# before other parts of $PATH that may contain cmake, such as /usr/bin# For example: "export PATH=$HOME/git/kudu/thirdparty/installed/common/bin:$PATH"# if using bash.$ mkdir -p build/debug$ cd build/debug$ cmake ../..$ make -j8 # or whatever level of parallelism your machine can handle The build artifacts, including the test binaries, will be stored inbuild/debug/bin/. To omit the Kudu unit tests during the build, add -DNO_TESTS=1 to theinvocation of cmake. For example: $ cd build/debug$ cmake -DNO_TESTS=1 ../.. Running unit/functional testsTo run the Kudu unit tests, you can use the $ cd build/debug$ ctest -j8 This command will report any tests that failed, and the test logs will bewritten to build/debug/test-logs. Individual tests can be run by directly invoking the test binaries inbuild/debug/bin. Since Kudu uses the Google C++ Test Framework (gtest),specific test cases can be run with gtest flags: # List all the tests within a test binary, then run a single test$ build/debug/bin/tablet-test --gtest_list_tests$ build/debug/bin/tablet-test --gtest_filter=TestTablet/9.TestFlush gtest also allows more complex filtering patterns. See the upstreamdocumentation for more details. Running tests with the clang AddressSanitizer enabledAddressSanitizer is a nice clang feature which can detect many types of memoryerrors. The Jenkins setup for kudu runs these tests automatically on a regularbasis, but if you make large changes it can be a good idea to run it locallybefore pushing. To do so, you’ll need to build using $ mkdir -p build/asan$ cd build/asan$ CC=../../thirdparty/clang-toolchain/bin/clang \ CXX=../../thirdparty/clang-toolchain/bin/clang++ \ ../../thirdparty/installed/common/bin/cmake \ -DKUDU_USE_ASAN=1 ../..$ make -j8$ ctest -j8 The tests will run significantly slower than without ASAN enabled, and if anymemory error occurs, the test that triggered it will fail. You can then use acommand like: $ cd build/asan$ ctest -R failing-test to run just the failed test.
Running tests with the clang Undefined Behavior Sanitizer (UBSAN) enabledSimilar to the above, you can use a special set of clang flags to enable the UndefinedBehavior Sanitizer. This will generate errors on certain pieces of code which maynot themselves crash but rely on behavior which isn’t defined by the C++ standard(and thus are likely bugs). To enable UBSAN, follow the same directions as forASAN above, but pass the In order to get a stack trace from UBSan, you can use gdb on the failing test, andset a breakpoint as follows: (gdb) b __ubsan::Diag::~Diag Then, when the breakpoint fires, gather a backtrace as usual using the Running tests with ThreadSanitizer enabledThreadSanitizer (TSAN) is a feature of recent Clang and GCC compilers which candetect improperly synchronized access to data along with many other threadingbugs. To enable TSAN, pass $ mkdir -p build/tsan$ cd build/tsan$ CC=../../thirdparty/clang-toolchain/bin/clang \ CXX=../../thirdparty/clang-toolchain/bin/clang++ \ ../../thirdparty/installed/common/bin/cmake \ -DKUDU_USE_TSAN=1 ../..$ make -j8$ ctest -j8 TSAN may truncate a few lines of the stack trace when reporting where the erroris. This can be bewildering. It’s documented for TSANv1 here:https://code.google.com/p/data-race-test/wiki/ThreadSanitizerAlgorithmIt is not mentioned in the documentation for TSANv2, but has been observed.In order to find out what is really happening, set a breakpoint on the TSANreport in GDB using the following incantation: $ gdb -ex 'set disable-randomization off' -ex 'b __tsan::PrintReport' ./some-test Generating code coverage reportsIn order to generate a code coverage report, you must use the following flags: $ mkdir -p build/coverage$ cd build/coverage$ CC=../../thirdparty/clang-toolchain/bin/clang \ CXX=../../thirdparty/clang-toolchain/bin/clang++ \ cmake -DKUDU_GENERATE_COVERAGE=1 ../..$ make -j4$ ctest -j4 This will generate the code coverage files with extensions .gcno and .gcda. You can thenuse a tool like $ cd build/coverage$ mkdir cov_html$ ../../thirdparty/installed/common/bin/gcovr \ --gcov-executable=$(pwd)/../../build-support/llvm-gcov-wrapper \ --html --html-details -o cov_html/coverage.html Then open Running lint checksKudu uses cpplint.py from Google to enforce coding style guidelines. You can run thelint checks via cmake using the $ make ilint This will scan any file which is dirty in your working tree, or changed since the lastgerrit-integrated upstream change in your git log. If you really want to do a fullscan of the source tree, you may use the Running clang-tidy checksKudu also uses the clang-tidy tool from LLVM to enforce coding styleguidelines. You can run the tidy checks via cmake using the $ make tidy This will scan any changes in the latest commit in the local tree. At the timeof writing, it will not scan any changes that are not locally committed. Running include-what-you-use (IWYU) checksKudu uses the IWYUtool to keep the set of headers in the C++ source files consistent. For moreinformation on what consistent means, seeWhy IWYU. You can run the IWYU checks via cmake using the $ make iwyu This will scan any file which is dirty in your working tree, or changed since the lastgerrit-integrated upstream change in your git log. If you want to run against a specific file, or against all files, you can use the $ ./build-support/iwyu.py See the output of Building Kudu documentationKudu’s documentation is written in asciidoc and lives in the docs subdirectory. To build the documentation (this is primarily useful if you would like toinspect your changes before submitting them to Gerrit), use the $ make docs This will invoke Updating the Kudu web site documentationTo update the documentation that is integrated into the Kudu web site,including Java and C++ client API documentation, you may run the followingcommand: $ ./docs/support/scripts/make_site.sh This script will use your local Git repository to check out a shallow clone ofthe 'gh-pages' branch and use You can proceed to commit the changes in the pages repository and send a codereview for your changes. In the future, this step may be automated wheneverchanges are checked into the main Kudu repository. After making changes to the Deploying changes to the Apache Kudu web siteWhen the documentation is updated on the git checkout gh-pagesgit fetch origingit merge --ff-only origin/gh-pages./site_tool proof # Check for broken links (takes a long time to run)./site_tool publish # Generate the static HTML for the site.cd _publish && git push # Update the live web site.
Improving build timesCaching build outputThe kudu build is compatible with ccache. Simply install your distro’s ccache package,prepend /usr/lib/ccache to your Improving linker speedOne of the major time sinks in the Kudu build is linking. GNU ld is historicallyquite slow at linking large C++ applications. The alternative linker Note that gold doesn’t handle weak symbol overrides properly (seethis bug report for details).As such, it cannot be used with shared objects (see below) because it’ll causetcmalloc’s alternative malloc implementation to be ignored. Building Kudu with dynamic linkingKudu can be built into shared objects, which, when used with ccache, can result in adramatic build time improvement in the steady state. Even after a $ cmake -DKUDU_LINK=dynamic ../.. Subsequent builds will create shared objects instead of archives and use them whenlinking the kudu binaries and unit tests. The full range of options for
Developing Kudu in EclipseEclipse can be used as an IDE for Kudu. To generate Eclipse project files, run: $ mkdir -p <sibling directory to source tree>$ cd <sibling directory to source tree>$ rm -rf CMakeCache.txt CMakeFiles/$ cmake -G "Eclipse CDT4 - Unix Makefiles" -DCMAKE_CXX_COMPILER_ARG1=-std=c++11 <source tree> When the Eclipse generator is run in a subdirectory of the source tree, theresulting project is incomplete. That’s why it’s recommended to use a directorythat’s a sibling to the source tree. See [1] for more details. It’s critical that CMakeCache.txt be removed prior to running the generator,otherwise the extra Eclipse generator logic (the CMakeFindEclipseCDT4.make module)won’t run and standard system includes will be missing from the generated project. Thanks to [2], the Eclipse generator ignores the By default, the Eclipse CDT indexer will index everything under the kudu/source tree. It tends to choke on certain complicated source files withinthirdparty. In CDT 8.7.0, the indexer will generate so many errors that it’llexit early, causing many spurious syntax errors to be highlighted. In olderversions of CDT, it’ll spin forever. Either way, these complicated source files must be excluded from indexing. To dothis, right click on the project in the Project Explorer and select Properties. Inthe dialog box, select "C/C++ Project Paths", select the Source tab, highlight"Exclusion filter: (None)", and click "Edit…". In the new dialog box, click"Add Multiple…". Select every subdirectory inside thirdparty except installed.Click OK all the way out and rebuild the project index by right clicking the projectin the Project Explorer and selecting Index → Rebuild. With this exclusion, the only false positives (shown as "red squigglies") thatCDT presents appear to be in atomicops functions ( Another way to approach enormous source code indexing in Ecplise is to get rid ofunnecessary source code in "thirdparty/src" directory right after building codeand before opening project in Eclipse. You can remove all source code excepthadoop, hive and sentry directories.Additionally, if you encounter red squigglies in code editor due toEclipse’s poor macro discovery, you may need to provide Eclipse with preprocessormacros values, which it could not extract during auto-discovery.Go to "Project Explorer" → "Properties" → "C/C General" ->"Preprocessor Include Paths, Macros, etc" -> "Entries" tab -> Language "GNU C" →Setting Entries "CDT User Setting Entries" → button "Add"→ choose "Preprocessor Macro" [3] Another Eclipse annoyance stems from the "[Targets]" linked resource that Eclipsegenerates for each unit test. These are probably used for building within Eclipse,but one side effect is that nearly every source file appears in the indexer twice:once via a target and once via the raw source file. To fix this, simply delete the[Targets] linked resource via the Project Explorer. Doing this should have no effecton writing code, though it may affect your ability to build from within Eclipse. |
请发表评论