Skip to content

Commit

Permalink
Merge branch 'master' into net-poll
Browse files Browse the repository at this point in the history
  • Loading branch information
glommer authored Apr 26, 2024
2 parents bfa5531 + 562adb8 commit c9b9f29
Show file tree
Hide file tree
Showing 81 changed files with 4,144 additions and 1,558 deletions.
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[net]
git-fetch-with-cli = true
6 changes: 0 additions & 6 deletions .github/templates/license_check_failed.md

This file was deleted.

16 changes: 7 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Cache setup
uses: ./.github/actions/cache-setup
Expand All @@ -24,7 +24,7 @@ jobs:
run: which deadlinks || cargo install cargo-deadlinks

- name: Generate documentation
run: cargo doc --all-features
run: cargo doc --all

# temporarily disabled.
# - name: Validate links
Expand All @@ -35,20 +35,20 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Cache setup
uses: ./.github/actions/cache-setup

- name: Build all targets
run: cargo build --all --all-targets --all-features
run: cargo build --all --all-targets

test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Cache setup
uses: ./.github/actions/cache-setup
Expand All @@ -58,12 +58,10 @@ jobs:
cat << EOF > "run-gha-workflow.sh"
PATH=$PATH:/usr/share/rust/.cargo/bin
echo "`nproc` CPU(s) available"
rustup install nightly
rustup component add rustfmt --toolchain nightly-x86_64-unknown-linux-gnu
rustup install 1.58
rustup install 1.65
rustup show
rustup default stable
cargo install cargo-sort
cargo test --all-features -- --test-threads=`nproc`
cargo test -- --test-threads=`nproc`
EOF
sudo -E bash -c "ulimit -Sl 512 && ulimit -Hl 512 && bash run-gha-workflow.sh"
34 changes: 5 additions & 29 deletions .github/workflows/third-party_exported.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ name: Third-party licences
permissions: write-all

on:
pull_request_target:
types: [opened, synchronize, reopened]
pull_request:
branches: [ master ]
types: [ "opened", "synchronize" ]
push:
branches: [ master ]

jobs:
allowed:
Expand All @@ -24,30 +27,3 @@ jobs:
log-level: warn
command: check licenses
arguments: --all-features

comment:
runs-on: ubuntu-latest

needs: [ allowed ]
if: failure()
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# pull the fork's HEAD instead of the main repo's
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}

- name: Render Template
id: template
uses: chuhlomin/[email protected]
with:
template: .github/templates/license_check_failed.md
vars: |
user: ${{ github.event.pull_request.user.login }}
- name: Comment PR
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.template.outputs.result }}
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ members = [
"examples",
"glommio",
]
resolver = "2"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ an [introductory article.](https://www.datadoghq.com/blog/engineering/introducin

## Supported Rust Versions

Glommio is built against the latest stable release. The minimum supported version is 1.58. The current Glommio version
Glommio is built against the latest stable release. The minimum supported version is 1.65. The current Glommio version
is not guaranteed to build on Rust versions earlier than the minimum supported version.

## Supported Linux kernels
Expand Down
3 changes: 2 additions & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ allow = [
"Apache-2.0 WITH LLVM-exception",
"MPL-2.0",
"Unlicense",
"Zlib"
"Zlib",
"Unicode-DFS-2016"
]
copyleft = "deny"
default = "deny"
Expand Down
25 changes: 15 additions & 10 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@ name = "examples"
version = "0.0.0"
license = "Apache-2.0 OR MIT"
publish = false
edition = "2018"
edition = "2021"

[dev-dependencies]
ansi_term = "~0.12.1"
clap = "2.33"
byte-unit = "5.1.4"
yansi = "~0.5.1"
clap = "4.5.3"
fastrand = "1.4.0"
futures = "~0.3.5"
futures-lite = "1.11.1"
glommio = { path = "../glommio" }

# hyper and tokio for the hyper example. We just need the traits from Tokio
hyper = { version = "0.14", features = ["full"] }
hyper = { version = "1.2.0", features = ["full"] }
num_cpus = "1.13.0"
pretty-bytes = "~0.2.2"
sys-info = "~0.8.0"
tokio = { version = "1" }
http-body-util = "0.1.0"
serde_json = "1.0.114"

[[example]]
name = "echo"
Expand Down Expand Up @@ -52,10 +53,14 @@ path = "storage.rs"
name = "channel_mesh"
path = "sharding.rs"

[[example]]
name = "hyper"
path = "hyper.rs"

[[example]]
name = "gate"
path = "gate.rs"

[[example]]
name = "hyper_server"
path = "hyper_server.rs"

[[example]]
name = "hyper_client"
path = "hyper_client.rs"
38 changes: 17 additions & 21 deletions examples/deadline_writer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use ansi_term::{Colour, Style};
use futures_lite::io::AsyncBufReadExt;
use glommio::{
controllers::{DeadlineQueue, DeadlineSource},
Expand All @@ -12,6 +11,7 @@ use std::{
rc::Rc,
time::{Duration, Instant},
};
use yansi::Paint;

fn burn_cpu(dur: Duration) {
let now = Instant::now();
Expand Down Expand Up @@ -69,13 +69,11 @@ impl IntWriter {

println!(
"{}: Wrote {} ({}%), {:.0} int/s, scheduler shares: {} , {:.2} % CPU",
Colour::Blue.paint(format!("{}s", elapsed.as_secs())),
Paint::blue(format!("{}s", elapsed.as_secs())),
self.count.get(),
Style::new().bold().paint(format!("{:.0}", ratio)),
Paint::new(format!("{:.0}", ratio)).bold(),
intratio,
Style::new()
.bold()
.paint(tq_stats.current_shares().to_string()),
Paint::new(tq_stats.current_shares().to_string()).bold(),
cpuratio
);
self.next_print
Expand Down Expand Up @@ -129,7 +127,7 @@ fn competing_cpu_hog(
}

async fn static_writer(how_many: usize, shares: usize, cpuhog_tq: TaskQueueHandle) -> Duration {
let name = format!("shares-{}", shares);
let name = format!("shares-{shares}");
let tq =
glommio::executor().create_task_queue(Shares::Static(shares), Latency::NotImportant, &name);

Expand Down Expand Up @@ -172,9 +170,7 @@ fn main() {

println!(
"{}",
Style::new()
.bold()
.paint("Welcome to the Deadline Writer example")
Paint::new("Welcome to the Deadline Writer example").bold()
);
println!(
"In this example we will write a sequence of integers to a variable, busy looping \
Expand All @@ -187,36 +183,36 @@ fn main() {
println!(
"For {} results, this test is pinned to your CPU0. Make sure nothing else of \
significance is running there. You should be able to see it at 100% at all times!",
Style::new().bold().paint("best")
Paint::new("best").bold()
);

println!("\n\nPlease tell me how many integers you would like to write");
let to_write = read_int().await.unwrap();
println!(
"Ok, now let's write {} integers with both the writer and the CPU hog having the \
same priority",
Colour::Blue.paint(to_write.to_string())
Paint::blue(to_write.to_string())
);
let dur = static_writer(to_write, 1000, cpuhog_tq).await;
println!(
"Finished writing in {}",
Colour::Green.paint(format!("{:#.0?}", dur))
Paint::green(format!("{dur:#.0?}"))
);
println!(
"This was using {} shares, and short of reducing the priority of the CPU hog. {}",
Colour::Green.paint("1000"),
Style::new().bold().paint("This is as fast as we can do!")
Paint::green("1000"),
Paint::new("This is as fast as we can do!").bold()
);
println!(
"With {} shares, this would have taken approximately {}",
Colour::Green.paint("100"),
Colour::Green.paint(format!("{:#.1?}", dur * 10))
Paint::green("100"),
Paint::green(format!("{:#.1?}", dur * 10))
);
println!(
"With {} shares, this would have taken approximately {}. {}.",
Colour::Green.paint("1"),
Colour::Green.paint(format!("{:#.1?}", dur * 1000)),
Style::new().bold().paint("Can't go any slower than that!")
Paint::green("1"),
Paint::green(format!("{:#.1?}", dur * 1000)),
Paint::new("Can't go any slower than that!").bold()
);

println!(
Expand All @@ -239,7 +235,7 @@ fn main() {
let dur = deadline.push_work(test).await.unwrap();
println!(
"Finished writing in {}",
Colour::Green.paint(format!("{:#.2?}", dur))
Paint::green(format!("{dur:#.2?}"))
);
stop.set(true);
hog.await.unwrap();
Expand Down
4 changes: 2 additions & 2 deletions examples/gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ fn main() {
for i in 0..nr_tasks {
gate.spawn(enclose!((running_tasks, tasks_to_complete) async move {
running_tasks.signal(1);
println!("[Task {}] started, running tasks: {}", i, running_tasks.available());
println!("[Task {i}] started, running tasks: {}", running_tasks.available());
tasks_to_complete.acquire(1).await.unwrap();
}))
.unwrap()
.detach();
}

println!("Main: waiting for {} tasks", nr_tasks);
println!("Main: waiting for {nr_tasks} tasks");
running_tasks.acquire(nr_tasks).await.unwrap();

println!("Main: closing gate");
Expand Down
Loading

0 comments on commit c9b9f29

Please sign in to comment.