Thanks to visit codestin.com
Credit goes to github.com

Skip to content

More minification. #4931

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

Merged
merged 4 commits into from
Mar 16, 2024
Merged

More minification. #4931

merged 4 commits into from
Mar 16, 2024

Conversation

sjrd
Copy link
Member

@sjrd sjrd commented Jan 26, 2024

Based on #4945.

All together, this brings a 17% code size reduction in a Vite full build, compared to what we get at the end of #4945. We're still 14% bigger than what we get with GCC, but that's a lot more acceptable than the status quo.

@sjrd sjrd force-pushed the minify-prototype branch from bceb896 to 1be1bbe Compare January 30, 2024 11:13
@sjrd sjrd force-pushed the minify-prototype branch 2 times, most recently from 0d5e313 to 2394217 Compare February 21, 2024 21:22
@sjrd sjrd changed the title WiP More minification. More minification. Feb 23, 2024
@sjrd sjrd requested a review from gzm0 February 23, 2024 16:59
@sjrd
Copy link
Member Author

sjrd commented Feb 23, 2024

@gzm0 This is still based on #4945, so not for merge yet. However, it is reviewable now.

@sjrd sjrd force-pushed the minify-prototype branch 4 times, most recently from bfd8ab5 to 054b708 Compare February 26, 2024 15:54
Copy link
Contributor

@gzm0 gzm0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I'm wondering if the last commit should go into its own PR, but given how many comments we'll have here already, it might make sense to keep the discussion history.

@gzm0
Copy link
Contributor

gzm0 commented Mar 6, 2024

We're still 14% bigger than what we get with GCC, but that's a lot more acceptable than the status quo.

On an unrelated note: IMO given how many total hours went into this vs GCC, this is quite the achievement :)

@sjrd sjrd force-pushed the minify-prototype branch from 054b708 to 2bfddcf Compare March 8, 2024 11:17
@sjrd
Copy link
Member Author

sjrd commented Mar 8, 2024

Addressed comments of all the commits except the last one.

@sjrd sjrd force-pushed the minify-prototype branch from 2bfddcf to fa9a753 Compare March 8, 2024 13:24
@sjrd sjrd marked this pull request as ready for review March 8, 2024 13:26
@sjrd
Copy link
Member Author

sjrd commented Mar 8, 2024

OK it should be all addressed, now.

@sjrd sjrd requested a review from gzm0 March 8, 2024 13:26
Copy link
Contributor

@gzm0 gzm0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of things I saw on second read only. Sorry for the extra iteration. (also some typos, but they are really minor).

sjrd added 3 commits March 10, 2024 15:09
When minifying, a susprisingly large amount of bytes in the
resulting .js file are caused by the `prototype`s in:

    C.prototype.f = function(...) { ... };
    C.prototype.g = function(...) { ... };

We can get rid of them by assigning `C.prototype` once to a
temporary variable, then reusing it many times:

    $p = C.prototype;
    $p.f = function(...) { ... };
    $p.f = function(...) { ... };

This commit implements that strategy when the `minify` config
is on.
* Merge `isInterface` and `isJSType` as a single parameter `kind`
  that is an integer.
* Use the first element of `ancestors` instead of independently
  passing the `internalName` (this is safe because ES 2015
  guarantees the order of `getOwnPropertyNames`).
* Really remove the `parentData` parameter when reachability
  analysis says it is not accessed.
This removes the largest source of uncompressible and non-removable
occurrences of `$classData` identifiers.

It does increase the size of the GCC output in the `LibrarySizeTest`,
but it does not translate to the `reversi` checksizes, so it is
probably a small codebase artifact.
@sjrd sjrd force-pushed the minify-prototype branch from fa9a753 to 3f249bf Compare March 10, 2024 15:15
@sjrd sjrd requested a review from gzm0 March 10, 2024 15:16
Copy link
Contributor

@gzm0 gzm0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one nit about the new comment.

During the optimizer, when emitting a `VarDef(x, ..., rhs)`, we
try to inline it if it has been used exactly once. In order to do
that, we look at the `body` in which it will be available, and
replace its only occurrence if it occurs in the first evaluation
context following only pure subexpressions.

See the long comment in the code for more details.
@sjrd sjrd force-pushed the minify-prototype branch from 3f249bf to 0dd63ff Compare March 16, 2024 09:06
@sjrd sjrd merged commit b694955 into scala-js:main Mar 16, 2024
@sjrd sjrd deleted the minify-prototype branch March 16, 2024 13:00
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