Skip to content

Commit

Permalink
Merge branch 'main' into fix_release_script
Browse files Browse the repository at this point in the history
  • Loading branch information
YJDoc2 committed Dec 13, 2022
2 parents 78fec6a + 28da7c0 commit fe3f11b
Show file tree
Hide file tree
Showing 16 changed files with 200 additions and 35 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/benchmark_execution_time.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
building-pr-branch:
if: (github.event.issue.pull_request != null) && github.event.comment.body == '!github easy-benchmark'
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
timeout-minutes: 15

steps:
Expand Down Expand Up @@ -37,7 +37,7 @@ jobs:

building-main-branch:
if: (github.event.issue.pull_request != null) && github.event.comment.body == '!github easy-benchmark'
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
timeout-minutes: 15

steps:
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
needs:
- building-pr-branch
- building-main-branch
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
timeout-minutes: 15

steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

jobs:
changes:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
timeout-minutes: 15
outputs:
dirs: ${{ steps.filter.outputs.changes }}
Expand All @@ -19,7 +19,7 @@ jobs:
deploy:
needs: [changes]
if: ${{ !contains(needs.changes.outputs.dirs, '[]') }}
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
timeout-minutes: 15
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/integration_tests_validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
changes:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
timeout-minutes: 15
outputs:
dirs: ${{ steps.filter.outputs.changes }}
Expand All @@ -22,7 +22,7 @@ jobs:
validate:
needs: [changes]
if: ${{ !contains(needs.changes.outputs.dirs, '[]') }}
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
timeout-minutes: 15
strategy:
matrix:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
changes:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
timeout-minutes: 15
outputs:
dirs: ${{ steps.filter.outputs.changes }}
Expand All @@ -27,7 +27,7 @@ jobs:
check:
needs: [changes]
if: ${{ !contains(needs.changes.outputs.dirs, '[]') }}
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
timeout-minutes: 15
strategy:
matrix:
Expand All @@ -51,7 +51,7 @@ jobs:
working-directory: ${{matrix.dirs}}
run: cargo clippy --all-targets --all-features -- -D warnings
tests:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
timeout-minutes: 15
strategy:
matrix:
Expand All @@ -71,7 +71,7 @@ jobs:
export LD_LIBRARY_PATH=$HOME/.wasmedge/lib
cd ./crates && cargo test --all --all-features --no-fail-fast
coverage:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
timeout-minutes: 15
name: Run test coverage
steps:
Expand Down Expand Up @@ -103,7 +103,7 @@ jobs:
with:
file: ./coverage.lcov
integration_tests:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
timeout-minutes: 15
strategy:
matrix:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/podman_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:

jobs:
podman-tests:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- run: sudo apt-get -y update
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
check:
name: Check
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -27,7 +27,7 @@ jobs:
upload:
name: Upload
needs: check
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- run: sudo apt-get -y update
Expand All @@ -54,7 +54,7 @@ jobs:

release:
name: Create Draft Release
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
needs:
- upload
outputs:
Expand Down Expand Up @@ -101,7 +101,7 @@ jobs:
publish:
name: Publish Packages
needs: check
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
env:
CARGO_REGISTRY_TOKEN: 'DUMMY Token' #${{ secrets.CARGO_REGISTRY_TOKEN }}
steps:
Expand Down
14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

118 changes: 117 additions & 1 deletion crates/libcgroups/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pub struct CpuStats {
pub usage: CpuUsage,
/// Cpu Throttling statistics for the cgroup
pub throttling: CpuThrottling,
/// Pressure Stall Information
pub psi: PSIStats,
}

/// Reports the cpu usage for a cgroup
Expand Down Expand Up @@ -79,6 +81,8 @@ pub struct MemoryStats {
pub hierarchy: bool,
/// Various memory statistics
pub stats: HashMap<String, u64>,
/// Pressure Stall Information
pub psi: PSIStats,
}

/// Reports memory stats for one type of memory
Expand All @@ -104,7 +108,7 @@ pub struct PidStats {
}

/// Reports block io stats for a cgroup
#[derive(Debug, Default, PartialEq, Eq, Serialize)]
#[derive(Debug, Default, PartialEq, Serialize)]
pub struct BlkioStats {
// Number of bytes transferred to/from a device by the cgroup
pub service_bytes: Vec<BlkioDeviceStat>,
Expand All @@ -122,6 +126,8 @@ pub struct BlkioStats {
pub queued: Vec<BlkioDeviceStat>,
// Number of requests merged into requests for I/O operations
pub merged: Vec<BlkioDeviceStat>,
/// Pressure Stall Information
pub psi: PSIStats,
}

/// Reports single stat value for a specific device
Expand Down Expand Up @@ -162,6 +168,26 @@ pub struct HugeTlbStats {
pub fail_count: u64,
}

/// Reports Pressure Stall Information for a cgroup
#[derive(Debug, Default, PartialEq, Serialize)]
pub struct PSIStats {
/// Percentage of walltime that some (one or more) tasks were delayed due to lack of resources
pub some: PSIData,
/// Percentage of walltime in which all tasks were delayed by lack of resources
pub full: PSIData,
}

///
#[derive(Debug, Default, PartialEq, Serialize)]
pub struct PSIData {
/// Running average over the last 10 seconds
pub avg10: f64,
/// Running average over the last 60 seconds
pub avg60: f64,
/// Running average over the last 300 seconds
pub avg300: f64,
}

/// Reports which hugepage sizes are supported by the system
pub fn supported_page_sizes() -> Result<Vec<String>> {
let mut sizes = Vec::new();
Expand Down Expand Up @@ -327,6 +353,48 @@ pub fn pid_stats(cgroup_path: &Path) -> Result<PidStats> {
Ok(stats)
}

pub fn psi_stats(psi_file: &Path) -> Result<PSIStats> {
let mut stats = PSIStats::default();

let psi = common::read_cgroup_file(psi_file)?;
for line in psi.lines() {
match &line[0..4] {
"some" => stats.some = parse_psi(&line[4..])?,
"full" => stats.full = parse_psi(&line[4..])?,
_ => continue,
}
}

Ok(stats)
}

fn parse_psi(stat_line: &str) -> Result<PSIData> {
let mut psi_data = PSIData::default();

for kv in stat_line.split_ascii_whitespace() {
match kv.split_once('=') {
Some(("avg10", v)) => {
psi_data.avg10 = v
.parse()
.with_context(|| format!("invalid psi value {v}"))?
}
Some(("avg60", v)) => {
psi_data.avg60 = v
.parse()
.with_context(|| format!("invalid psi value {v}"))?
}
Some(("avg300", v)) => {
psi_data.avg300 = v
.parse()
.with_context(|| format!("invalid psi value {v}"))?
}
_ => continue,
}
}

Ok(psi_data)
}

#[cfg(test)]
mod tests {
use crate::test::{create_temp_dir, set_fixture};
Expand Down Expand Up @@ -520,4 +588,52 @@ mod tests {
let result = parse_device_number("a:b");
assert!(result.is_err());
}

#[test]
fn test_parse_psi_full_stats() {
let tmp = create_temp_dir("test_parse_psi_full_stats").unwrap();
let file_content = [
"some avg10=80.00 avg60=50.00 avg300=90.00 total=0",
"full avg10=10.00 avg60=30.00 avg300=50.00 total=0",
]
.join("\n");
let psi_file = set_fixture(&tmp, "psi.pressure", &file_content).unwrap();

let result = psi_stats(&psi_file).unwrap();
assert_eq!(
result,
PSIStats {
some: PSIData {
avg10: 80.0,
avg60: 50.0,
avg300: 90.0
},
full: PSIData {
avg10: 10.0,
avg60: 30.0,
avg300: 50.0
},
}
)
}

#[test]
fn test_parse_psi_only_some() {
let tmp = create_temp_dir("test_parse_psi_only_some").unwrap();
let file_content = ["some avg10=80.00 avg60=50.00 avg300=90.00 total=0"].join("\n");
let psi_file = set_fixture(&tmp, "psi.pressure", &file_content).unwrap();

let result = psi_stats(&psi_file).unwrap();
assert_eq!(
result,
PSIStats {
some: PSIData {
avg10: 80.0,
avg60: 50.0,
avg300: 90.0
},
full: PSIData::default(),
}
)
}
}
1 change: 1 addition & 0 deletions crates/libcgroups/src/v1/blkio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ impl Blkio {
wait_time: Self::parse_blkio_file(&cgroup_path.join(BLKIO_WAIT_TIME))?,
queued: Self::parse_blkio_file(&cgroup_path.join(BLKIO_QUEUED))?,
merged: Self::parse_blkio_file(&cgroup_path.join(BLKIO_MERGED))?,
..Default::default()
};

Ok(stats)
Expand Down
1 change: 1 addition & 0 deletions crates/libcgroups/src/v1/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ impl StatsProvider for Memory {
cache: stats["cache"],
hierarchy,
stats,
..Default::default()
})
}
}
Expand Down
Loading

0 comments on commit fe3f11b

Please sign in to comment.