guodongxiaren commented on a change in pull request #1515: URL: https://github.com/apache/incubator-brpc/pull/1515#discussion_r687369877
########## File path: docs/cn/getting_started.md ########## @@ -208,135 +211,134 @@ $ sh config_brpc.sh --headers=.. --libs=.. $ make ``` -### Compile brpc with cmake -Same with [here](#compile-brpc-with-cmake) +### 使用cmake编译brpc +参考[这里](#使用cmake编译brpc) ## MacOS -Note: In the same running environment, the performance of the current Mac version is about 2.5 times worse than the Linux version. If your service is performance-critical, do not use MacOS as your production environment. +注意:在相同运行环境下,当前Mac版brpc的性能比Linux版差2.5倍。如果你的服务是性能敏感的,请不要使用MacOs作为你的生产环境。 -### Prepare deps +### 依赖准备 -Install common deps: +安装通用依赖: ```shell brew install openssl git gnu-getopt coreutils ``` -Install [gflags](https://github.com/gflags/gflags), [protobuf](https://github.com/google/protobuf), [leveldb](https://github.com/google/leveldb): +安装[gflags](https://github.com/gflags/gflags),[protobuf](https://github.com/google/protobuf),[ [leveldb](https://github.com/google/leveldb): ```shell brew install gflags protobuf leveldb ``` -If you need to enable cpu/heap profilers in examples: +如果你要在样例中启用cpu/heap的profiler: ```shell brew install gperftools ``` -If you need to run tests, download and compile googletest (which is not compiled yet): +如果你要运行测试,那么要安装并编译googletest(它没有被默认编译): ```shell git clone https://github.com/google/googletest -b release-1.10.0 && cd googletest/googletest && mkdir build && cd build && cmake -DCMAKE_CXX_FLAGS="-std=c++11" .. && make ``` -After the compilation, copy include/ and lib/ into /usr/local/include and /usr/local/lib respectively to expose gtest to all apps +在编译完成后,复制include/和lib/目录到/usr/local/include和/usr/local/lib目录中,以便于让所有应用都能使用gtest。 -### Compile brpc with config_brpc.sh -git clone brpc, cd into the repo and run +### 使用config_brpc.sh编译brpc +git克隆brpc,进入到项目目录然后运行: ```shell $ sh config_brpc.sh --headers=/usr/local/include --libs=/usr/local/lib --cc=clang --cxx=clang++ $ make ``` -To not link debugging symbols, add `--nodebugsymbols` and compiled binaries will be much smaller. +不想链接调试符号,添加选项`--nodebugsymbols`,然后编译将会得到更轻量的二进制文件。 -To use brpc with glog, add `--with-glog`. +使用glog版的brpc,添加选项`--with-glog`。 -To enable [thrift support](../en/thrift.md), install thrift first and add `--with-thrift`. +要启用[thrift 支持](../en/thrift.md),首先安装thrift并且添加选项`--with-thrift`。 -**Run example** +**运行样例** ```shell $ cd example/echo_c++ $ make $ ./echo_server & $ ./echo_client ``` +上述操作会链接brpc的静态库到样例中,如果你想链接brpc的共享库,请依次执行:`make clean`和`LINK_SO=1 make` -Examples link brpc statically, if you need to link the shared version, `make clean` and `LINK_SO=1 make` - -**Run tests** +**运行测试** ```shell $ cd test $ make $ sh run_tests.sh ``` -### Compile brpc with cmake -Same with [here](#compile-brpc-with-cmake) +### 使用cmake编译brpc +参考[这里](#使用cmake编译brpc) -# Supported deps +# 支持的依赖 ## GCC: 4.8-7.1 -c++11 is turned on by default to remove dependencies on boost (atomic). +c++11被默认启用,以去除去boost的依赖(比如atomic)。 -The over-aligned issues in GCC7 is suppressed temporarily now. +GCC7中over-aligned的问题暂时被禁止。 -Using other versions of gcc may generate warnings, contact us to fix. +使用其他版本的gcc可能会产生编译警告,请联系我们予以修复。 -Adding `-D__const__=` to cxxflags in your makefiles is a must to avoid [errno issue in gcc4+](thread_local.md). +请在makefile中给cxxflags增加`-D__const__=`选项以避免[gcc4+中的errno问题](thread_local.md). ## Clang: 3.5-4.0 -no known issues. +无已知问题。 ## glibc: 2.12-2.25 -no known issues. +无已知问题。 ## protobuf: 2.4+ -Be compatible with pb 3.x and pb 2.x with the same file: -Don't use new types in proto3 and start the proto file with `syntax="proto2";` -[tools/add_syntax_equal_proto2_to_all.sh](https://github.com/brpc/brpc/blob/master/tools/add_syntax_equal_proto2_to_all.sh)can add `syntax="proto2"` to all proto files without it. +同一个文件兼容pb 3.x版本和pb 2.x版本: +不要使用proto3新增的类型,并且在proto文件的起始位置添加`syntax=proto2;`声明。 +[tools/add_syntax_equal_proto2_to_all.sh](https://github.com/brpc/brpc/blob/master/tools/add_syntax_equal_proto2_to_all.sh)这个脚本可以给所有没有这行声明的proto文件添加`syntax="proto2"`声明。 -Arena in pb 3.x is not supported yet. +pb 3.x中的Arena至今没被支持。 ## gflags: 2.0-2.2.1 -no known issues. +无已知问题。 ## openssl: 0.97-1.1 -required by https. +被https功能需要。 ## tcmalloc: 1.7-2.5 -brpc does **not** link [tcmalloc](http://goog-perftools.sourceforge.net/doc/tcmalloc.html) by default. Users link tcmalloc on-demand. +brpc默认**不**链接 [tcmalloc](http://goog-perftools.sourceforge.net/doc/tcmalloc.html)。用户按需要链接tcmalloc。 -Comparing to ptmalloc embedded in glibc, tcmalloc often improves performance. However different versions of tcmalloc may behave really differently. For example, tcmalloc 2.1 may make multi-threaded examples in brpc perform significantly worse(due to a spinlock in tcmalloc) than the one using tcmalloc 1.7 and 2.5. Even different minor versions may differ. When you program behave unexpectedly, remove tcmalloc or try another version. +和glibc内置的ptmalloc相比,tcmalloc通常能提升性能。然而不同版本的tcmalloc可能表现迥异。例如:tcmalloc 2.1与 tcmalloc 1.7和2.5相比,可能会让brpc的多线程样例性能显著恶化(tcmalloc中的一个自旋锁导致的)。甚至不同的小版本号之间变现也可能不同。当你的程序表现不符合预期的时候,移除tcmalloc然后尝试其他版本。 -Code compiled with gcc 4.8.2 and linked to a tcmalloc compiled with earlier GCC may crash or deadlock before main(), E.g: +用gcc4.8.2编译然后链接更早版本GCC编译的tcmalloc,可能会让程序中main()函数之前挂掉或者死锁,例如:  -When you meet the issue, compile tcmalloc with the same GCC. +当你遇到这个问题的时候,请用同一个GCC重新编译tcmalloc。 -Another common issue with tcmalloc is that it does not return memory to system as early as ptmalloc. So when there's an invalid memory access, the program may not crash directly, instead it crashes at a unrelated place, or even not crash. When you program has weird memory issues, try removing tcmalloc. +另外一个使用tcmalloc的常见问题是,它不会像 ptmalloc一样及时地归还内存给系统。因此当有一个无效的内存访问的时候,程序可能不会直接挂掉,取而代之的是它可能在一个不相关的地方挂掉,或者甚至一直不挂掉。当你的程序出现怪异的内存问题的时候,尝试移除tcmalloc。 -If you want to use [cpu profiler](cpu_profiler.md) or [heap profiler](heap_profiler.md), do link `libtcmalloc_and_profiler.a`. These two profilers are based on tcmalloc.[contention profiler](contention_profiler.md) does not require tcmalloc. +如果你要使用[cpu profiler](cpu_profiler.md)或[heap profiler](heap_profiler.md),要链接`libtcmalloc_and_profiler.a`。这两个 profiler都是基于tcmalloc的。而[contention profiler](contention_profiler.md)不需要tcmalloc。 -When you remove tcmalloc, not only remove the linkage with tcmalloc but also the macro `-DBRPC_ENABLE_CPU_PROFILER`. +当你移除tcmalloc的时候,不仅要移除tcmalloc的链接,也要移除宏`-DBRPC_ENABLE_CPU_PROFILER`。 ## glog: 3.3+ -brpc implements a default [logging utility](../../src/butil/logging.h) which conflicts with glog. To replace this with glog, add *--with-glog* to config_brpc.sh or add `-DWITH_GLOG=ON` to cmake. +brpc实现了一个默认的[日志功能](../../src/butil/logging.h)它和glog冲突。要替换成glog,可以给config_brpc.sh增加*--with-glog*选项或者给cmake增加`-DWITH_GLOG=ON`选项。 ## valgrind: 3.8+ -brpc detects valgrind automatically (and registers stacks of bthread). Older valgrind(say 3.2) is not supported. +brpc会自动检测valgrind(然后注册bthread的栈)。不支持老版本的valgrind(比如3.2)。 ## thrift: 0.9.3-0.11.0 -no known issues. +无已知问题。 -# Track instances +# 实例追踪 -We provide a program to help you to track and monitor all brpc instances. Just run [trackme_server](https://github.com/brpc/brpc/tree/master/tools/trackme_server/) somewhere and launch need-to-be-tracked instances with -trackme_server=SERVER. The trackme_server will receive pings from instances periodically and print logs when it does. You can aggregate instance addresses from the log and call builtin services of the instances for further information. +我们提供了一个程序去帮助你追踪和监控所有brpc实例。 只需要现在某处运行 [trackme_server](https://github.com/brpc/brpc/tree/master/tools/trackme_server/) 然后再带着 -trackme_server=SERVER参数启动需要被追踪的实例。trackme_server将从实例周期性地收到ping消息然后打印日志。您可以从日志中聚合实例地址,并调用实例的内置服务以获取更多信息。 Review comment: ok,改了 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
