Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[web] Improve CPU usage when building wasm_release #37294

Merged
merged 3 commits into from
Nov 4, 2022
Merged
Changes from 2 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
14 changes: 11 additions & 3 deletions lib/web_ui/dev/build.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class BuildCommand extends Command<bool> with ArgUtils<bool> {
final FilePath libPath = FilePath.fromWebUi('lib');
final List<PipelineStep> steps = <PipelineStep>[
GnPipelineStep(buildCanvasKit: buildCanvasKit, host: host),
NinjaPipelineStep(target: host ? environment.hostDebugUnoptDir : environment.wasmReleaseOutDir),
NinjaPipelineStep(host: host),
];
final Pipeline buildPipeline = Pipeline(steps: steps);
await buildPipeline.run();
Expand Down Expand Up @@ -115,23 +115,31 @@ class GnPipelineStep extends ProcessStep {
///
/// Can be safely interrupted.
class NinjaPipelineStep extends ProcessStep {
NinjaPipelineStep({required this.target});
NinjaPipelineStep({required this.host});

@override
String get description => 'ninja';

@override
bool get isSafeToInterrupt => true;

final bool host;

/// The target directory to build.
final Directory target;
Directory get target =>
host ? environment.hostDebugUnoptDir : environment.wasmReleaseOutDir;

@override
Future<ProcessManager> createProcess() {
print('Running autoninja...');
return startProcess(
'autoninja',
<String>[
// When building the wasm target that includes CanvasKit, we need to use
// `--offline` to prevent `autoninja` from using `goma` which would lead
// to a high `-j` value that causes high CPU usage. This is because goma
// doesn't support emscripten yet.
if (!host) '--offline',
'-C',
target.path,
],
Expand Down