Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Issue 2607893002: Save 166 KB of per-process private data by deleting 'const' (Closed)

Created:
3 years, 11 months ago by brucedawson
Modified:
3 years, 11 months ago
CC:
chromium-reviews
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Save 166 KB of per-process private data by deleting 'const' Also saves a total of 224 KB of code. VC++ has an odd quirk where if you have a const array of structs where the structs have some const members then the compiler stores the array in the .data (read/write section) instead of the .rdata (read-only section). Worse yet, in this case the compiler generates code to do the initialization, even in full official builds. This wastes code/reloc space and also means that the arrays all turn into per-process private data. That is, every Chrome process was ending up with a private copy of the many global arrays which this change fixes. This anomaly was discovered while investigating why a couple of large const arrays were in the wrong section. The section size improvements for full official build are shown below: chrome.dll .text: -111744 bytes change .rdata: 165824 bytes change .data: -166208 bytes change .reloc: -23864 bytes change Total change: -135992 bytes chrome_child.dll .text: -111904 bytes change .rdata: 166000 bytes change .data: -166240 bytes change .reloc: -23832 bytes change Total change: -135976 bytes The on-disk size of each binary shrinks by 88,576 bytes. I do not understand any of the math behind how section sizes map to binary sizes. The VC++ tracking bug is: https://connect.microsoft.com/VisualStudio/feedback/details/3117602 BUG=677351 Committed: https://crrev.com/7a0168cc2fae634b15e720527bfcd2d75ff21def Cr-Commit-Position: refs/heads/master@{#441211}

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+3 lines, -3 lines) Patch
M device/usb/usb_ids.h View 1 chunk +3 lines, -3 lines 0 comments Download

Messages

Total messages: 19 (13 generated)
brucedawson
Strange, but effective. Part one of several. PTAL.
3 years, 11 months ago (2016-12-29 04:11:49 UTC) #7
Ken Rockot(use gerrit already)
lgtm
3 years, 11 months ago (2017-01-03 20:09:24 UTC) #11
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2607893002/1
3 years, 11 months ago (2017-01-03 20:27:15 UTC) #13
commit-bot: I haz the power
Committed patchset #1 (id:1)
3 years, 11 months ago (2017-01-03 21:27:26 UTC) #16
commit-bot: I haz the power
Patchset 1 (id:??) landed as https://crrev.com/7a0168cc2fae634b15e720527bfcd2d75ff21def Cr-Commit-Position: refs/heads/master@{#441211}
3 years, 11 months ago (2017-01-03 21:31:49 UTC) #18
brucedawson
3 years, 11 months ago (2017-01-04 17:48:27 UTC) #19
Message was sent while issue was closed.
On 2017/01/03 21:31:49, commit-bot: I haz the power wrote:
> Patchset 1 (id:??) landed as
> https://crrev.com/7a0168cc2fae634b15e720527bfcd2d75ff21def
> Cr-Commit-Position: refs/heads/master@{#441211}

I just looked in more detail at the before/after count of global variables in
the read/write data segment, from yesterday's canary build to today's. This
change caused 1,501 global variables, totaling about 167,000 bytes, to move to
the read-only segment. This matches the previously surprising change in the size
of the .data segment which I had measured but not fully understood because I was
only looking at large globals, and some of the affected globals are as small as
eight bytes.

Powered by Google App Engine
This is Rietveld 408576698