Skip to content

Commit

Permalink
refactor(core): move compiler/queue.rs to compiler/make/queue.rs (#5892)
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Mar 8, 2024
1 parent 4c26a16 commit 445ad62
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 25 deletions.
31 changes: 19 additions & 12 deletions crates/rspack_core/src/compiler/make/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
mod queue;
mod rebuild_deps_builder;

use std::{
collections::VecDeque,
path::PathBuf,
Expand All @@ -14,21 +17,25 @@ use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet};
use tokio::sync::mpsc;
use tokio::sync::mpsc::error::TryRecvError;

use self::queue::{
AddQueue, AddTask, AddTaskResult, BuildQueue, BuildTask, BuildTaskResult,
BuildTimeExecutionQueue, CleanQueue, CleanTask, CleanTaskResult, FactorizeQueue,
FactorizeTaskResult, ModuleCreationCallback, ProcessDependenciesQueue, ProcessDependenciesResult,
ProcessDependenciesTask, TaskResult, WorkerTask,
};
pub use self::queue::{
AddQueueHandler, BuildQueueHandler, BuildTimeExecutionOption, BuildTimeExecutionQueueHandler,
BuildTimeExecutionTask, FactorizeQueueHandler, FactorizeTask, ProcessDependenciesQueueHandler,
};
pub use self::rebuild_deps_builder::RebuildDepsBuilder;
use crate::{
logger::Logger, tree_shaking::BailoutFlag, AddQueue, AddTask, AddTaskResult,
AsyncDependenciesBlock, AsyncDependenciesBlockIdentifier, BoxDependency, BuildDependency,
BuildQueue, BuildTask, BuildTaskResult, BuildTimeExecutionQueue, BuildTimeExecutionTask,
CacheOptions, CleanQueue, CleanTask, CleanTaskResult, Compilation, Context, ContextDependency,
DependencyId, DependencyParents, DependencyType, FactorizeQueue, FactorizeTask,
FactorizeTaskResult, GroupOptions, Module, ModuleCreationCallback, ModuleFactoryResult,
ModuleGraph, ModuleGraphModule, ModuleIdentifier, ModuleIssuer, ModuleProfile,
NormalModuleSource, ProcessDependenciesQueue, ProcessDependenciesResult, ProcessDependenciesTask,
Resolve, TaskResult, WorkerTask,
logger::Logger, tree_shaking::BailoutFlag, AsyncDependenciesBlock,
AsyncDependenciesBlockIdentifier, BoxDependency, BuildDependency, CacheOptions, Compilation,
Context, ContextDependency, DependencyId, DependencyParents, DependencyType, GroupOptions,
Module, ModuleFactoryResult, ModuleGraph, ModuleGraphModule, ModuleIdentifier, ModuleIssuer,
ModuleProfile, NormalModuleSource, Resolve,
};

mod rebuild_deps_builder;
pub use rebuild_deps_builder::RebuildDepsBuilder;

#[derive(Debug)]
pub enum MakeParam {
ModifiedFiles(HashSet<PathBuf>),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ use crate::{
BoxModule, DependencyId, ExecuteModuleResult, ExportInfo, ExportsInfo, QueueHandler, UsageState,
};

pub type CleanQueue = WorkerQueue<CleanTask, ModuleIdentifier>;

pub type ModuleCreationCallback = Box<dyn FnOnce(&BoxModule) + Send>;

pub type FactorizeQueueHandler = QueueHandler<FactorizeTask, DependencyId>;
pub type AddQueueHandler = QueueHandler<AddTask, ModuleIdentifier>;
pub type BuildQueueHandler = QueueHandler<BuildTask, ModuleIdentifier>;
pub type ProcessDependenciesQueueHandler = QueueHandler<ProcessDependenciesTask, ModuleIdentifier>;
pub type BuildTimeExecutionQueueHandler = QueueHandler<BuildTimeExecutionTask, ModuleIdentifier>;

#[derive(Debug)]
pub enum TaskResult {
Factorize(Box<FactorizeTaskResult>),
Expand Down Expand Up @@ -520,13 +530,3 @@ impl CleanTask {
}
}
}

pub type CleanQueue = WorkerQueue<CleanTask, ModuleIdentifier>;

pub type ModuleCreationCallback = Box<dyn FnOnce(&BoxModule) + Send>;

pub type FactorizeQueueHandler = QueueHandler<FactorizeTask, DependencyId>;
pub type AddQueueHandler = QueueHandler<AddTask, ModuleIdentifier>;
pub type BuildQueueHandler = QueueHandler<BuildTask, ModuleIdentifier>;
pub type ProcessDependenciesQueueHandler = QueueHandler<ProcessDependenciesTask, ModuleIdentifier>;
pub type BuildTimeExecutionQueueHandler = QueueHandler<BuildTimeExecutionTask, ModuleIdentifier>;
8 changes: 5 additions & 3 deletions crates/rspack_core/src/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ mod compilation;
mod execute_module;
mod hmr;
mod make;
mod queue;

use std::collections::hash_map::Entry;
use std::ops::Deref;
Expand All @@ -20,8 +19,11 @@ use tracing::instrument;

pub use self::compilation::*;
pub use self::hmr::{collect_changed_modules, CompilationRecords};
pub use self::make::MakeParam;
pub use self::queue::*;
pub use self::make::{
AddQueueHandler, BuildQueueHandler, BuildTimeExecutionOption, BuildTimeExecutionQueueHandler,
BuildTimeExecutionTask, FactorizeQueueHandler, FactorizeTask, MakeParam,
ProcessDependenciesQueueHandler,
};
use crate::cache::Cache;
use crate::tree_shaking::symbol::{IndirectType, StarSymbolKind, DEFAULT_JS_WORD};
use crate::tree_shaking::visitor::SymbolRef;
Expand Down

2 comments on commit 445ad62

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Ran ecosystem CI: Open

suite result
modernjs ✅ success
nx ✅ success
rspress ✅ success
rsbuild ✅ success
compat ✅ success
examples ✅ success

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Benchmark detail: Open

Name Base (2024-03-08 d7d87bb) Current Change
10000_development-mode + exec 1.71 s ± 28 ms 1.7 s ± 17 ms -0.33 %
10000_development-mode_hmr + exec 712 ms ± 4.7 ms 709 ms ± 3.7 ms -0.43 %
10000_production-mode + exec 2.75 s ± 45 ms 2.63 s ± 16 ms -4.56 %
arco-pro_development-mode + exec 2.44 s ± 28 ms 2.42 s ± 32 ms -1.21 %
arco-pro_development-mode_hmr + exec 508 ms ± 3.5 ms 509 ms ± 3.1 ms +0.09 %
arco-pro_development-mode_hmr_intercept-plugin + exec 525 ms ± 6.2 ms 524 ms ± 2.9 ms -0.21 %
arco-pro_development-mode_intercept-plugin + exec 3.26 s ± 52 ms 3.28 s ± 33 ms +0.45 %
arco-pro_production-mode + exec 4.03 s ± 36 ms 4.04 s ± 34 ms +0.03 %
arco-pro_production-mode_intercept-plugin + exec 4.9 s ± 44 ms 4.91 s ± 38 ms +0.16 %
threejs_development-mode_10x + exec 1.91 s ± 20 ms 1.92 s ± 18 ms +0.62 %
threejs_development-mode_10x_hmr + exec 725 ms ± 5.8 ms 721 ms ± 3.4 ms -0.47 %
threejs_production-mode_10x + exec 5.88 s ± 38 ms 5.86 s ± 117 ms -0.40 %

Please sign in to comment.