Information on how to reduce the binary size?

1,758 views
Skip to first unread message

Dudi Patimer

unread,
Feb 25, 2022, 5:53:36 PM2/25/22
to Chromium-dev
Hi,

I'm trying to find information on how to reduce chrome binary size on linux?

After building chromium according to the instructions, the binary size is ~1.3GB (using is_debug = false) and I'm wondering if there is any instructions on how can it be reduced as I've noticed the size is just 83MB when downloading the binary?

Thanks,
Dudi


Sven Zheng

unread,
Feb 25, 2022, 6:30:00 PM2/25/22
to dud...@gmail.com, Chromium-dev
I think you can use is_official_build=true to optimize.
Also, the binary is large because it contains symbols. You can use the 'strip' command on linux to reduce the binary size. Or use 'symbol_level=0'.

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/ac284838-47b7-44e7-a7e0-8f6ec1543f0cn%40chromium.org.

Dudi Patimer

unread,
Feb 28, 2022, 12:11:29 AM2/28/22
to Chromium-dev, sven...@chromium.org, Chromium-dev, Dudi Patimer
Thanks.

Indeed 'strip' command reduced the binary size to ~260MB.

The other build flags didn't seems to affect, I've already used the following: 

symbol_level = 0
blink_symbol_level = 0
v8_symbol_level = 0
is_official_build = true
is_debug = false


Thanks,
Dudi

Bruce Dawson

unread,
Feb 28, 2022, 10:16:11 PM2/28/22
to Chromium-dev, dud...@gmail.com, sven...@chromium.org, Chromium-dev
Once you are stripping the binary you don't need to set the symbol_level settings to zero, because that just reduces the amount of debug information and stripping should remove that. If you leave the symbol_level settings alone (or set symbol_level=2) then you will have a binary that you can debug, which is valuable.

What binary are you seeing is 83 MB on Linux? The chrome binary on my Linux machine is 189 MB, and there are many other files needed to run Chrome so the total is probably close to 260 MB. Also, binary or metric MB? I'm using metric MB. Either way, if you're seeing an 83 MB Chrome binary on Linux it is probably an installer package or something like that and hence compressed, because the main Chrome binary is much larger than that.

The only other settings I see for our official Linux builds are dcheck_always_on = false and is_chrome_branded = true. I'm not sure what the default is for dcheck_always_on in official builds, so try setting that. You can't set is_chrome_branded unless you work at Google, and that wouldn't cause huge size differences anyway.

Let us know what instructions you were using and maybe we can improve them - it sounds like mentioning "strip", and possibly "dcheck_always_on = false" might be a good idea.

Dudi Patimer

unread,
Mar 3, 2022, 5:22:41 PM3/3/22
to Bruce Dawson, Chromium-dev, sven...@chromium.org
Hi,

I've used the following build arguments:
is_official_build = true
is_chrome_branded = false
is_debug = false
ffmpeg_branding="Chrome"
proprietary_codecs=true
dcheck_is_configurable=true

After the build I'm stripping the chrome binary and the other *.so files.
The stripped chrome binary size is 228M and the total size including the *.so files is ~1.6GB

I think it would be nice to add to the instructions the step(s) required to minimize the size of the output, currently the is_debug flag and the 'strip' command.
Or either add a flag to the build to build a production version which will run 'strip' and use a predefined set of production build flags. 

In addition, I'm not sure which of the files in the output directory are required, at the moment I'm copying all *.so files, but eventually I would like to create a similar folder structure as published in the continuos build archivehttps://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Linux/
So it would be nice to have instructions on how to build and get identical structure as the continuos build output.

Thanks,
Dudi

Bruce Dawson

unread,
Mar 3, 2022, 7:19:16 PM3/3/22
to Dudi Patimer, Chromium-dev, sven...@chromium.org
What instructions have you been following, that you think need more information? i.e.; what web page?

Why do you set dcheck_is_configurable=true? That seems contradictory to the goal of smallest-possible-binary.
--
Bruce Dawson, he/him

Aggeliki Stouraite

unread,
Mar 4, 2022, 6:25:51 PM3/4/22
to 'Bruce Dawson' via Chromium-dev


Εστάλη από το Huawei κινητό μου


-------- Αρχικό μήνυμα --------
Θέμα: Re: [chromium-dev] Information on how to reduce the binary size?
Από: 'Bruce Dawson' via Chromium-dev
Προς: Dudi Patimer
Κοιν.: Chromium-dev ,"sven...@chromium.org"


Dudi Patimer

unread,
Mar 6, 2022, 2:06:48 AM3/6/22
to Bruce Dawson, Chromium-dev, sven...@chromium.org
I'll check the effect of dcheck_is_configurable=true on the size.

I'm using the Linux build instructions - https://chromium.googlesource.com/chromium/src/+/main/docs/linux/build_instructions.md, but because the output is somehow different from the folder structure the continuous build archive, I suspect there are different flags used by the continuous build system.
Is the continuous build system code published?



Lei Zhang

unread,
Mar 6, 2022, 2:42:35 AM3/6/22
to dud...@gmail.com, Bruce Dawson, Chromium-dev, sven...@chromium.org
On build.chromium.org, one can navigate to
https://ci.chromium.org/p/chromium/builders/ci/linux-archive-rel,
which is the builder that performs the job as described by its name.
Click through any successful run and expand the "lookup GN args" step.
The relevant args are simply:

dcheck_always_on = false
is_component_build = false
is_debug = false

When I build with just those args, I get a 204 MB stripped chrome
binary. The same size as the ones in the continuous build archive.
> To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAMT93Qr1xVfOTb806ognuZ8TXg4vvhUbwWTyztw%3Dr8J1%3DwiiCQ%40mail.gmail.com.

Bruce Dawson

unread,
Mar 9, 2022, 5:52:18 PM3/9/22
to Chromium-dev, Lei Zhang, Bruce Dawson, Chromium-dev, sven...@chromium.org, dud...@gmail.com
I just uploaded a CL to add instructions on making smaller Linux builds. It really is just the three GN args and then using strip:

https://chromium-review.googlesource.com/c/chromium/src/+/3514630
Reply all
Reply to author
Forward
0 new messages