Skip to content

Commit aa9c6a3

Browse files
committed
perfomance tuning
tcmalloc minimal snmalloc use-snmalloc(x86_64 musl)(not use-snmalloc-static)
1 parent 3d425fb commit aa9c6a3

File tree

7 files changed

+51
-52
lines changed

7 files changed

+51
-52
lines changed

.cargo/config.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ build-std-features = ["panic_immediate_abort"]
1111
#CXX_x86_64_unknown_linux_musl = "zig c++"
1212
#CC_x86_64_unknown_linux_musl="zig cc"
1313
#AR_x86_64_unknown_linux_musl="zig ar"
14-
CC_x86_64_unknown_linux_musl="clang"
15-
CXX_x86_64_unknown_linux_musl = "clang++"
14+
#CC_x86_64_unknown_linux_musl="clang"
15+
#CXX_x86_64_unknown_linux_musl = "clang++"
1616

1717
[target.x86_64-unknown-linux-gnu]
1818
#linker = "gcc"
@@ -33,7 +33,7 @@ rustflags = [
3333
"-C", "link-args=-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC -fpic -fPIE -fpie -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections",
3434
]
3535
[target.x86_64-unknown-linux-musl]
36-
#linker = "zig"
36+
#linker = "musl-gcc"
3737
rustflags = [
3838
#"-C", "linker-flavor=gcc", "-C", "link-arg=-target", "-C", "link-arg=x86_64-linux-musl",
3939
"-Ctarget-feature=+crt-static",
@@ -49,6 +49,7 @@ rustflags = [
4949
"-C", "embed-bitcode=y",
5050
"-C", "codegen-units=1",
5151
"-C", "opt-level=3",
52+
#"-C", "link-args=-fPIC -fpic -fPIE -fpie -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections",
5253
"-C", "link-args=-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC -fpic -fPIE -fpie -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections",
5354
#"-C", "link-args=-Wp,-D_FORTIFY_SOURCE=2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC -fpic -fPIE -fpie -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections",
5455
#"-C", "link-args=-Wp,-D_FORTIFY_SOURCE=2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC -fpic -fPIE -fpie -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections",
@@ -88,6 +89,7 @@ rustflags = [
8889
"-C", "codegen-units=1",
8990
"-C", "opt-level=3",
9091
"-C", "link-args=-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC -fpic -fPIE -fpie -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections",
92+
#"-C", "link-args=-fPIC -fpic -fPIE -fpie -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections",
9193
#"-C", "link-args=-Wp,-D_FORTIFY_SOURCE=2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC -fpic -fPIE -fpie -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections",
9294
]
9395

.github/workflows/release.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,33 +206,33 @@ jobs:
206206
run: |
207207
case "${{ join(matrix.targets) }}" in
208208
*arm*linux*musl*)
209-
echo "features=use-snmalloc-static" >> $GITHUB_OUTPUT
209+
echo "features=use-snmalloc" >> $GITHUB_OUTPUT
210210
#echo "features=use-auto-allocator" >> $GITHUB_OUTPUT
211211
# cargo-dist=cargo
212212
echo "cargo=cargo" >> $GITHUB_OUTPUT
213213
;;
214214
*aarch64*linux*musl*)
215-
echo "features=use-snmalloc-static" >> $GITHUB_OUTPUT
215+
echo "features=use-snmalloc" >> $GITHUB_OUTPUT
216216
#echo "features=use-auto-allocator" >> $GITHUB_OUTPUT
217217
# cargo-dist=cargo
218218
echo "cargo=cargo" >> $GITHUB_OUTPUT
219219
;;
220220
*linux*musl*)
221221
# x86_64 musl zigbuild is best.(snmalloc or mimalloc or auto-allocator)
222-
echo "features=use-snmalloc-static" >> $GITHUB_OUTPUT
222+
echo "features=use-snmalloc" >> $GITHUB_OUTPUT
223223
#echo "features=use-auto-allocator" >> $GITHUB_OUTPUT
224224
echo "cargo=cargo-zigbuild" >> $GITHUB_OUTPUT
225225
;;
226226
*aarch64*linux*)
227-
echo "features=use-snmalloc-static" >> $GITHUB_OUTPUT
227+
#echo "features=use-snmalloc" >> $GITHUB_OUTPUT
228228
#echo "features=use-jemalloc" >> $GITHUB_OUTPUT
229-
#echo "features=use-auto-allocator" >> $GITHUB_OUTPUT
229+
echo "features=use-auto-allocator" >> $GITHUB_OUTPUT
230230
echo "cargo=cargo" >> $GITHUB_OUTPUT
231231
;;
232232
*arm*linux*)
233-
echo "features=use-snmalloc-static" >> $GITHUB_OUTPUT
233+
#echo "features=use-snmalloc" >> $GITHUB_OUTPUT
234234
#echo "features=use-jemalloc" >> $GITHUB_OUTPUT
235-
#echo "features=use-auto-allocator" >> $GITHUB_OUTPUT
235+
echo "features=use-auto-allocator" >> $GITHUB_OUTPUT
236236
echo "cargo=cargo" >> $GITHUB_OUTPUT
237237
;;
238238
*linux*)
@@ -251,7 +251,7 @@ jobs:
251251
echo "cargo=cargo-xwin" >> $GITHUB_OUTPUT
252252
;;
253253
*)
254-
echo "features=use-snmalloc-static" >> $GITHUB_OUTPUT
254+
echo "features=use-snmalloc" >> $GITHUB_OUTPUT
255255
#echo "features=use-auto-allocator" >> $GITHUB_OUTPUT
256256
echo "cargo=cargo" >> $GITHUB_OUTPUT
257257
;;

Cargo.lock

Lines changed: 12 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ members = [
77
resolver = "3"
88

99
[workspace.package]
10-
version = "0.6.27"
10+
version = "0.6.28"
1111
authors = ["Masato TOYOSHIMA", "phoepsilonix <phoepsilonix@gmail.com>"]
1212
edition = "2024"
1313
rust-version = "1.90.0"
@@ -43,7 +43,7 @@ hashbrown = { version = "^0.16", default-features = false, features = [ "allocat
4343
#auto-allocator = { version = "*", features = [], git = "https://github.com/phoepsilonix/auto-allocator.git" }
4444
auto-allocator = { version = "*", features = ["_no_info"] }
4545

46-
snmalloc-rs = { version = "0.3", features = ["lto"] }
46+
snmalloc-rs = { version = "0.3", features = ["default", "lto"] }
4747
mimalloc = { version = "0.1.48" }
4848

4949
smmalloc = { version = "7.6.4" }
@@ -92,6 +92,9 @@ kanaria = { git = "https://github.com/samunohito/kanaria.git", rev = "c98ea3a9af
9292
auto-allocator = { git = "https://github.com/phoepsilonix/auto-allocator.git", rev = "c0c9fbb23dbe2cb49f22f532ae9793fc1703353b" } # mimalloc(_no_info)
9393
#auto-allocator = { git = "https://github.com/phoepsilonix/auto-allocator.git", rev = "8546dae3ce2d860db3644b177e8f67df1dd7fce5" } # mimalloc-rust
9494
snmalloc-rs = { git = "https://github.com/phoepsilonix/snmalloc-rs.git", rev = "a4a31eb3436a2183c0ed4da95f578c0f570ce02a" }
95+
tcmalloc = { git = "https://github.com/phoepsilonix/tcmalloc-rs.git", rev = "7c38e8db98472e5860caa0ca6c30ad88df19f6e6" }
96+
#tcmalloc = { path = "../tcmalloc-rs" }
97+
#snmalloc-rs = { path = "../snmalloc-rs" }
9598

9699
[dependencies]
97100
lib-dict-to-mozc = { workspace = true }
@@ -138,8 +141,8 @@ use-tcmalloc = ["dep:tcmalloc"]
138141
use-tcmalloc-static = ["tcmalloc/bundled"]
139142
use-auto-allocator = ["dep:auto-allocator"]
140143
use-snmalloc = ["snmalloc-rs/lto"]
141-
use-snmalloc-static = ["snmalloc-rs/lto", "snmalloc-rs/static-link"]
142-
use-snmalloc-cc = ["snmalloc-rs/build_cc"]
144+
use-snmalloc-static = ["snmalloc-rs", "snmalloc-rs/lto", "snmalloc-rs/static-link"]
145+
use-snmalloc-cc = ["snmalloc-rs/lto", "snmalloc-rs/build_cc"]
143146

144147
use-mimalloc = ["dep:mimalloc"]
145148
use-mimalloc-rs = ["dep:mimalloc-rust"]

Cross.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build]
22
default-target = "x86_64-unknown-linux-gnu" # use this target if none is explicitly provided
3-
xargo = false # enable the use of xargo by default
4-
zig = true # do not use zig cc for the builds
5-
std = false
3+
#xargo = false # enable the use of xargo by default
4+
#zig = false # do not use zig cc for the builds
5+
#std = true

README.md

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ RUSTFLAGS="" cargo build --release -F use-tcmalloc-static
130130
```sh
131131
sudo pacman install gperftools xz libunwind --needed
132132
```
133-
## tcmalloc(static)
134-
* 実行時にliblzma.so, libunwind.soが必要。
133+
## tcmalloc(static,minimal)
135134
```sh
136135
RUSTFLAGS="" cargo build --release -F use-tcmalloc-static
137136
```
@@ -163,12 +162,13 @@ RUSTFLAGS="" cargo build --release -F use-jemalloc
163162
```
164163

165164
## リリース版の設定
166-
### v0.6.27
165+
### v0.6.28
167166
| プラットフォーム | OS | メモリアロケータ |
168167
|----------------|----|----------------|
169-
| x86_64(gnu) | Linux | tcmalloc(static) |
170-
| x86_64(musl) | Linux | snmalloc(static)(zigbuild) |
171-
| aarch64,armv7 | Linux | snmalloc(static)(zigbuild) |
168+
| x86_64(gnu) | Linux | tcmalloc(static,minimal) |
169+
| x86_64(musl) | Linux | snmalloc(zigbuild) |
170+
| aarch64,armv7(gnu) | Linux | auto-allocator(mimalloc)(zigbuild) |
171+
| aarch64,armv7(musl) | Linux | snmalloc(zigbuild) |
172172
| x86_64, aarch64 | Windows | snmalloc(cargo-xwin) |
173173
| x86_64, aarch64 | Mac | snmalloc |
174174

@@ -215,16 +215,6 @@ sudo apt install libgoogle-perftools-dev liblzma-dev libunwind-dev
215215
sudo pacman -S gperftools xz libunwind --needed
216216
```
217217

218-
#### use-tcmalloc-static features
219-
##### Ubuntu, Debian
220-
```sh
221-
sudo apt install liblzma-dev libunwind-dev
222-
```
223-
##### Arch, Manjaro
224-
```sh
225-
sudo pacman -S xz libunwind --needed
226-
```
227-
228218
### ダウンロード
229219
https://github.com/phoepsilonix/dict-to-mozc/releases からダウンロード
230220
```sh

build.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,24 @@ fn link_tcmalloc_static() {
5757
// println!("cargo:rustc-link-lib=static=unwind");
5858

5959
// Static link
60+
6061
{
61-
let lib = "tcmalloc";
62+
let lib = "tcmalloc_minimal";
6263
println!("cargo:rustc-link-lib=static={}", lib);
6364
}
64-
for lib in ["stdc++", "unwind", "lzma"] {
65+
66+
//for lib in ["stdc++", "unwind", "lzma"] {
67+
68+
{
69+
let lib = "stdc++";
70+
//for lib in ["stdc++"] {
6571
println!("cargo:rustc-link-lib={}", lib);
6672
}
6773
}
6874

6975
fn link_snmalloc_linux() {
7076
// snmalloc (for Linux)
77+
/*
7178
let static_link = std::env::var("CARGO_FEATURE_USE_SNMALLOC_STATIC_LINK").is_ok();
7279
//if target_env == "musl" {
7380
if static_link {
@@ -76,6 +83,7 @@ fn link_snmalloc_linux() {
7683
// println!("cargo:rustc-link-lib=static=snmallocshim-rust");
7784
println!("cargo:rustc-link-lib=snmallocshim-rust");
7885
}
86+
*/
7987
}
8088

8189
fn link_snmalloc_windows() {

0 commit comments

Comments
 (0)