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

refactor: allocator !macos !linux !windows #8290

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
13 changes: 11 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions crates/node_binding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ impl Rspack {
) -> Result<Self> {
tracing::info!("raw_options: {:#?}", &options);

let mut compiler_options: rspack_core::CompilerOptions = options
.try_into()
.map_err(|e| Error::from_reason(format!("{e}")))?;

let mut plugins = Vec::new();
let js_plugin = JsHooksAdapterPlugin::from_js_hooks(env, register_js_taps)?;
plugins.push(js_plugin.clone().boxed());
for bp in builtin_plugins {
bp.append_to(env, &mut plugins)
bp.append_to(&mut plugins)
.map_err(|e| Error::from_reason(format!("{e}")))?;
}

let compiler_options: rspack_core::CompilerOptions = options
.try_into()
.map_err(|e| Error::from_reason(format!("{e}")))?;

tracing::info!("normalized_options: {:#?}", &compiler_options);

let resolver_factory =
Expand Down
6 changes: 6 additions & 0 deletions crates/rspack_allocator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ mimalloc = { workspace = true, features = ["local_dynamic_tls"] }

[target.'cfg(not(target_os = "linux"))'.dependencies]
mimalloc = { workspace = true }

# [target.'cfg(target_os = "linux")'.dependencies]
# snmalloc-rs = { version = "0.3.6", features = ["local_dynamic_tls"] }

# [target.'cfg(not(target_os = "linux"))'.dependencies]
# snmalloc-rs = { version = "0.3.6" }
4 changes: 2 additions & 2 deletions crates/rspack_binding_options/src/options/raw_builtins/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use napi_derive::napi;
use raw_dll::{RawDllReferenceAgencyPluginOptions, RawFlagAllModulesAsUsedPluginOptions};
use raw_lightning_css_minimizer::RawLightningCssMinimizerRspackPluginOptions;
use rspack_binding_values::entry::JsEntryPluginOptions;
use rspack_core::{BoxPlugin, Plugin, PluginExt};
use rspack_core::{BoxPlugin, CompilerOptions, Plugin, PluginExt};
use rspack_error::Result;
use rspack_ids::{
DeterministicChunkIdsPlugin, DeterministicModuleIdsPlugin, NamedChunkIdsPlugin,
Expand Down Expand Up @@ -204,7 +204,7 @@ pub struct BuiltinPlugin {
}

impl BuiltinPlugin {
pub fn append_to(self, _env: Env, plugins: &mut Vec<BoxPlugin>) -> rspack_error::Result<()> {
pub fn append_to(self, plugins: &mut Vec<BoxPlugin>) -> rspack_error::Result<()> {
match self.name {
// webpack also have these plugins
BuiltinPluginName::DefinePlugin => {
Expand Down
11 changes: 10 additions & 1 deletion crates/rspack_core/src/code_generation_results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@
debug_assert!(result.is_none());
}

pub fn inner_size(&self) -> usize {
self.inner.iter().fold(0, |mut acc, (_, s)| {
acc += s.buffer().len();
acc
})
}

pub fn set_hash(
&mut self,
hash_function: &HashFunction,
Expand Down Expand Up @@ -218,9 +225,11 @@
runtimes: impl IntoIterator<Item = RuntimeSpec>,
) {
let codegen_res_id = codegen_res.id;
self
let a = self
.module_generation_result_map
.insert(codegen_res_id, codegen_res);
dbg!(codegen_res_id);

Check failure on line 231 in crates/rspack_core/src/code_generation_results.rs

View workflow job for this annotation

GitHub Actions / Rust check

the `dbg!` macro is intended as a debugging tool
assert!(a.is_none());
for runtime in runtimes {
self.add(module_identifier, runtime, codegen_res_id);
}
Expand Down
10 changes: 10 additions & 0 deletions crates/rspack_core/src/compiler/hmr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ impl Compiler {
self.input_filesystem.clone(),
);

println!(
"new compilation code generation results: {}",
new_compilation
.code_generation_results
.clone()
.into_inner()
.1
.len()
);

new_compilation.hot_index = self.compilation.hot_index + 1;

if new_compilation
Expand Down
1 change: 1 addition & 0 deletions crates/rspack_core/src/old_cache/occasion/code_generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ impl CodeGenerateOccasion {
} else {
match provide(job.module, &job.runtime) {
Ok(res) => {
println!("{cache_key}: {}", res.inner_size());
storage.set(cache_key, res.clone());
(Ok(res), job.runtimes, false)
}
Expand Down
4 changes: 4 additions & 0 deletions crates/rspack_plugin_devtool/src/mapped_assets_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ impl MappedAssetsCache {
mapped_asstes.extend(map_assets(vanilla_assets).await?);

self.0.clear();
dbg!(mapped_asstes
.iter()
.map(|a| { a.asset.0.clone() })
.collect::<Vec<String>>());
for mapped_asset in &mapped_asstes {
let MappedAsset {
asset: (filename, asset),
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export class RspackCLI {
item => item instanceof rspackCore.ProgressPlugin
);
if (!installed) {
(item.plugins ??= []).push(new rspackCore.ProgressPlugin());
// (item.plugins ??= []).push(new rspackCore.ProgressPlugin());
}
}

Expand Down
Loading