Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: avoid dashmap lock for logger #8633

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions crates/rspack_binding_values/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,76 +195,76 @@ pub struct JsStatsLogging {
pub trace: Option<Vec<String>>,
}

impl From<(String, rspack_core::LogType)> for JsStatsLogging {
fn from(value: (String, rspack_core::LogType)) -> Self {
impl From<(String, rspack_core::Log)> for JsStatsLogging {
fn from(value: (String, rspack_core::Log)) -> Self {
match value.1 {
rspack_core::LogType::Error { message, trace } => Self {
rspack_core::Log::Error { message, trace } => Self {
name: value.0,
r#type: "error".to_string(),
args: Some(vec![message]),
trace: Some(trace),
},
rspack_core::LogType::Warn { message, trace } => Self {
rspack_core::Log::Warn { message, trace } => Self {
name: value.0,
r#type: "warn".to_string(),
args: Some(vec![message]),
trace: Some(trace),
},
rspack_core::LogType::Info { message } => Self {
rspack_core::Log::Info { message } => Self {
name: value.0,
r#type: "info".to_string(),
args: Some(vec![message]),
trace: None,
},
rspack_core::LogType::Log { message } => Self {
rspack_core::Log::Log { message } => Self {
name: value.0,
r#type: "log".to_string(),
args: Some(vec![message]),
trace: None,
},
rspack_core::LogType::Debug { message } => Self {
rspack_core::Log::Debug { message } => Self {
name: value.0,
r#type: "debug".to_string(),
args: Some(vec![message]),
trace: None,
},
rspack_core::LogType::Trace { message, trace } => Self {
rspack_core::Log::Trace { message, trace } => Self {
name: value.0,
r#type: "trace".to_string(),
args: Some(vec![message]),
trace: Some(trace),
},
rspack_core::LogType::Group { message } => Self {
rspack_core::Log::Group { message } => Self {
name: value.0,
r#type: "group".to_string(),
args: Some(vec![message]),
trace: None,
},
rspack_core::LogType::GroupCollapsed { message } => Self {
rspack_core::Log::GroupCollapsed { message } => Self {
name: value.0,
r#type: "groupCollapsed".to_string(),
args: Some(vec![message]),
trace: None,
},
rspack_core::LogType::GroupEnd => Self {
rspack_core::Log::GroupEnd => Self {
name: value.0,
r#type: "groupEnd".to_string(),
args: None,
trace: None,
},
rspack_core::LogType::Profile { label } => Self {
rspack_core::Log::Profile { label } => Self {
name: value.0,
r#type: "profile".to_string(),
args: Some(vec![label.to_string()]),
trace: None,
},
rspack_core::LogType::ProfileEnd { label } => Self {
rspack_core::Log::ProfileEnd { label } => Self {
name: value.0,
r#type: "profileEnd".to_string(),
args: Some(vec![label.to_string()]),
trace: None,
},
rspack_core::LogType::Time {
rspack_core::Log::Time {
label,
secs,
subsec_nanos,
Expand All @@ -278,19 +278,19 @@ impl From<(String, rspack_core::LogType)> for JsStatsLogging {
)]),
trace: None,
},
rspack_core::LogType::Clear => Self {
rspack_core::Log::Clear => Self {
name: value.0,
r#type: "clear".to_string(),
args: None,
trace: None,
},
rspack_core::LogType::Status { message } => Self {
rspack_core::Log::Status { message } => Self {
name: value.0,
r#type: "status".to_string(),
args: Some(vec![message]),
trace: None,
},
rspack_core::LogType::Cache { label, hit, total } => Self {
rspack_core::Log::Cache { label, hit, total } => Self {
name: value.0,
r#type: "cache".to_string(),
args: Some(vec![format!(
Expand Down
9 changes: 6 additions & 3 deletions crates/rspack_core/src/build_chunk_graph/code_splitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ Or do you want to use the entrypoints '{name}' and '{runtime}' independently on
input_entrypoints_and_modules: UkeyIndexMap<ChunkGroupUkey, Vec<ModuleIdentifier>>,
compilation: &mut Compilation,
) -> Result<()> {
let logger = compilation.get_logger("rspack.buildChunkGraph");
let mut logger = compilation.get_logger("rspack.buildChunkGraph");
let start = logger.time("prepare entrypoints");
logger.time_end(start);

Expand Down Expand Up @@ -744,12 +744,13 @@ Or do you want to use the entrypoints '{name}' and '{runtime}' independently on
}
}

compilation.collect_logger(logger);
Ok(())
}

#[tracing::instrument(skip_all)]
pub fn split(&mut self, compilation: &mut Compilation) -> Result<()> {
let logger = compilation.get_logger("rspack.buildChunkGraph");
let mut logger = compilation.get_logger("rspack.buildChunkGraph");

// pop() is used to read from the queue
// so it need to be reversed to be iterated in
Expand Down Expand Up @@ -876,7 +877,7 @@ Or do you want to use the entrypoints '{name}' and '{runtime}' independently on
.incremental
.can_read_mutations(IncrementalPasses::BUILD_CHUNK_GRAPH)
{
let logger = compilation.get_logger("rspack.incremental.buildChunkGraph");
let mut logger = compilation.get_logger("rspack.incremental.buildChunkGraph");
logger.log(format!(
"{} chunk group created",
self.stat_chunk_group_created,
Expand All @@ -901,9 +902,11 @@ Or do you want to use the entrypoints '{name}' and '{runtime}' independently on
"{} cache missed by incorrect available modules",
self.stat_cache_miss_by_available_modules,
));
compilation.collect_logger(logger);
self.update_cache(compilation);
}

compilation.collect_logger(logger);
Ok(())
}

Expand Down
Loading
Loading