Skip to content

Commit

Permalink
refactor: remove profile integration timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
LingyuCoder committed Jun 27, 2024
1 parent 7be2767 commit 3e8e673
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 99 deletions.
1 change: 0 additions & 1 deletion crates/node_binding/binding.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,6 @@ export interface JsStatsModuleIssuer {

export interface JsStatsModuleProfile {
factory: JsStatsMillisecond
integration: JsStatsMillisecond
building: JsStatsMillisecond
}

Expand Down
2 changes: 0 additions & 2 deletions crates/rspack_binding_values/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,13 @@ impl TryFrom<rspack_core::StatsModule<'_>> for JsStatsModule {
#[napi(object)]
pub struct JsStatsModuleProfile {
pub factory: JsStatsMillisecond,
pub integration: JsStatsMillisecond,
pub building: JsStatsMillisecond,
}

impl From<rspack_core::StatsModuleProfile> for JsStatsModuleProfile {
fn from(value: rspack_core::StatsModuleProfile) -> Self {
Self {
factory: value.factory.into(),
integration: value.integration.into(),
building: value.building.into(),
}
}
Expand Down
8 changes: 0 additions & 8 deletions crates/rspack_core/src/compiler/make/repair/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ impl Task<MakeTaskContext> for AddTask {
TaskType::Sync
}
fn sync_run(self: Box<Self>, context: &mut MakeTaskContext) -> TaskResult<MakeTaskContext> {
if let Some(current_profile) = &self.current_profile {
current_profile.mark_integration_start();
}

let module_identifier = self.module.identifier();
let artifact = &mut context.artifact;
let module_graph =
Expand Down Expand Up @@ -72,10 +68,6 @@ impl Task<MakeTaskContext> for AddTask {
module_identifier,
)?;

if let Some(current_profile) = &self.current_profile {
current_profile.mark_integration_end();
}

tracing::trace!("Module added: {}", self.module.identifier());

artifact.built_modules.insert(module_identifier);
Expand Down
79 changes: 3 additions & 76 deletions crates/rspack_core/src/module_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,13 @@ impl ModulePhaseProfile {
}
}

// https://github.com/webpack/webpack/blob/4809421990a20dfefa06e6445191e65001e75f88/lib/ModuleProfile.js
// NOTE: Rspack has different cache design, remove cache related profiles

#[derive(Debug, Default, Clone)]
pub struct ModuleProfile {
pub factory: ModulePhaseProfile,
// pub restoring: ModulePhaseProfile,
pub integration: ModulePhaseProfile,
pub building: ModulePhaseProfile,
// pub storing: ModulePhaseProfile,

// pub additional_factory_times: Vec<TimeRange>,
// pub additional_factories: Duration,
// pub additional_factories_parallelism_factor: u16,
}

impl ModuleProfile {
Expand All @@ -78,43 +74,6 @@ impl ModuleProfile {
.expect("should only call once");
}

// TODO: restore module to cache is not implemented yet
// pub fn mark_restoring_start(&self) {
// self
// .restoring
// .range
// .start
// .set(Instant::now())
// .expect("should only call once");
// }

// pub fn mark_restoring_end(&self) {
// self
// .restoring
// .range
// .end
// .set(Instant::now())
// .expect("should only call once");
// }

pub fn mark_integration_start(&self) {
self
.integration
.range
.start
.set(Instant::now())
.expect("should only call once");
}

pub fn mark_integration_end(&self) {
self
.integration
.range
.end
.set(Instant::now())
.expect("should only call once");
}

pub fn mark_building_start(&self) {
self
.building
Expand All @@ -132,36 +91,4 @@ impl ModuleProfile {
.set(Instant::now())
.expect("should only call once");
}

// TODO: store module to cache is not implemented yet
// pub fn mark_storing_start(&self) {
// self
// .storing
// .range
// .start
// .set(Instant::now())
// .expect("should only call once");
// }

// pub fn mark_storing_end(&self) {
// self
// .storing
// .range
// .end
// .set(Instant::now())
// .expect("should only call once");
// }

// pub fn merge(&mut self, other: Self) {
// self.additional_factories += other.factory.duration().expect("should have duration");
// self.additional_factory_times.push(TimeRange::with_value(
// *other
// .factory
// .range
// .start
// .get()
// .expect("should have duration"),
// *other.factory.range.end.get().expect("should have duration"),
// ));
// }
}
3 changes: 0 additions & 3 deletions crates/rspack_core/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,12 +689,10 @@ impl Stats<'_> {
.transpose()?;
let profile = if let Some(p) = mgm.get_profile()
&& let Some(factory) = p.factory.duration()
&& let Some(integration) = p.integration.duration()
&& let Some(building) = p.building.duration()
{
Some(StatsModuleProfile {
factory: StatsMillisecond::new(factory.as_secs(), factory.subsec_millis()),
integration: StatsMillisecond::new(integration.as_secs(), integration.subsec_millis()),
building: StatsMillisecond::new(building.as_secs(), building.subsec_millis()),
})
} else {
Expand Down Expand Up @@ -1107,7 +1105,6 @@ pub enum StatsUsedExports {
#[derive(Debug)]
pub struct StatsModuleProfile {
pub factory: StatsMillisecond,
pub integration: StatsMillisecond,
pub building: StatsMillisecond,
}

Expand Down
8 changes: 4 additions & 4 deletions packages/rspack-test-tools/tests/statsAPICases/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ module.exports = {
stats?.toString({ all: false, modules: true }).replace(/\d+ ms/g, "X ms")
).toMatchInlineSnapshot(`
"./fixtures/abc.js 83 bytes [built] [code generated]
X ms (resolving: X ms, integration: X ms, building: X ms)
X ms (resolving: X ms, building: X ms)
./fixtures/a.js 55 bytes [built] [code generated]
X ms (resolving: X ms, integration: X ms, building: X ms)
X ms (resolving: X ms, building: X ms)
./fixtures/b.js 94 bytes [built] [code generated]
X ms (resolving: X ms, integration: X ms, building: X ms)
X ms (resolving: X ms, building: X ms)
./fixtures/c.js 72 bytes [built] [code generated]
X ms (resolving: X ms, integration: X ms, building: X ms)"
X ms (resolving: X ms, building: X ms)"
`);
}
};
1 change: 0 additions & 1 deletion packages/rspack/etc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4396,7 +4396,6 @@ type KnownStatsPrinterContext = {
type KnownStatsProfile = {
total: number;
resolving: number;
integration: number;
building: number;
};

Expand Down
4 changes: 1 addition & 3 deletions packages/rspack/src/stats/DefaultStatsFactoryPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -877,12 +877,10 @@ const SIMPLE_EXTRACTORS: SimpleExtractors = {
profile: {
_: (object, profile) => {
const factory = resolveStatsMillisecond(profile.factory);
const integration = resolveStatsMillisecond(profile.integration);
const building = resolveStatsMillisecond(profile.building);
const statsProfile: StatsProfile = {
total: factory + integration + building,
total: factory + building,
resolving: factory,
integration,
building
};
Object.assign(object, statsProfile);
Expand Down
1 change: 0 additions & 1 deletion packages/rspack/src/stats/statsFactoryUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export type StatsProfile = KnownStatsProfile & Record<string, any>;
export type KnownStatsProfile = {
total: number;
resolving: number;
integration: number;
building: number;
};

Expand Down

0 comments on commit 3e8e673

Please sign in to comment.