Skip to content

Commit

Permalink
fix: disable parallelization by default
Browse files Browse the repository at this point in the history
  • Loading branch information
mtshiba committed Sep 19, 2024
1 parent 58b22c4 commit 1cdcefc
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 19 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ gal = ["erg_common/gal", "erg_compiler/gal"]
els = ["erg_common/els", "erg_compiler/els", "dep:els"]
full-repl = ["erg_common/full-repl"]
full = ["els", "full-repl", "unicode", "pretty"]
experimental = ["erg_common/experimental", "erg_parser/experimental", "erg_compiler/experimental", "erg_linter/experimental"]
experimental = ["erg_common/experimental", "erg_parser/experimental", "erg_compiler/experimental", "erg_linter/experimental", "parallel"]
log-level-error = ["erg_common/log-level-error", "erg_parser/log-level-error", "erg_compiler/log-level-error", "erg_linter/log-level-error"]
single-thread = ["erg_common/single-thread", "erg_parser/single-thread", "erg_compiler/single-thread", "erg_linter/single-thread"]
# The parallelizing compiler was found to contain a bug that caused it to hang in complex dependencies, so it is disabled by default.
parallel = ["erg_common/parallel", "erg_parser/parallel", "erg_compiler/parallel", "erg_linter/parallel"]

[workspace.dependencies]
erg_common = { version = "0.6.44-nightly.0", path = "./crates/erg_common" }
Expand Down
4 changes: 2 additions & 2 deletions crates/erg_common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ py_compat = []
gal = []
no_std = []
full-repl = ["dep:crossterm"]
experimental = []
experimental = ["parallel"]
pylib = ["dep:pyo3"]
log-level-error = []
single-thread = []
parallel = []

[target.'cfg(unix)'.dependencies]
backtrace-on-stack-overflow = { version = "0.3.0", optional = true }
Expand Down
14 changes: 14 additions & 0 deletions crates/erg_common/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,8 @@ impl ErgConfig {
"--build-features" => {
#[cfg(feature = "debug")]
print!("debug ");
#[cfg(feature = "backtrace")]
println!("backtrace");
#[cfg(feature = "els")]
print!("els ");
#[cfg(feature = "py_compat")]
Expand All @@ -483,6 +485,18 @@ impl ErgConfig {
print!("pretty ");
#[cfg(feature = "large_thread")]
print!("large_thread");
#[cfg(feature = "no_std")]
println!("no_std");
#[cfg(feature = "full-repl")]
println!("full-repl");
#[cfg(feature = "experimental")]
println!("experimental");
#[cfg(feature = "pylib")]
println!("pylib");
#[cfg(feature = "log-level-error")]
println!("log-level-error");
#[cfg(feature = "parallel")]
println!("parallel");
println!();
process::exit(0);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/erg_common/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ pub const LOG_LEVEL_ERROR: bool = cfg!(feature = "log-level-error");
pub const EXPERIMENTAL_MODE: bool = cfg!(feature = "experimental");
pub const BACKTRACE_MODE: bool = cfg!(feature = "backtrace");
pub const GAL: bool = cfg!(feature = "gal");
pub const SINGLE_THREAD: bool = cfg!(feature = "single-thread");
pub const PARALLEL: bool = cfg!(feature = "parallel");
5 changes: 3 additions & 2 deletions crates/erg_compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ gal = ["erg_common/gal"]
els = ["erg_common/els"]
no_std = ["erg_common/no_std"]
full-repl = ["erg_common/full-repl"]
experimental = ["erg_common/experimental", "erg_parser/experimental"]
experimental = ["erg_common/experimental", "erg_parser/experimental", "parallel"]
pylib = ["dep:pyo3", "erg_common/pylib", "erg_parser/pylib"]
pylib_compiler = ["pylib"]
log-level-error = ["erg_common/log-level-error", "erg_parser/log-level-error"]
single-thread = ["erg_common/single-thread", "erg_parser/single-thread"]
# The parallelizing compiler was found to contain a bug that caused it to hang in complex dependencies, so it is disabled by default.
parallel = ["erg_common/parallel", "erg_parser/parallel"]

[dependencies]
erg_common = { workspace = true }
Expand Down
10 changes: 5 additions & 5 deletions crates/erg_compiler/build_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::time::{Duration, SystemTime};
use erg_common::config::ErgMode;

use erg_common::config::ErgConfig;
use erg_common::consts::{ELS, ERG_MODE, SINGLE_THREAD};
use erg_common::consts::{ELS, ERG_MODE, PARALLEL};
use erg_common::debug_power_assert;
use erg_common::dict::Dict;
use erg_common::env::is_std_decl_path;
Expand Down Expand Up @@ -971,12 +971,12 @@ impl<ASTBuilder: ASTBuildable, HIRBuilder: Buildable>
}
}
};
if SINGLE_THREAD {
run();
self.shared.promises.mark_as_joined(path);
} else {
if PARALLEL {
let handle = spawn_new_thread(run, &__name__);
self.shared.promises.insert(path, handle);
} else {
run();
self.shared.promises.mark_as_joined(path);
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/erg_compiler/module/promise.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fmt;
use std::thread::{current, JoinHandle, ThreadId};

use erg_common::consts::{DEBUG_MODE, SINGLE_THREAD};
use erg_common::consts::{DEBUG_MODE, PARALLEL};
use erg_common::dict::Dict;
use erg_common::pathutil::NormalizedPathBuf;
use erg_common::shared::Shared;
Expand Down Expand Up @@ -182,7 +182,7 @@ impl SharedPromises {
// self.wait_until_finished(path);
return Ok(());
}
if SINGLE_THREAD {
if !PARALLEL {
assert!(self.is_joined(path));
return Ok(());
}
Expand Down
3 changes: 2 additions & 1 deletion crates/erg_linter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ full-repl = ["erg_common/full-repl"]
full = ["full-repl", "unicode", "pretty"]
experimental = ["erg_common/experimental", "erg_parser/experimental", "erg_compiler/experimental"]
log-level-error = ["erg_common/log-level-error", "erg_parser/log-level-error", "erg_compiler/log-level-error"]
single-thread = ["erg_common/single-thread", "erg_parser/single-thread", "erg_compiler/single-thread"]
# The parallelizing compiler was found to contain a bug that caused it to hang in complex dependencies, so it is disabled by default.
parallel = ["erg_common/parallel", "erg_parser/parallel", "erg_compiler/parallel"]

[dependencies]
erg_common = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions crates/erg_parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ traditional_chinese = ["erg_common/traditional_chinese"]
unicode = ["erg_common/unicode"]
pretty = ["erg_common/pretty"]
large_thread = ["erg_common/large_thread"]
experimental = ["erg_common/experimental"]
experimental = ["erg_common/experimental", "parallel"]
pylib = ["dep:pyo3", "erg_common/pylib"]
pylib_parser = ["pylib"]
log-level-error = ["erg_common/log-level-error"]
single-thread = ["erg_common/single-thread"]
parallel = ["erg_common/parallel"]

[dependencies]
erg_common = { workspace = true }
Expand Down
6 changes: 5 additions & 1 deletion doc/EN/dev_guide/build_features.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ Enable Python-compatible mode, which makes parts of the APIs and syntax compatib

## experimental

Enable experimental features.
Enable experimental features (contains `parallel`).

## log-level-error

Only display error logs.

## parallel

Enable compiler parallelization. Unstable feature.
6 changes: 5 additions & 1 deletion doc/JA/dev_guide/build_features.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@ Python互換モードを有効にする。APIや文法の一部がPythonと互

## experimental

実験的な機能を有効にする。
実験的な機能を有効にする。`parallel`も有効化される。

## log-level-error

エラーログのみ表示する。

## parallel

コンパイラの並列化を有効にする。不安定機能。

0 comments on commit 1cdcefc

Please sign in to comment.