New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 846464 link

Starred by 5 users

Issue metadata

Status: Fixed
Owner:
Closed: Oct 15
Cc:
EstimatedDays: ----
NextAction: ----
OS: Linux , Android
Pri: 3
Type: Bug

Blocked on:
issue 871418

Blocking:
issue 838413



Sign in to add a comment

Enable ICF on rodata

Project Member Reported by p...@chromium.org, May 24 2018

Issue description

lld has a flag --ignore-data-address-equality that enables ICF on rodata. I sent a tryjob to enable the flag: https://chromium-review.googlesource.com/c/chromium/src/+/1069741

That uncovered a couple of bugs in lld, which I fixed.
https://reviews.llvm.org/D47241
https://reviews.llvm.org/D47242

We should wait for a clang roll, rerun the tryjob, see what else breaks if we turn it on, and if feasible, try to work on turning it on.

If infeasible, we could try enabling an upcoming lld feature, safe ICF (done properly), on rodata. I've sent a proposal to llvm-dev to allow safe ICF in general: http://lists.llvm.org/pipermail/llvm-dev/2018-May/123514.html

We already enable --icf=all in chromium. I'm imagining that we'd change lld to make that flag mean --icf=all for text, and --icf=safe for rodata.
 

Comment 1 by pasko@chromium.org, May 29 2018

Sounds cool!

A few questions:

1. What would be the impact on the binary size?

2. What happens if a piece of rodata is both in __attribute__((section("rodata_unlikely"))) and in the main .rodata? Would we be able to guarantee that it does not get folded in this case? Another option would be to put it always outside "rodata_unlikely" when there is folding.

3. naming bikeshed: should this be s/ICF/IDF/ ?

Comment 2 by p...@chromium.org, May 29 2018

1. Haven't measured it yet. I was going to do that after the clang roll.

2. In that case they wouldn't be merged (previously we would merge them, but that was a bug that I fixed in https://reviews.llvm.org/D47241). I can't see a safe generic rule that we can implement in the linker for merging between output sections.

3. We probably don't want to rename the flags since they've been around for a while. Maybe we could redefine the C to stand for "Code+Data"? :-)

Comment 3 by pasko@chromium.org, May 30 2018

great! thank you for the answers, Peter

Comment 4 by p...@chromium.org, Jun 15 2018

I reran the tryjob after the clang roll: https://chromium-review.googlesource.com/c/chromium/src/+/1069741
and there were still quite a few failures. I don't know how many root causes there are, though.

Here's what the MonochromePublic.apk size looks like if I enable --icf=safe on rodata with my upcoming safe ICF patches (patch series ending in https://reviews.llvm.org/D48146 plus some optimizations that I haven't sent for review yet).

Before: 125781815 bytes
After: 124868407 bytes

i.e. over 900KB reduction.

I also compared the size of 64-bit libmonochrome.so varying whether we do --icf=safe or --icf=all on rodata:

--icf=safe: 56616152 bytes
--icf=all: 56517480 bytes

i.e. around 100KB.

(I tried to compare the size of 32-bit libmonochrome.so in the same way but it looks like lld currently has a bug which causes it to hang if I try to link with --icf=all on rodata. Nevertheless I think we should expect to see around 100KB savings on 32-bit as well.)

So even with just --icf=safe that should get us most of the size reduction.
Blockedon: -845798 866225
My safe ICF patches (including the patch that implements safe ICF on rodata with --icf=all) have landed as of clang r337640, so we should expect to see the ~900KB reduction when the next clang roll happens.
The clang roll landed in r579922, but the size reduction was only 8KB.

https://chromeperf.appspot.com/report?sid=ed9062e858640e2505914167e530b717bbb0f6d588463571ef837c7aadb2928e&rev=579922

One thing that changed since I last took measurements was that we turned on ThinLTO in official Android builds. I think I know what the problem is: we need to enable the object file metadata that allows for safe ICF in the LTO component of the linker. It should be an easy fix, so assuming that I'm correct we should expect to see the size reduction in the *next* clang roll.
https://reviews.llvm.org/D50221

Local apk size measurements are:
123656720 bytes without the fix
123063360 bytes with the fix.
Blockedon: -866225 871418
Landed in r339050, so this should finally get resolved once the roll happens.
Blocking: 838413
I think this is fixed now?
Status: Fixed (was: Started)
In terms of arm32, the clang roll containing this decreased libmonochrome.so by 265442 bytes.

https://chromeperf.appspot.com/report?sid=c818fc25c83582d53c59097a06a6fc33da0cbe0a039bd2845a32f96e3bd3044d&rev=582951


Sign in to add a comment