Skip to content

New nightly shows mysterious changes of binary size #214

Closed
@matklad

Description

@matklad

For https://github.com/matklad/tom/tree/f81bede5244eda62dac6b362784b6529d17f26e6, I observe an interesting difference between nightly-2018-07-07 and nightly-2018-07-13.

On 07-07, I see a huge unused data section in WASM. On 07-13 the section is gone, but the total size of the binary is nonetheless slightly bigger. This is after wasm-opt (see build.sh)

STR:

% git clone https://github.com/matklad/tom/ && cd tom && git checkout f81bede5244eda62dac6b362784b6529d17f26e6

% twiggy --version
twiggy-opt 0.2.0

% rustup override add nightly-2018-07-07
info: using existing install for 'nightly-2018-07-07-x86_64-unknown-linux-gnu'
info: override toolchain for '/home/matklad/projects/tom' set to 'nightly-2018-07-07-x86_64-unknown-linux-gnu'

  nightly-2018-07-07-x86_64-unknown-linux-gnu unchanged - rustc 1.29.0-nightly (e06c87544 2018-07-06)

% rustc -vV
rustc 1.29.0-nightly (e06c87544 2018-07-06)
binary: rustc
commit-hash: e06c875442e91cc2c597135d1e807a69e73eee26
commit-date: 2018-07-06
host: x86_64-unknown-linux-gnu
release: 1.29.0-nightly
LLVM version: 6.0

% ./build.sh
    Finished release [optimized] target(s) in 0.03s

% ls main_bg.wasm
.rw-r--r-- 553k matklad 15 Jul  0:31 main_bg.wasm

% twiggy garbage main_bg.wasm
 Bytes  │ Size % │ Garbage Item
────────┼────────┼─────────────
 161804 ┊ 29.22% ┊ data[35] // OUCH!!!
  55289 ┊  9.98% ┊ data[8]
  28765 ┊  5.19% ┊ code[107]
  17948 ┊  3.24% ┊ data[34]
  14409 ┊  2.60% ┊ code[74]
   7761 ┊  1.40% ┊ code[183]
   7685 ┊  1.39% ┊ code[116]
   7531 ┊  1.36% ┊ code[362]
   4938 ┊  0.89% ┊ code[142]
   4197 ┊  0.76% ┊ code[112]


// Switching to newer nightly...

% rustup override add nightly-2018-07-13
info: using existing install for 'nightly-2018-07-13-x86_64-unknown-linux-gnu'
info: override toolchain for '/home/matklad/projects/tom' set to 'nightly-2018-07-13-x86_64-unknown-linux-gnu'

  nightly-2018-07-13-x86_64-unknown-linux-gnu unchanged - rustc 1.29.0-nightly (64f7de921 2018-07-12)

% rustc -vV
rustc 1.29.0-nightly (64f7de921 2018-07-12)
binary: rustc
commit-hash: 64f7de92166f1f7d940575feff57ac33bc384550
commit-date: 2018-07-12
host: x86_64-unknown-linux-gnu
release: 1.29.0-nightly
LLVM version: 7.0 // newer LLVM

% ./build.sh
   Compiling tom_wasm v0.0.0 (file:///home/matklad/projects/tom/tom_wasm)
    Finished release [optimized] target(s) in 4.36s
    
% ls main_bg.wasm
.rw-r--r-- 574k matklad 15 Jul  0:32 main_bg.wasm

% twiggy garbage main_bg.wasm
 Bytes │ Size % │ Garbage Item
───────┼────────┼─────────────
 52691 ┊  9.18% ┊ data[8] // Hey, we've lost that big of data. However, total size (^) is bigger
 28875 ┊  5.03% ┊ code[107]
 14194 ┊  2.47% ┊ code[74]
  8048 ┊  1.40% ┊ code[361]
  7708 ┊  1.34% ┊ code[183]
  7642 ┊  1.33% ┊ code[116]
  6456 ┊  1.12% ┊ data[3420]
  5720 ┊  1.00% ┊ data[3492]
  5696 ┊  0.99% ┊ data[302]
  5664 ┊  0.99% ┊ data[3434]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions