Merge pull request #1746 from rtfeldman/bench_race_condition

benchmark race condition patch
This commit is contained in:
Anton-4 2021-09-27 17:14:48 +02:00 committed by GitHub
commit 0b02929a53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -7,6 +7,7 @@ name: Benchmarks
env:
RUST_BACKTRACE: 1
ROC_NUM_WORKERS: 1
jobs:
prep-dependency-container:
@ -42,4 +43,4 @@ jobs:
run: cd ci/bench-runner && cargo build --release && cd ../..
- name: run benchmarks with regression check
run: echo "TODO re-enable benchmarks once race condition is fixed"#./ci/bench-runner/target/release/bench-runner --check-executables-changed
run: ./ci/bench-runner/target/release/bench-runner --check-executables-changed

View File

@ -37,13 +37,13 @@ use roc_types::subs::{Subs, VarStore, Variable};
use roc_types::types::{Alias, Type};
use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::collections::{HashMap, HashSet};
use std::fs;
use std::io;
use std::iter;
use std::path::{Path, PathBuf};
use std::str::from_utf8_unchecked;
use std::sync::Arc;
use std::time::{Duration, SystemTime};
use std::{env, fs};
/// Default name for the binary generated for an app, if an invalid one was specified.
const DEFAULT_APP_OUTPUT_PATH: &str = "app";
@ -1351,7 +1351,12 @@ where
// doing .max(1) on the entire expression guards against
// num_cpus returning 0, while also avoiding wrapping
// unsigned subtraction overflow.
let num_workers = num_cpus::get().max(2) - 1;
let default_num_workers = num_cpus::get().max(2) - 1;
let num_workers = match env::var("ROC_NUM_WORKERS") {
Ok(env_str) => env_str.parse::<usize>().unwrap_or(default_num_workers),
Err(_) => default_num_workers,
};
let worker_arenas = arena.alloc(bumpalo::collections::Vec::with_capacity_in(
num_workers,