-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add optimize * fix error of clang * update README * fix code style
- Loading branch information
Showing
36 changed files
with
1,145 additions
and
1,467 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
bazel_dep(name = 'babylon', version = '1.4.1') | ||
bazel_dep(name = 'babylon', version = '1.4.2') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
bazel_dep(name = 'babylon', version = '1.4.1') | ||
bazel_dep(name = 'babylon', version = '1.4.2') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
bazel_dep(name = 'babylon', version = '1.4.1') | ||
bazel_dep(name = 'brpc', version = '1.10.0.bcr.1') | ||
bazel_dep(name = 'babylon', version = '1.4.2') | ||
bazel_dep(name = 'brpc', version = '1.11.0') | ||
bazel_dep(name = 'yaml-cpp', version = '0.8.0') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
7.3.2 | ||
7.4.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,18 @@ | ||
bazel_dep(name = 'babylon', version = '1.4.1') | ||
bazel_dep(name = 'brpc', version = '1.9.0.bcr.1') | ||
bazel_dep(name = 'babylon', version = '1.4.2') | ||
bazel_dep(name = 'brpc', version = '1.11.0') | ||
bazel_dep(name = 'tcmalloc', version = '0.0.0-20240411-5ed309d') | ||
single_version_override(module_name = 'protobuf', version = '25.3.arenastring') | ||
|
||
single_version_override(module_name = 'rules_fuzzing', version = '0.5.1') | ||
#single_version_override(module_name = 'protobuf', version = '28.3') | ||
single_version_override(module_name = 'protobuf', version = '28.3.arenastring') | ||
|
||
archive_override(module_name = 'brpc', | ||
urls = ['https://github.com/apache/brpc/archive/30a56dd153010c0be88d7c197712e5b95843ff9c.zip'], | ||
integrity = 'sha256-94aE0H4NZo72DSB0wtq6YlMZc9fOpGAlK4QHgG0FvXg=', | ||
strip_prefix = 'brpc-30a56dd153010c0be88d7c197712e5b95843ff9c', | ||
) | ||
|
||
local_path_override( | ||
module_name = 'babylon', | ||
path = '../..', | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
**[[简体中文]](README.zh-cn.md)** | ||
|
||
# Use Arena for brpc | ||
|
||
Before invoking a user's service, [brpc](https://github.com/apache/brpc) needs to construct instances of `Request` and `Response` internally, as well as perform corresponding serialization and deserialization operations. By default, it uses dynamic heap memory allocation. For complex structures, the allocation and deallocation of memory, along with the construction and destruction of `Message` structures, can lead to noticeable overhead. | ||
|
||
Since version 3.x, [Protobuf](https://github.com/protocolbuffers/protobuf) has introduced [Arena](https://protobuf.dev/reference/cpp/arenas) allocation, which enables aggregated allocation and deallocation for complex structures. More recent versions of [brpc](https://github.com/apache/brpc) also support the [Protobuf arena](https://github.com/apache/brpc/blob/master/docs/cn/server.md#protobuf-arena) component. Based on this, further acceleration for `string` members can be achieved by applying [arenastring](../../docs/arenastring.zh-cn.md). | ||
|
||
In addition to using native [Arena](https://protobuf.dev/reference/cpp/arenas), you can also employ [babylon::SwissMemoryResource](../../docs/reusable/memory_resource.zh-cn.md#swissmemoryresource) for memory pool acceleration. [babylon::SwissMemoryResource](../../docs/reusable/memory_resource.zh-cn.md#swissmemoryresource) enables further flexibility through a customizable fixed-size paging reuse mechanism. | ||
|
||
## Performance Demonstration | ||
|
||
CPU: AMD EPYC 7W83 64-Core Processor, taskset 0-3 core | ||
|
||
QPS: 800 | ||
|
||
- Default (mode: 0) | ||
- latency_percentiles: "[2213,2523,3232,3670]" | ||
- process_cpu_usage : 1.172 | ||
- process_memory_resident : 44978722 | ||
- Arena (mode: 1) | ||
- latency_percentiles: "[1318,1490,1794,1984]" | ||
- process_cpu_usage : 0.702 | ||
- process_memory_resident : 41421824 | ||
- Arena & ArenaString (mode: 1, arenastring patch) | ||
- latency_percentiles: "[1055,1196,1416,1583]" | ||
- process_cpu_usage : 0.572 | ||
- process_memory_resident : 39732770 | ||
- SwissMemoryResource & ArenaString (mode: 2, arenastring patch) | ||
- latency_percentiles: "[1006,1139,1341,1478]" | ||
- process_cpu_usage : 0.551 | ||
- process_memory_resident : 44763136 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
README.zh-cn.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
**[[English]](README.en.md)** | ||
|
||
# Use arena for brpc | ||
|
||
[brpc](https://github.com/apache/brpc)在调用用户的service前,需要在内部先完成Request和Response的实例构建,并在service前后执行对应的正反序列化。默认采用动态堆内存分配模式创建,对于比较复杂的结构,内存分配释放和Message结构的构建和析构可能也会带来可见的开销。 | ||
|
||
[Protobuf](https://github.com/protocolbuffers/protobuf)在3.x之后增加了[Arena](https://protobuf.dev/reference/cpp/arenas)分配功能,针对复杂结构提供了聚集分配和释放能力。较新版本的[brpc](https://github.com/apache/brpc)也提供了[Protobuf arena](https://github.com/apache/brpc/blob/master/docs/cn/server.md#protobuf-arena)组件进行支持。在这些基础上,通过应用[arenastirng](../../docs/arenastring.zh-cn.md)可以针对string成员实现进一步加速。 | ||
|
||
除了使用原生的[Arena](https://protobuf.dev/reference/cpp/arenas),也可以使用[babylon::SwissMemoryResource](../../docs/reusable/memory_resource.zh-cn.md#swissmemoryresource)实现内存池加速。[babylon::SwissMemoryResource](../../docs/reusable/memory_resource.zh-cn.md#swissmemoryresource)通过可定制的定长分页重用机制,可以进一步提升灵活性。 | ||
|
||
## 性能演示 | ||
|
||
CPU: AMD EPYC 7W83 64-Core Processor, taskset 0-3 core | ||
|
||
QPS: 800 | ||
|
||
- Default (mode: 0) | ||
- latency_percentiles: "[2213,2523,3232,3670]" | ||
- process_cpu_usage : 1.172 | ||
- process_memory_resident : 44978722 | ||
- Arena (mode: 1) | ||
- latency_percentiles: "[1318,1490,1794,1984]" | ||
- process_cpu_usage : 0.702 | ||
- process_memory_resident : 41421824 | ||
- Arena & ArenaString (mode: 1, arenastring patch) | ||
- latency_percentiles: "[1055,1196,1416,1583]" | ||
- process_cpu_usage : 0.572 | ||
- process_memory_resident : 39732770 | ||
- SwissMemoryResource & ArenaString (mode: 2, arenastring patch) | ||
- latency_percentiles: "[1006,1139,1341,1478]" | ||
- process_cpu_usage : 0.551 | ||
- process_memory_resident : 44763136 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/sh | ||
set -ex | ||
|
||
bazel build --registry=https://bcr.bazel.build --registry=https://baidu.github.io/babylon/registry --compilation_mode=opt --cxxopt=-std=c++17 client server | ||
bazel build --registry=file:///home/oathdruid/src/babylon/registry --registry=https://bcr.bazel.build --registry=https://baidu.github.io/babylon/registry --compilation_mode=opt --cxxopt=-std=c++17 client server server_babylon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.