Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d6ab48c6 authored by Yi Kong's avatar Yi Kong
Browse files

Limit LTO inlining even when profile is present

Reduce the import instr limit from the LLVM default (100) to 40. This
helps reduce the binary size as well as improving performance slightly.

Size:
             Default(100)   40        30
libhwui.so   11059040       11058912  11060872
libart.so    10697576       10697160  10696568

Performance:
40 vs. default:  0.37% improvement
                 http://go/art-benchmark?p=BootImageProfileId:36054
30 vs. default:  0.36% improvement
                 http://go/art-benchmark?p=BootImageProfileId:36058

Test: presubmit
Change-Id: Id800ff7818cde908daab784bac0a312c6a71272d
parent 1e079dfd
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -135,11 +135,15 @@ func (lto *lto) flags(ctx BaseModuleContext, flags Flags) Flags {
			ltoLdFlags = append(ltoLdFlags, cachePolicyFormat+policy)
		}

		// If the module does not have a profile, be conservative and limit cross TU inline
		// limit to 5 LLVM IR instructions, to balance binary size increase and performance.
		if !ctx.Darwin() && !ctx.isPgoCompile() && !ctx.isAfdoCompile() {
		// Reduce the inlining threshold for a better balance of binary size and
		// performance.
		if !ctx.Darwin() {
			if ctx.isPgoCompile() || ctx.isAfdoCompile() {
				ltoLdFlags = append(ltoLdFlags, "-Wl,-plugin-opt,-import-instr-limit=40")
			} else {
				ltoLdFlags = append(ltoLdFlags, "-Wl,-plugin-opt,-import-instr-limit=5")
			}
		}

		flags.Local.CFlags = append(flags.Local.CFlags, ltoCFlags...)
		flags.Local.AsFlags = append(flags.Local.AsFlags, ltoCFlags...)