Skip to content

Commit

Permalink
[wasm] Disable interp pgo recording by default since it adds startup …
Browse files Browse the repository at this point in the history
…overhead (dotnet#101566)

* Disable interp pgo recording by default since it adds startup overhead
* Make withRuntimeOptions not trample existing runtime options
  • Loading branch information
kg authored and matouskozak committed Apr 30, 2024
1 parent 4a62150 commit 96283ce
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
11 changes: 8 additions & 3 deletions src/mono/browser/runtime/loader/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ export class HostBuilder implements DotnetHostBuilder {
interpreterPgo: value,
interpreterPgoSaveDelay: autoSaveDelay
});
if (monoConfig.runtimeOptions)
monoConfig.runtimeOptions.push("--interp-pgo-recording");
else
monoConfig.runtimeOptions = ["--interp-pgo-recording"];
return this;
} catch (err) {
mono_exit(1, err);
Expand Down Expand Up @@ -268,9 +272,10 @@ export class HostBuilder implements DotnetHostBuilder {
withRuntimeOptions (runtimeOptions: string[]): DotnetHostBuilder {
try {
mono_assert(runtimeOptions && Array.isArray(runtimeOptions), "must be array of strings");
deep_merge_config(monoConfig, {
runtimeOptions
});
if (monoConfig.runtimeOptions)
monoConfig.runtimeOptions.push(...runtimeOptions);
else
monoConfig.runtimeOptions = runtimeOptions;
return this;
} catch (err) {
mono_exit(1, err);
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/utils/options-def.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ DEFINE_BOOL(wasm_exceptions, "wasm-exceptions", FALSE, "Enable codegen for WASM
DEFINE_BOOL(aot_lazy_assembly_load, "aot-lazy-assembly-load", FALSE, "Load assemblies referenced by AOT images lazily")

#if HOST_BROWSER
DEFINE_BOOL(interp_pgo_recording, "interp-pgo-recording", TRUE, "Record interpreter tiering information for automatic PGO")
DEFINE_BOOL(interp_pgo_recording, "interp-pgo-recording", FALSE, "Record interpreter tiering information for automatic PGO")
#else
DEFINE_BOOL(interp_pgo_recording, "interp-pgo-recording", FALSE, "Record interpreter tiering information for automatic PGO")
DEFINE_BOOL(wasm_gc_safepoints, "wasm-gc-safepoints", FALSE, "Use GC safepoints on WASM")
Expand Down
5 changes: 0 additions & 5 deletions src/mono/sample/wasm/browser-bench/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,6 @@ try {
// console to see statistics on how much code it generated and whether any new opcodes
// are causing traces to fail to compile
.withRuntimeOptions(["--jiterpreter-stats-enabled"])
// We enable interpreter PGO so that you can exercise it in local tests, i.e.
// run browser-bench one, then refresh the tab to measure the performance improvement
// on the second run of browser-bench. The overall speed of the benchmarks won't
// improve much, but the time spent generating code during the run will go down
.withInterpreterPgo(true, 30)
.withElementOnExit()
.withExitCodeLogging()
.create();
Expand Down
6 changes: 3 additions & 3 deletions src/mono/wasm/testassets/WasmBasicTestApp/App/wwwroot/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ switch (testCase) {
let alreadyFailed = [];
dotnet.withDiagnosticTracing(true).withResourceLoader((type, name, defaultUri, integrity, behavior) => {
if (type === "dotnetjs") {
// loadBootResource could return string with unqualified name of resource.
// loadBootResource could return string with unqualified name of resource.
// It assumes that we resolve it with document.baseURI
// we test it here
return `_framework/${name}`;
Expand Down Expand Up @@ -131,8 +131,8 @@ try {
}
});
const iterationCount = params.get("iterationCount") ?? 70;
for (let i = 0; i < iterationCount; i++) {
exports.InterpPgoTest.Greeting();
for (let i = 0; i < iterationCount; i++) {
exports.InterpPgoTest.Greeting();
};
await INTERNAL.interp_pgo_save_data();
exit(0);
Expand Down

0 comments on commit 96283ce

Please sign in to comment.