diff --git a/Cargo.toml b/Cargo.toml index 7b5bf06ed..d21809442 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" } diff --git a/crates/erg_common/Cargo.toml b/crates/erg_common/Cargo.toml index 32d712380..f9f61c7c6 100644 --- a/crates/erg_common/Cargo.toml +++ b/crates/erg_common/Cargo.toml @@ -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 } diff --git a/crates/erg_common/config.rs b/crates/erg_common/config.rs index f52e399ed..be7065280 100644 --- a/crates/erg_common/config.rs +++ b/crates/erg_common/config.rs @@ -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")] @@ -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); } diff --git a/crates/erg_common/consts.rs b/crates/erg_common/consts.rs index 62e4bd0ad..000614eb1 100644 --- a/crates/erg_common/consts.rs +++ b/crates/erg_common/consts.rs @@ -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"); diff --git a/crates/erg_compiler/Cargo.toml b/crates/erg_compiler/Cargo.toml index c2502bf36..a5c4c8ec9 100644 --- a/crates/erg_compiler/Cargo.toml +++ b/crates/erg_compiler/Cargo.toml @@ -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 } diff --git a/crates/erg_compiler/build_package.rs b/crates/erg_compiler/build_package.rs index 3483ea0f2..73a41865e 100644 --- a/crates/erg_compiler/build_package.rs +++ b/crates/erg_compiler/build_package.rs @@ -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; @@ -971,12 +971,12 @@ impl } } }; - 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); } } diff --git a/crates/erg_compiler/module/promise.rs b/crates/erg_compiler/module/promise.rs index 991aa0d11..268ad978f 100644 --- a/crates/erg_compiler/module/promise.rs +++ b/crates/erg_compiler/module/promise.rs @@ -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; @@ -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(()); } diff --git a/crates/erg_linter/Cargo.toml b/crates/erg_linter/Cargo.toml index 9c1a46071..be3bd31be 100644 --- a/crates/erg_linter/Cargo.toml +++ b/crates/erg_linter/Cargo.toml @@ -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 } diff --git a/crates/erg_parser/Cargo.toml b/crates/erg_parser/Cargo.toml index b19e87880..1d240e958 100644 --- a/crates/erg_parser/Cargo.toml +++ b/crates/erg_parser/Cargo.toml @@ -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 } diff --git a/doc/EN/dev_guide/build_features.md b/doc/EN/dev_guide/build_features.md index 73a5da262..52a4df21e 100644 --- a/doc/EN/dev_guide/build_features.md +++ b/doc/EN/dev_guide/build_features.md @@ -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. diff --git a/doc/JA/dev_guide/build_features.md b/doc/JA/dev_guide/build_features.md index 2c246f318..27e72bd6d 100644 --- a/doc/JA/dev_guide/build_features.md +++ b/doc/JA/dev_guide/build_features.md @@ -45,8 +45,12 @@ Python互換モードを有効にする。APIや文法の一部がPythonと互 ## experimental -実験的な機能を有効にする。 +実験的な機能を有効にする。`parallel`も有効化される。 ## log-level-error エラーログのみ表示する。 + +## parallel + +コンパイラの並列化を有効にする。不安定機能。