Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SVELTE] rollup -private for winnings #4925

Merged
merged 8 commits into from Apr 25, 2017

Conversation

runspired
Copy link
Contributor

@runspired runspired commented Apr 14, 2017

This PR de-cycles our import/export structure into and out-of -private, allowing us to use rollup to condense the -private directory.

It took 2 liberties with file structure changes to differentiate between public and private:

  • the deprecated instance-initializer is now in addon/instance-initializers
  • the initializers have been flattened into setup-container (and could be made a bit nicer still)

Additionally, Transform and Adapter Errors are now re-exported from -private, as they are occasionally used in the internals. I don't think transforms and errors belong there and only a very tiny portion of them is actually used internally. As they are entirely public interface we should consider how to divide / extract.

TODO

  • ensure globals build has not regressed
  • [-] ensure globals build gets the same winnings
  • ensure production builds still strip all code correctly
  • build time differences (cold, warm, rebuild)
  • output load time differences (via kris's method) <-- just due diligence (then we can decide if we want to invest more in this approach for other things (like apps) and also make sure we don't troll ourslves)
  • ship it!

Before

ember-data Asset Size Report
=====================
        Total: 160.06 KB
        gZip: 34.56 KB
        Modules: 84
=====================
  Bytes         Percent   Gzip Bytes    Percent Module Name
