Skip to content

Instantly share code, notes, and snippets.

@classilla

classilla/firefox-pgo.diff

Last active Apr 21, 2021
Embed
What would you like to do?
PGO fixes and livability improvements for LTO in Firefox on ppc64le Linux. Read web page first! -- https://www.talospace.com/2021/04/firefox-88-on-power.html
diff -r e42e379b4dcc build/moz.configure/lto-pgo.configure
--- a/build/moz.configure/lto-pgo.configure Mon Apr 19 12:58:03 2021 +0000
+++ b/build/moz.configure/lto-pgo.configure Tue Apr 20 19:35:29 2021 -0700
@@ -82,17 +82,17 @@
@depends(c_compiler, pgo_profile_path, target_is_windows)
@imports("multiprocessing")
@imports(_from="__builtin__", _import="min")
def pgo_flags(compiler, profdata, target_is_windows):
if compiler.type == "gcc":
return namespace(
gen_cflags=["-fprofile-generate"],
gen_ldflags=["-fprofile-generate"],
- use_cflags=["-fprofile-use", "-fprofile-correction", "-Wcoverage-mismatch"],
+ use_cflags=["-fprofile-use", "-fprofile-correction", "-Wno-coverage-mismatch"],
use_ldflags=["-fprofile-use"],
)
if compiler.type in ("clang-cl", "clang"):
prefix = ""
if compiler.type == "clang-cl":
prefix = "/clang:"
gen_ldflags = None
@@ -235,23 +235,23 @@
"configure."
)
if c_compiler.type == "clang":
if len(value) and value[0].lower() == "full":
cflags.append("-flto")
ldflags.append("-flto")
else:
- cflags.append("-flto=thin")
- ldflags.append("-flto=thin")
+ cflags.append("-flto")
+ ldflags.append("-flto")
elif c_compiler.type == "clang-cl":
if len(value) and value[0].lower() == "full":
cflags.append("-flto")
else:
- cflags.append("-flto=thin")
+ cflags.append("-flto")
# With clang-cl, -flto can only be used with -c or -fuse-ld=lld.
# AC_TRY_LINKs during configure don't have -c, so pass -fuse-ld=lld.
cflags.append("-fuse-ld=lld")
# Explicitly set the CPU to optimize for so the linker doesn't
# choose a poor default. Rust compilation by default uses the
# pentium4 CPU on x86:
#
diff -r e42e379b4dcc build/pgo/profileserver.py
--- a/build/pgo/profileserver.py Mon Apr 19 12:58:03 2021 +0000
+++ b/build/pgo/profileserver.py Tue Apr 20 19:35:29 2021 -0700
@@ -82,19 +82,32 @@
docroot=os.path.join(build.topsrcdir, "build", "pgo"),
path_mappings=path_mappings,
)
httpd.start(block=False)
locations = ServerLocations()
locations.add_host(host="127.0.0.1", port=PORT, options="primary,privileged")
- old_profraw_files = glob.glob("*.profraw")
- for f in old_profraw_files:
- os.remove(f)
+ using_gcc = False
+ try:
+ if build.config_environment.substs.get('CC_TYPE') == 'gcc':
+ using_gcc = True
+ except BuildEnvironmentNotFoundException:
+ pass
+
+ if using_gcc:
+ for dirpath, _, filenames in os.walk('.'):
+ for f in filenames:
+ if f.endswith('.gcda'):
+ os.remove(os.path.join(dirpath, f))
+ else:
+ old_profraw_files = glob.glob('*.profraw')
+ for f in old_profraw_files:
+ os.remove(f)
with TemporaryDirectory() as profilePath:
# TODO: refactor this into mozprofile
profile_data_dir = os.path.join(build.topsrcdir, "testing", "profiles")
with open(os.path.join(profile_data_dir, "profiles.json"), "r") as fh:
base_profiles = json.load(fh)["profileserver"]
prefpaths = [
@@ -207,16 +220,20 @@
# Try to move the crash reports to the artifacts even if Firefox appears
# to exit successfully, in case there's a crash that doesn't set the
# return code to non-zero for some reason.
if get_crashreports(profilePath, name="Firefox exited successfully?") != 0:
print("Firefox exited successfully, but produced a crashreport")
sys.exit(1)
+ print('Copying profile data....')
+ os.system('pwd');
+ os.system('tar cf profdata.tar.gz `find . -name "*.gcda"`; cd ..; tar xf instrumented/profdata.tar.gz;');
+
llvm_profdata = env.get("LLVM_PROFDATA")
if llvm_profdata:
profraw_files = glob.glob("*.profraw")
if not profraw_files:
print(
"Could not find profraw files in the current directory: %s"
% os.getcwd()
)
diff -r e42e379b4dcc mfbt/tests/moz.build
--- a/mfbt/tests/moz.build Mon Apr 19 12:58:03 2021 +0000
+++ b/mfbt/tests/moz.build Tue Apr 20 19:35:29 2021 -0700
@@ -73,21 +73,21 @@
"TestWrappingOperations",
"TestXorShift128PlusRNG",
]
)
# Not to be unified with the rest, because this test
# sets MOZ_PRETEND_NO_JSRUST, which changes the behavior
# of the included headers.
-CppUnitTests(
- [
- "TestUtf8",
- ]
-)
+#CppUnitTests(
+# [
+# "TestUtf8",
+# ]
+#)
if not CONFIG["MOZ_ASAN"]:
CppUnitTests(
[
"TestPoisonArea",
]
)
diff -r e42e379b4dcc toolkit/components/terminator/nsTerminator.cpp
--- a/toolkit/components/terminator/nsTerminator.cpp Mon Apr 19 12:58:03 2021 +0000
+++ b/toolkit/components/terminator/nsTerminator.cpp Tue Apr 20 19:35:29 2021 -0700
@@ -451,16 +451,21 @@
// Defend against overflow
crashAfterMS = INT32_MAX;
} else {
crashAfterMS *= scaleUp;
}
}
#endif
+ // Disable watchdog for PGO train builds - writting profile information at
+ // exit may take time and it is better to make build hang rather than
+ // silently produce poorly performing binary.
+ crashAfterMS = INT32_MAX;
+
UniquePtr<Options> options(new Options());
const PRIntervalTime ticksDuration =
PR_MillisecondsToInterval(HEARTBEAT_INTERVAL_MS);
options->crashAfterTicks = crashAfterMS / ticksDuration;
// Handle systems where ticksDuration is greater than crashAfterMS.
if (options->crashAfterTicks == 0) {
options->crashAfterTicks = crashAfterMS / HEARTBEAT_INTERVAL_MS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment