Skip to content

Conversation

@nevkontakte
Copy link
Contributor

When --analyze_size flag is passed to GopherJS, an additional
${packagename}.js.svg file is creates with a TreeMap diagram that
visualizes which packages contributed to the artifact size and how much.

The data is obtained by counting bytes written for each section of the
file including GopherJS's own prelude and works accurately both in
minified and default modes.

Most of diagram-related logic is isolated to the build/analysis package
with minimal changes to the rest of the code base.

@nevkontakte nevkontakte force-pushed the artifact-size-goplusjs branch 2 times, most recently from a169a54 to a1f5e57 Compare November 11, 2020 18:12
@visualfc
Copy link
Collaborator

fix and update workflows action and please merge master

When --analyze_size flag is passed to GopherJS, an additional
${packagename}.js.svg file is creates with a TreeMap diagram that
visualizes which packages contributed to the artifact size and how much.

The data is obtained by counting bytes written for each section of the
file including GopherJS's own prelude and works accurately both in
minified and default modes.

Most of diagram-related logic is isolated to the build/analysis package
with minimal changes to the rest of the code base.
@nevkontakte nevkontakte force-pushed the artifact-size-goplusjs branch from a1f5e57 to 0c991f0 Compare November 13, 2020 21:20
@nevkontakte
Copy link
Contributor Author

Synced with the master branch, but I'm not sure what workflow action fix you mean.

@nevkontakte
Copy link
Contributor Author

@visualfc could you please clarify what else needs to be fixed in this PR or whether you are interested in merging it?

@visualfc
Copy link
Collaborator

visualfc commented Nov 24, 2020

@visualfc could you please clarify what else needs to be fixed in this PR or whether you are interested in merging it?

It's cool, but users may just need a simple text display.

fmt   243kb
os   157kb
....

generate svg format is a other tools and can parser this text format.

@nevkontakte
Copy link
Contributor Author

First of all, apologies for taking so long to respond, december was a busy month.

Adding text output option makes sense. I've experimented with it a bit before going on to implement SVG rendering and found that for any real-life project it is very difficult to understand, even when printed in a tree-like form. That said, I could still see how it could be useful to track artifact size changes in a CI system or something like that.

Example output:

  $artifact — 0 B own size, 1.2 MiB with children
  | playground/cmd — 1.5 KiB own size, 1.1 MiB with children
  | | fmt — 122 KiB own size, 1.1 MiB with children
  | | | os — 76 KiB own size, 453 KiB with children
  | | | | time — 161 KiB own size, 164 KiB with children
  | | | | | github.com/gopherjs/gopherjs/nosync — 2.3 KiB own size, 2.3 KiB with children
  | | | | internal/poll — 104 KiB own size, 104 KiB with children
  | | | | syscall — 93 KiB own size, 93 KiB with children
  | | | | runtime — 8.0 KiB own size, 8.5 KiB with children
  | | | | | runtime/internal/sys — 454 B own size, 454 B with children
  | | | | sync/atomic — 2.9 KiB own size, 2.9 KiB with children
  | | | | internal/testlog — 2.1 KiB own size, 2.1 KiB with children
  | | | | internal/syscall/unix — 1.5 KiB own size, 1.5 KiB with children
  | | | | internal/oserror — 890 B own size, 890 B with children
  | | | | internal/syscall/execenv — 631 B own size, 631 B with children
  | | | reflect — 266 KiB own size, 268 KiB with children
  | | | | internal/unsafeheader — 1.0 KiB own size, 1.0 KiB with children
  | | | | unicode — 441 B own size, 441 B with children
  | | | errors — 1.6 KiB own size, 118 KiB with children
  | | | | internal/reflectlite — 116 KiB own size, 116 KiB with children
  | | | strconv — 91 KiB own size, 93 KiB with children
  | | | | internal/bytealg — 879 B own size, 1.3 KiB with children
  | | | | | internal/cpu — 446 B own size, 446 B with children
  | | | sync — 37 KiB own size, 38 KiB with children
  | | | | internal/race — 1017 B own size, 1017 B with children
  | | | internal/fmtsort — 18 KiB own size, 30 KiB with children
  | | | | sort — 12 KiB own size, 12 KiB with children
  | | | unicode/utf8 — 15 KiB own size, 15 KiB with children
  | | | math — 2.1 KiB own size, 13 KiB with children
  | | | | github.com/gopherjs/gopherjs/js — 6.8 KiB own size, 6.8 KiB with children
  | | | | math/bits — 4.6 KiB own size, 4.6 KiB with children
  | | | io — 9.6 KiB own size, 9.6 KiB with children
  | $prelude — 56 KiB own size, 56 KiB with children

Moving SVG rendering into a separate tool is not very practical because it would need the dependency tree and a lot of meta information that are only available to the gopherjs compiler (in particular differences due to build tags and stdlib augmentation). It will require a much more complicated format to pass that on, which won't be human-readable.

As a middle ground I could offer to move most of the size analysis and/or SVG rendering logic into a separate package which I'd maintain myself, and import that from GopherJS codebase.

@nevkontakte nevkontakte force-pushed the artifact-size-goplusjs branch from 23ada84 to 5f6ecdf Compare January 8, 2021 14:01
@visualfc
Copy link
Collaborator

@nevkontakte
I'm try --anylize for dump pkgs json infos #25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants