Skip to content

Commit 1583844

Browse files
authored
Try #112:
2 parents a80de1f + ed114a5 commit 1583844

File tree

18 files changed

+151
-20
lines changed

18 files changed

+151
-20
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ jobs:
7575
- name: Building release version
7676
run:
7777
cargo build -p rusty_demo -Z build-std=std,core,alloc,panic_abort --target x86_64-unknown-hermit --release
78+
- name: Building release version (LTO)
79+
run:
80+
cargo build -p rusty_demo --profile release-lto -Z unstable-options -Z build-std=std,core,alloc,panic_abort --target x86_64-unknown-hermit
7881
env:
7982
RUSTFLAGS: -Clinker-plugin-lto
8083
- name: Build loader (unix)
@@ -98,6 +101,9 @@ jobs:
98101
- name: Test release version
99102
run:
100103
qemu-system-x86_64 -display none -smp 1 -m 64M -serial stdio -kernel loader/target/x86_64-unknown-hermit-loader/debug/rusty-loader -initrd target/x86_64-unknown-hermit/release/rusty_demo -cpu qemu64,apic,fsgsbase,rdtscp,xsave,fxsr,rdrand
104+
- name: Test release version (LTO)
105+
run:
106+
qemu-system-x86_64 -display none -smp 1 -m 64M -serial stdio -kernel loader/target/x86_64-unknown-hermit-loader/debug/rusty-loader -initrd target/x86_64-unknown-hermit/release-lto/rusty_demo -cpu qemu64,apic,fsgsbase,rdtscp,xsave,fxsr,rdrand
101107
- name: Build httpd with DHCP support
102108
run:
103109
cargo build --manifest-path examples/httpd/Cargo.toml --features dhcpv4

.gitlab-ci.yml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,50 @@ variables:
3434
prepare:docker:
3535
<<: *prepare_docker
3636

37+
build:instrument:
38+
stage: build
39+
image: ${CI_REGISTRY_IMAGE}
40+
script:
41+
- RUSTFLAGS="-Z instrument-mcount" cargo build -p rusty_demo --release --features=instrument
42+
artifacts:
43+
paths:
44+
- target/x86_64-unknown-hermit/release/matrix_multiplcation
45+
3746
build:demo:
3847
stage: build
3948
image: ${CI_REGISTRY_IMAGE}
4049
script:
4150
- cargo build -p rusty_demo
42-
- RUSTFLAGS="-Clinker-plugin-lto" cargo build -p rusty_demo --release
51+
- cargo build -p rusty_demo --release
52+
- RUSTFLAGS="-Clinker-plugin-lto" cargo build -p rusty_demo --profile release-lto -Z unstable-options
4353
artifacts:
4454
paths:
4555
- target/x86_64-unknown-hermit/debug/rusty_demo
4656
- target/x86_64-unknown-hermit/release/rusty_demo
57+
- target/x86_64-unknown-hermit/release-lto/rusty_demo
4758

4859
build:httpd:
4960
stage: build
5061
image: ${CI_REGISTRY_IMAGE}
5162
script:
52-
- RUSTFLAGS="-Clinker-plugin-lto" cargo build --manifest-path examples/httpd/Cargo.toml --no-default-features --features pci,acpi,smoltcp,vga,dhcpv4 --release
63+
- cargo build --manifest-path examples/httpd/Cargo.toml --no-default-features --features pci,acpi,smoltcp,vga,dhcpv4 --release
5364
artifacts:
5465
paths:
5566
- target/x86_64-unknown-hermit/release/httpd
5667

68+
test:instrument:
69+
stage: test
70+
dependencies:
71+
- build:instrument
72+
image: ${CI_REGISTRY_IMAGE}
73+
script:
74+
- lscpu
75+
- kvm-ok
76+
- cargo install uhyve
77+
- uhyve -v -c 1 target/x86_64-unknown-hermit/release/matrix_multiplcation
78+
tags:
79+
- privileged
80+
5781
test:uhyve:
5882
stage: test
5983
dependencies:
@@ -67,6 +91,8 @@ test:uhyve:
6791
- uhyve -v -c 2 target/x86_64-unknown-hermit/debug/rusty_demo
6892
- uhyve -v -c 1 target/x86_64-unknown-hermit/release/rusty_demo
6993
- uhyve -v -c 2 target/x86_64-unknown-hermit/release/rusty_demo
94+
- uhyve -v -c 1 target/x86_64-unknown-hermit/release-lto/rusty_demo
95+
- uhyve -v -c 2 target/x86_64-unknown-hermit/release-lto/rusty_demo
7096
tags:
7197
- privileged
7298

@@ -86,6 +112,8 @@ test:qemu:
86112
- qemu-system-x86_64 -display none -smp 2 -m 64M -serial stdio -kernel loader/target/x86_64-unknown-hermit-loader/debug/rusty-loader -initrd target/x86_64-unknown-hermit/debug/rusty_demo -cpu qemu64,apic,fsgsbase,rdtscp,xsave,fxsr,rdrand -enable-kvm
87113
- qemu-system-x86_64 -display none -smp 1 -m 64M -serial stdio -kernel loader/target/x86_64-unknown-hermit-loader/release/rusty-loader -initrd target/x86_64-unknown-hermit/release/rusty_demo -cpu qemu64,apic,fsgsbase,rdtscp,xsave,fxsr,rdrand -enable-kvm
88114
- qemu-system-x86_64 -display none -smp 2 -m 64M -serial stdio -kernel loader/target/x86_64-unknown-hermit-loader/release/rusty-loader -initrd target/x86_64-unknown-hermit/release/rusty_demo -cpu qemu64,apic,fsgsbase,rdtscp,xsave,fxsr,rdrand -enable-kvm
115+
- qemu-system-x86_64 -display none -smp 1 -m 64M -serial stdio -kernel loader/target/x86_64-unknown-hermit-loader/release/rusty-loader -initrd target/x86_64-unknown-hermit/release-lto/rusty_demo -cpu qemu64,apic,fsgsbase,rdtscp,xsave,fxsr,rdrand -enable-kvm
116+
- qemu-system-x86_64 -display none -smp 2 -m 64M -serial stdio -kernel loader/target/x86_64-unknown-hermit-loader/release/rusty-loader -initrd target/x86_64-unknown-hermit/release-lto/rusty_demo -cpu qemu64,apic,fsgsbase,rdtscp,xsave,fxsr,rdrand -enable-kvm
89117
tags:
90118
- privileged
91119

Cargo.lock

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

Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
cargo-features = ["named-profiles"]
12
[workspace]
23
members = [
34
"hermit-abi",
@@ -14,9 +15,13 @@ exclude = ["target", "loader", "libhermit-rs"]
1415
opt-level = 3
1516
debug = false
1617
rpath = false
17-
lto = "thin"
18+
lto = false
1819
debug-assertions = false
1920

21+
[profile.release-lto]
22+
inherits = "release"
23+
lto = "thin"
24+
2025
[profile.dev]
2126
opt-level = 1 # controls the `--opt-level` the compiler builds with
2227
debug = true # controls whether the compiler passes `-C debuginfo`

benches/micro/Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
cargo-features = ["named-profiles"]
12
[package]
23
name = "micro_benchmarks"
34
version = "0.1.0"
@@ -27,15 +28,18 @@ pci = ["hermit-sys/pci"]
2728
acpi = ["hermit-sys/acpi"]
2829
fsgsbase = ["hermit-sys/fsgsbase"]
2930
smp = ["hermit-sys/smp"]
30-
instrument = ["hermit-sys/instrument"]
3131

3232
[profile.release]
3333
opt-level = 3
3434
debug = false
3535
rpath = false
36-
lto = true
36+
lto = false
3737
debug-assertions = false
3838

39+
[profile.release-lto]
40+
inherits = "release"
41+
lto = "thin"
42+
3943
[profile.dev]
4044
opt-level = 1 # controls the `--opt-level` the compiler builds with
4145
debug = true # controls whether the compiler passes `-C debuginfo`

benches/micro/rust-toolchain

Lines changed: 0 additions & 1 deletion
This file was deleted.

benches/netbench/Cargo.toml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1+
cargo-features = ["named-profiles"]
12
[package]
2-
33
name = "rust-tcp-io-perf"
44
version = "0.0.0"
55
authors = ["Lorenzo Martini <[email protected]>"]
66
readme = "README.md"
7-
87
description = "A Rust program to measure bandwidth or latency over a Rust TCP connection"
98

109
[dependencies]
@@ -27,7 +26,6 @@ acpi = ["hermit-sys/acpi"]
2726
fsgsbase = ["hermit-sys/fsgsbase"]
2827
smp = ["hermit-sys/smp"]
2928
smoltcp = ["hermit-sys/smoltcp"]
30-
instrument = ["hermit-sys/instrument"]
3129

3230
[[bin]]
3331
name = "server-bw"
@@ -49,9 +47,13 @@ path = "src/rust-tcp-latency/client.rs"
4947
opt-level = 3
5048
debug = false
5149
rpath = false
52-
lto = true
50+
lto = false
5351
debug-assertions = false
5452

53+
[profile.release-lto]
54+
inherits = "release"
55+
lto = "thin"
56+
5557
[profile.dev]
5658
opt-level = 1 # controls the `--opt-level` the compiler builds with
5759
debug = true # controls whether the compiler passes `-C debuginfo`

examples/demo/Cargo.toml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
cargo-features = ["named-profiles"]
12
[package]
23
name = "rusty_demo"
34
version = "0.1.0"
@@ -33,22 +34,30 @@ default-features = false
3334
[target.'cfg(target_os = "linux")'.dependencies]
3435
syscalls = { version = "0.2", default-features = false }
3536

37+
[dependencies.rftrace-frontend]
38+
version = "0.1.0"
39+
optional = true
40+
3641
[features]
3742
default = ["pci", "acpi", "smp"]
3843
vga = ["hermit-sys/vga"]
3944
pci = ["hermit-sys/pci"]
4045
acpi = ["hermit-sys/acpi"]
4146
fsgsbase = ["hermit-sys/fsgsbase"]
4247
smp = ["hermit-sys/smp"]
43-
instrument = ["hermit-sys/instrument"]
48+
instrument = ["hermit-sys/instrument", "rftrace-frontend"]
4449

4550
[profile.release]
4651
opt-level = 3
4752
debug = false
4853
rpath = false
49-
lto = true
54+
lto = false
5055
debug-assertions = false
5156

57+
[profile.release-lto]
58+
inherits = "release"
59+
lto = "thin"
60+
5261
[profile.dev]
5362
opt-level = 1 # controls the `--opt-level` the compiler builds with
5463
debug = true # controls whether the compiler passes `-C debuginfo`

examples/demo/src/main.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@
1313
extern crate hermit_sys;
1414
extern crate num_cpus;
1515
extern crate rayon;
16+
#[cfg(feature = "instrument")]
17+
extern crate rftrace_frontend;
1618
#[cfg(target_os = "linux")]
1719
#[macro_use]
1820
extern crate syscalls;
1921

2022
mod tests;
2123

24+
#[cfg(feature = "instrument")]
25+
use rftrace_frontend::Events;
2226
use tests::*;
2327

2428
fn test_result<T>(result: Result<(), T>) -> &'static str {
@@ -29,6 +33,11 @@ fn test_result<T>(result: Result<(), T>) -> &'static str {
2933
}
3034

3135
fn main() {
36+
#[cfg(feature = "instrument")]
37+
let events = rftrace_frontend::init(1000000, true);
38+
#[cfg(feature = "instrument")]
39+
rftrace_frontend::enable();
40+
3241
println!("Test {} ... {}", stringify!(hello), test_result(hello()));
3342
println!(
3443
"Test {} ... {}",
@@ -85,4 +94,8 @@ fn main() {
8594
stringify!(thread_creation),
8695
test_result(thread_creation())
8796
);
97+
98+
#[cfg(feature = "instrument")]
99+
rftrace_frontend::dump_full_uftrace(events, "trace", "rusty_demo", false)
100+
.expect("Saving trace failed");
88101
}

examples/demo/src/matrix_multiplication.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@
1313
extern crate hermit_sys;
1414
extern crate num_cpus;
1515
extern crate rayon;
16+
#[cfg(feature = "instrument")]
17+
extern crate rftrace_frontend;
1618
#[cfg(target_os = "linux")]
1719
#[macro_use]
1820
extern crate syscalls;
1921

2022
mod tests;
2123

24+
#[cfg(feature = "instrument")]
25+
use rftrace_frontend::Events;
2226
use tests::*;
2327

2428
fn test_result<T>(result: Result<(), T>) -> &'static str {
@@ -29,9 +33,18 @@ fn test_result<T>(result: Result<(), T>) -> &'static str {
2933
}
3034

3135
fn main() {
36+
#[cfg(feature = "instrument")]
37+
let events = rftrace_frontend::init(1000000, true);
38+
#[cfg(feature = "instrument")]
39+
rftrace_frontend::enable();
40+
3241
println!(
3342
"Test {} ... {}",
3443
stringify!(test_matmul_strassen),
3544
test_result(test_matmul_strassen())
3645
);
46+
47+
#[cfg(feature = "instrument")]
48+
rftrace_frontend::dump_full_uftrace(events, "trace", "matrix_multiplcation", false)
49+
.expect("Saving trace failed");
3750
}

examples/demo/src/pi_sequential.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@
1111

1212
#[cfg(target_os = "hermit")]
1313
extern crate hermit_sys;
14+
#[cfg(feature = "instrument")]
15+
extern crate rftrace_frontend;
1416
#[cfg(target_os = "linux")]
1517
#[macro_use]
1618
extern crate syscalls;
1719

1820
mod tests;
1921

22+
#[cfg(feature = "instrument")]
23+
use rftrace_frontend::Events;
2024
use tests::*;
2125

2226
fn test_result<T>(result: Result<(), T>) -> &'static str {
@@ -27,9 +31,18 @@ fn test_result<T>(result: Result<(), T>) -> &'static str {
2731
}
2832

2933
fn main() {
34+
#[cfg(feature = "instrument")]
35+
let events = rftrace_frontend::init(1000000, true);
36+
#[cfg(feature = "instrument")]
37+
rftrace_frontend::enable();
38+
3039
println!(
3140
"Test {} ... {}",
3241
stringify!(pi_sequential),
3342
test_result(pi_sequential(5000000))
3443
);
44+
45+
#[cfg(feature = "instrument")]
46+
rftrace_frontend::dump_full_uftrace(events, "trace", "pi_sequential", false)
47+
.expect("Saving trace failed");
3548
}

examples/hello_world/Cargo.toml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
cargo-features = ["named-profiles"]
12
[package]
23
name = "hello_world"
34
version = "0.1.0"
@@ -10,14 +11,18 @@ path = "../../hermit-sys"
1011
default-features = false
1112
features = ["with_submodule"]
1213

14+
[dependencies.rftrace-frontend]
15+
version = "0.1.0"
16+
optional = true
17+
1318
[features]
1419
default = ["pci", "acpi"]
1520
vga = ["hermit-sys/vga"]
1621
pci = ["hermit-sys/pci"]
1722
acpi = ["hermit-sys/acpi"]
1823
fsgsbase = ["hermit-sys/fsgsbase"]
1924
smp = ["hermit-sys/smp"]
20-
instrument = ["hermit-sys/instrument"]
25+
instrument = ["hermit-sys/instrument", "rftrace-frontend"]
2126

2227
[profile.release]
2328
opt-level = 3
@@ -26,6 +31,10 @@ rpath = false
2631
lto = true
2732
debug-assertions = false
2833

34+
[profile.release-lto]
35+
inherits = "release"
36+
lto = "thin"
37+
2938
[profile.dev]
3039
opt-level = 1 # controls the `--opt-level` the compiler builds with
3140
debug = true # controls whether the compiler passes `-C debuginfo`

0 commit comments

Comments
 (0)