-----------------------------
15.28 KB        9.5 %    4.66 KB        13.5 %  ember-data/-private/system/store
14.52 KB        9.1 %    3.90 KB        11.3 %  ember-data/-private/system/model/internal-model
 9.54 KB        6.0 %    2.86 KB        8.3 %   ember-data/adapters/rest
 8.70 KB        5.4 %    2.36 KB        6.8 %   ember-data/serializers/json
 6.95 KB        4.3 %    2.24 KB        6.5 %   ember-data/-private/system/model/model
 5.54 KB        3.5 %    1.77 KB        5.1 %   ember-data/-private/system/relationships/state/has-many
 4.80 KB        3.0 %    1.60 KB        4.6 %   ember-data/serializers/rest
 5.64 KB        3.5 %    1.49 KB        4.3 %   ember-data/serializers/json-api
 5.74 KB        3.6 %    1.48 KB        4.3 %   ember-data/-private/system/relationships/state/relationship
 5.90 KB        3.7 %    1.45 KB        4.2 %   ember-data/-private/system/model/states
 4.56 KB        2.8 %    1.37 KB        4.0 %   ember-data/-private/system/record-array-manager
 4.55 KB        2.8 %    1.31 KB        3.8 %   ember-data/serializers/embedded-records-mixin
 3.99 KB        2.5 %    1.15 KB        3.3 %   ember-data/-private/system/relationships/state/belongs-to
 3.28 KB        2.1 %    1.04 KB        3.0 %   ember-data/index
 3.50 KB        2.2 %    1.01 KB        2.9 %   ember-data/-private/system/store/finders
 2.97 KB        1.9 %     1002 B        2.8 %   ember-data/-private/system/snapshot
 2.84 KB        1.8 %      987 B        2.8 %   ember-data/-private/system/relationships/relationship-payloads
 2.35 KB        1.5 %      952 B        2.7 %   ember-data/-private/system/many-array
 2.02 KB        1.3 %      897 B        2.5 %   ember-data/adapters/errors
 2.13 KB        1.3 %      891 B        2.5 %   ember-data/-private/system/record-arrays/record-array
 1.86 KB        1.2 %      841 B        2.4 %   ember-data/-private/system/debug/debug-adapter
 1.98 KB        1.2 %      777 B        2.2 %   ember-data/adapters/json-api
 1.98 KB        1.2 %      759 B        2.1 %   ember-data/-private/system/model/errors
 2.05 KB        1.3 %      738 B        2.1 %   ember-data/-private/system/references/has-many
 1.91 KB        1.2 %      669 B        1.9 %   ember-data/-private/adapters/build-url-mixin
 1.59 KB        1.0 %      649 B        1.8 %   ember-data/-private/system/internal-model-map
 1.29 KB        0.8 %      628 B        1.8 %   ember-data/-private/system/relationships/state/create
 1.37 KB        0.9 %      609 B        1.7 %   ember-data/-private/system/store/serializer-response
 1.35 KB        0.8 %      602 B        1.7 %   ember-data/-private/system/store/container-instance-cache
 1.58 KB        1.0 %      578 B        1.6 %   ember-data/-private/system/references/belongs-to
 1.38 KB        0.9 %      575 B        1.6 %   ember-data/-private/system/relationships/relationship-payloads-manager
 1.16 KB        0.7 %      532 B        1.5 %   ember-data/-private/system/relationships/belongs-to
 1.15 KB        0.7 %      532 B        1.5 %   ember-data/attr
   962 B        0.6 %      521 B        1.5 %   ember-data/-private/system/record-arrays/adapter-populated-record-array
 1.06 KB        0.7 %      499 B        1.4 %   ember-data/-private/debug
 1.29 KB        0.8 %      498 B        1.4 %   ember-data/-private/system/relationships/ext
  1010 B        0.6 %      498 B        1.4 %   ember-data/-private/system/relationships/has-many
   801 B        0.5 %      471 B        1.3 %   ember-data/-private/ext/date
   915 B        0.6 %      464 B        1.3 %   ember-data/-private/system/snapshot-record-array
   985 B        0.6 %      441 B        1.2 %   ember-data/-private/system/promise-proxies
   887 B        0.5 %      406 B        1.1 %   ember-data/-private/system/references/record
   774 B        0.5 %      396 B        1.1 %   ember-data/-private/system/record-arrays/filtered-record-array
   678 B        0.4 %      376 B        1.1 %   ember-data/-private/transforms/boolean
   669 B        0.4 %      366 B        1.0 %   ember-data/-private/transforms/date
   754 B        0.5 %      353 B        1.0 %   ember-data/-private/initializers/store
   530 B        0.3 %      347 B        1.0 %   ember-data/-private/instance-initializers/initialize-store-service
   638 B        0.4 %      346 B        1.0 %   ember-data/-private/utils
   554 B        0.3 %      345 B        1.0 %   ember-data/-private/system/ordered-set
   693 B        0.4 %      339 B        1.0 %   ember-data/-private/global
   491 B        0.3 %      330 B        0.9 %   ember-data/-private/system/store/common
   505 B        0.3 %      324 B        0.9 %   ember-data/-private/system/relationship-meta
   432 B        0.3 %      316 B        0.9 %   ember-data/-private/system/diff-array
   444 B        0.3 %      316 B        0.9 %   ember-data/-private/utils/parse-response-headers
   655 B        0.4 %      315 B        0.9 %   ember-data/adapter
   474 B        0.3 %      289 B        0.8 %   ember-data/-private/system/identity-map
   471 B        0.3 %      288 B        0.8 %   ember-data/-private/system/normalize-link
   432 B        0.3 %      258 B        0.7 %   ember-data/-private/transforms/number
   348 B        0.2 %      254 B        0.7 %   ember-data/-private/system/is-array-like
   316 B        0.2 %      236 B        0.7 %   ember-data/-private/core
   543 B        0.3 %      236 B        0.7 %   ember-data/-private/transforms
   396 B        0.2 %      227 B        0.6 %   ember-data/-private/initializers/transforms
   310 B        0.2 %      227 B        0.6 %   ember-data/-private/system/store/serializers
   508 B        0.3 %      226 B        0.6 %   ember-data/-private/system/record-arrays
   441 B        0.3 %      220 B        0.6 %   ember-data/-private/system/references
   413 B        0.3 %      217 B        0.6 %   ember-data/setup-container
   339 B        0.2 %      216 B        0.6 %   ember-data/-private/initializers/store-injections
   325 B        0.2 %      214 B        0.6 %   ember-data/-private/transforms/string
   258 B        0.2 %      210 B        0.6 %   ember-data/-private/system/empty-object
   394 B        0.2 %      209 B        0.6 %   ember-data/-private/system/model
   374 B        0.2 %      209 B        0.6 %   ember-data/-private/serializers
   303 B        0.2 %      198 B        0.6 %   ember-data/relationships
   225 B        0.1 %      196 B        0.6 %   ember-data/-private/features
   240 B        0.1 %      195 B        0.6 %   ember-data/-private/system/references/reference
   262 B        0.2 %      194 B        0.5 %   ember-data/-private/initializers/data-adapter
   277 B        0.2 %      192 B        0.5 %   ember-data/-private/adapters
   221 B        0.1 %      184 B        0.5 %   ember-data/-private/system/clone-null
   218 B        0.1 %      184 B        0.5 %   ember-data/-private/system/normalize-model-name
   238 B        0.1 %      181 B        0.5 %   ember-data/serializer
   206 B        0.1 %      177 B        0.5 %   ember-data/-private/system/coerce-id
   197 B        0.1 %      165 B        0.5 %   ember-data/transform
   201 B        0.1 %      158 B        0.4 %   ember-data/-private/system/debug
   153 B        0.1 %      154 B        0.4 %   ember-data/version
   171 B        0.1 %      150 B        0.4 %   ember-data/store
   171 B        0.1 %      150 B        0.4 %   ember-data/model

After

ember-data Asset Size Report
==========================
        Total: 137.05 KB
        gZip: 32.16 KB
        Modules: 19
==========================
  Bytes         Percent   Gzip Bytes    Percent Module Name
-----------------------------------
93.70 KB        68.4 %  23.32 KB        72.5 %  ember-data/-private
 9.46 KB        6.9 %    2.84 KB        8.8 %   ember-data/adapters/rest
 8.60 KB        6.3 %    2.34 KB        7.3 %   ember-data/serializers/json
 4.68 KB        3.4 %    1.56 KB        4.8 %   ember-data/serializers/rest
 5.65 KB        4.1 %    1.48 KB        4.6 %   ember-data/serializers/json-api
 4.52 KB        3.3 %    1.30 KB        4.0 %   ember-data/serializers/embedded-records-mixin
 2.48 KB        1.8 %      962 B        2.9 %   ember-data/index
 1.95 KB        1.4 %      770 B        2.3 %   ember-data/adapters/json-api
 1.12 KB        0.8 %      522 B        1.6 %   ember-data/attr
 1.24 KB        0.9 %      483 B        1.5 %   ember-data/setup-container
   491 B        0.3 %      329 B        1.0 %   ember-data/instance-initializers/initialize-store-service
   655 B        0.5 %      315 B        1.0 %   ember-data/adapter
 1.19 KB        0.9 %      304 B        0.9 %   ember-data/adapters/errors
   318 B        0.2 %      189 B        0.6 %   ember-data/relationships
   238 B        0.2 %      181 B        0.5 %   ember-data/serializer
   220 B        0.2 %      171 B        0.5 %   ember-data/store
   230 B        0.2 %      170 B        0.5 %   ember-data/transform
   220 B        0.2 %      170 B        0.5 %   ember-data/model
   153 B        0.1 %      155 B        0.5 %   ember-data/version

@bmac
Copy link
Member

bmac commented Apr 14, 2017

Yay @runspired! I'm excited for this change!

@runspired
Copy link
Contributor Author

@igorT @bmac @stefanpenner our pre-gzip size has shifted significantly, but our post-gzip size has not budged much. I suspect some of this is due to us still needing to re-export almost everything from -private. Please pay extra attention to the "groupings" in this file to see what I mean.

https://github.com/emberjs/data/pull/4925/files#diff-d090d6077afd998d4578d3423aa53f1a

@rwjblue
Copy link
Member

rwjblue commented Apr 14, 2017

Can you share what the costs are to build time for both standard development builds and production builds before and after this change?

@stefanpenner
Copy link
Member

stefanpenner commented Apr 14, 2017

LGTM (in broad strokes)

Be sure to also measure:

@runspired
Copy link
Contributor Author

@stefanpenner gonna port those TODOs up to the main PR text

@stefanpenner
Copy link
Member

  • Rebased + fixed tests
  • Current build performance is poor because we: rollup -> babel, I will change this to babel -> rollup that way we still get 1:1 babel compilation, which should address most of these issues

@runspired
Copy link
Contributor Author

@stefanpenner given there is a new branch on my fork with a slightly different name and the fix you mention here, I suspect you trolled yourself. I think we want to remove the "merge into master" commit, do an actual rebase, and apply this commit? runspired@a560ada

@stefanpenner
Copy link
Member

I think i didn't finish the rebase, redoing it now.

@stefanpenner stefanpenner force-pushed the svelte/rollup-private branch 2 times, most recently from 4622a04 to 7291441 Compare April 20, 2017 01:44
@stefanpenner
Copy link
Member

dev/prod builds feel fine now, quick load profile doesn't show any obvious issues.

@runspired
Copy link
Contributor Author

Thanks @stefanpenner! I'll get a HAR on this asap.

@stefanpenner
Copy link
Member

Thanks @stefanpenner! I'll get a HAR on this asap.

@runspired ping

@runspired
Copy link
Contributor Author

@stefanpenner I did, I'll share data later, it's basically "slight improvement"

@stefanpenner
Copy link
Member

stefanpenner commented Apr 24, 2017

@runspired awesome. So we are good to go? (i'll fix the rebase now)

@stefanpenner
Copy link
Member

Rebased. @runspired let me know if you are good with me merging:

initial build added cost: 400ms
rebuild added cost: 5ms

Not perfect, but not the end of the world. Some future work to allow for "prebuilt" assets will mitigate that (and more importantly the 5s of babel that is pre-existing)

@runspired
Copy link
Contributor Author

@stefanpenner no objections to merging.

@runspired
Copy link
Contributor Author

Charts (50 runs of EmbeAddons.com with and without this change)

gc
plot
samples

@fivetanley fivetanley merged commit 2fabe2e into emberjs:master Apr 25, 2017
@runspired
Copy link
Contributor Author

🎉

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.

None yet

5 participants