Skip to content

Commit

Permalink
can we fix CI OOM by skipping large modules?
Browse files Browse the repository at this point in the history
  • Loading branch information
danleh committed Jul 26, 2024
1 parent 5156bf9 commit 6c31835
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
50 changes: 50 additions & 0 deletions crates/Cargo.lock

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

1 change: 1 addition & 0 deletions crates/test_utilities/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ edition = "2021"
once_cell = "1.17.0"
rayon = "1.6.1"
indicatif = { version = "0.17.2", features = ["rayon"] }
sysinfo = "0.30.0"

# Only used for the "test commands" when validating/updating the valid-inputs list.
[dev-dependencies]
Expand Down
23 changes: 22 additions & 1 deletion crates/test_utilities/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

use std::io;
use std::io::BufRead;
use std::fs;
use std::fs::File;
use std::path::Path;
use std::path::PathBuf;

use once_cell::sync::Lazy;
use rayon::prelude::*;
use indicatif::ParallelProgressIterator;
use sysinfo::System;

const VALID_WASM_BINARIES_LIST_FILE: &str = "../../test-inputs/valid-wasm-binaries.txt";

Expand Down Expand Up @@ -36,7 +38,26 @@ pub fn for_each_valid_wasm_binary_in_test_set(test_fn: impl Fn(&Path) + Send + S
// Abort parallel processing as early as possible.
.panic_fuse()
.progress()
.for_each(|path| test_fn(path));
.for_each(|path| {
let module_size_bytes = fs::metadata(path)
.map(|file| file.len())
.unwrap_or(0);

const AST_BYTES_PER_INSTRUCTION_BYTE_APPROX: u64 = 100;
let memory_needed_for_ast_approx = module_size_bytes * AST_BYTES_PER_INSTRUCTION_BYTE_APPROX;

let memory_available = {
let mut system = System::new();
system.refresh_memory();
system.available_memory()
};
if memory_needed_for_ast_approx > memory_available {
eprintln!("Skipping {} due to running low on memory...\n\t{} bytes memory available\n\t{} bytes module size\n\t{} bytes approx. required", path.display(), memory_available, module_size_bytes, memory_needed_for_ast_approx);
return;
}

test_fn(path)}
);
}

/// Call WABT's wasm-validate tool on a file (WABT needs to be on $PATH).
Expand Down

0 comments on commit 6c31835

Please sign in to comment.