Closed Bug 1833676 Opened 3 years ago Closed 3 years ago

Building libpref takes tons of memory and time.

Categories

(Core :: Preferences: Backend, defect)

defect

Tracking

()

RESOLVED FIXED
115 Branch
Tracking Status
firefox115 --- fixed

People

(Reporter: emilio, Assigned: glandium)

Details

Attachments

(1 external file)

This command is always one of the last things to finish in my builds:

/home/emilio/.mozbuild/clang/bin/clang++ -x c++ -c Unified_cpp_modules_libpref0.cpp -o Unified_cpp_modules_libpref0.o -I/home/emilio/src/moz/gecko/obj-debug/dist/stl_wrappers -I/home/emilio/src/moz/gecko/obj-debug/dist/system_wrappers -include /home/emilio/src/moz/gecko/config/gcc_hidden.h -I/home/emilio/src/moz/gecko/modules/libpref -I/home/emilio/src/moz/gecko/obj-debug/modules/libpref -I/home/emilio/src/moz/gecko/obj-debug/ipc/ipdl/_ipdlheaders -I/home/emilio/src/moz/gecko/ipc/chromium/src -I/home/emilio/src/moz/gecko/obj-debug/dist/include -I/home/emilio/src/moz/gecko/obj-debug/dist/include/nspr -I/home/emilio/src/moz/gecko/obj-debug/dist/include/nss -include /home/emilio/src/moz/gecko/obj-debug/mozilla-config.h --sysroot /home/emilio/.mozbuild/sysroot-x86_64-linux-gnu -Qunused-arguments -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fstack-clash-protection -ftrivial-auto-var-init=pattern -DDEBUG=1 -DOS_POSIX=1 -DOS_LINUX=1 -DOS_ARCH=Linux -DMOZ_WIDGET_TOOLKIT=gtk -DMOZ_SERVICES_SYNC -DMOZ_BUILD_APP_IS_BROWSER -DMOZ_HAS_MOZGLUE -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL -DSTATIC_EXPORTABLE_JS_API -DMOZILLA_CLIENT -fno-sized-deallocation -fno-aligned-new -fno-exceptions -fPIC -fno-rtti -fno-exceptions -fno-math-errno -pthread -pipe -gdwarf-4 -Os -fno-omit-frame-pointer -funwind-tables -Wall -Wbitfield-enum-conversion -Wdeprecated-this-capture -Wempty-body -Wformat-type-confusion -Wignored-qualifiers -Wpointer-arith -Wshadow-field-in-constructor-modified -Wsign-compare -Wtautological-constant-in-range-compare -Wtype-limits -Wno-error=tautological-type-limit-compare -Wunreachable-code -Wunreachable-code-return -Wunused-but-set-parameter -Wno-invalid-offsetof -Wclass-varargs -Wempty-init-stmt -Wfloat-overflow-conversion -Wfloat-zero-conversion -Wloop-analysis -Wno-range-loop-analysis -Wc++2a-compat -Wenum-compare-conditional -Wenum-float-conversion -Wno-ambiguous-reversed-operator -Wno-error=deprecated -Wno-error=deprecated-anon-enum-enum-conversion -Wno-error=deprecated-enum-enum-conversion -Wno-error=deprecated-pragma -Wno-error=deprecated-this-capture -Wcomma -Wimplicit-fallthrough -Wstring-conversion -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wformat -Wformat-security -Wno-psabi -Wthread-safety -Wno-unknown-warning-option -fno-strict-aliasing -ffp-contract=off -fcolor-diagnostics

That only has Preferences.cpp and SharedPrefMap.cpp

Waw

	User time (seconds): 97.80
	System time (seconds): 2.83
	Percent of CPU this job got: 99%
	Elapsed (wall clock) time (h:mm:ss or m:ss): 1:40.65
	Average shared text size (kbytes): 0
	Average unshared data size (kbytes): 0
	Average stack size (kbytes): 0
	Average total size (kbytes): 0
	Maximum resident set size (kbytes): 10332428
	Average resident set size (kbytes): 0
	Major (requiring I/O) page faults: 0
	Minor (reclaiming a frame) page faults: 1917422
	Voluntary context switches: 1
	Involuntary context switches: 439
	Swaps: 0
	File system inputs: 0
	File system outputs: 0
	Socket messages sent: 0
	Socket messages received: 0
	Signals delivered: 0
	Page size (bytes): 4096
	Exit status: 0

On a non-debug build:

	User time (seconds): 14.82
	System time (seconds): 1.30
	Percent of CPU this job got: 99%
	Elapsed (wall clock) time (h:mm:ss or m:ss): 0:16.13
	Average shared text size (kbytes): 0
	Average unshared data size (kbytes): 0
	Average stack size (kbytes): 0
	Average total size (kbytes): 0
	Maximum resident set size (kbytes): 4539388
	Average resident set size (kbytes): 0
	Major (requiring I/O) page faults: 0
	Minor (reclaiming a frame) page faults: 987632
	Voluntary context switches: 1
	Involuntary context switches: 45
	Swaps: 0
	File system inputs: 0
	File system outputs: 0
	Socket messages sent: 0
	Socket messages received: 0
	Signals delivered: 0
	Page size (bytes): 4096
	Exit status: 0

Much better, although it's surprisingly using a lot of memory. There must be something in the debug code...

Summary from -ftime-report:
Pass execution: 8.7585s
Analysis execution: 0.4480s
Miscellaneous Ungrouped Timers: 13.0692s
Register Allocation: 0.2266s
Instruction Selection and Scheduling: 0.6104s
Pass execution: 3.0160s
DWARF Emission: 0.0910s
Clang front-end: 81.6825s

It's -Wthread-safety.

I get down to 37s with:

--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -5899,6 +5899,7 @@ static void RegisterOncePrefs(SharedPrefMapBuilder& aBuilder) {
 #undef ONCE_PREF
 }
 
+MOZ_NO_THREAD_SAFETY_ANALYSIS
 static void InitStaticPrefsFromShared() {
   MOZ_ASSERT(!XRE_IsParentProcess());
   MOZ_DIAGNOSTIC_ASSERT(gSharedMap,
Assignee: nobody → mh+mozilla
Status: NEW → ASSIGNED

Also memory usage is down to less than 800MB.

Pushed by mh@glandium.org: https://hg.mozilla.org/integration/autoland/rev/7f9dab078c06 Disable thread safety analysis on InitStaticPrefsFromShared. r=KrisWright
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 115 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: