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

Bundle size delta #937

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Bundle size delta #937

wants to merge 3 commits into from

Conversation

LesnyRumcajs
Copy link
Contributor

@LesnyRumcajs LesnyRumcajs commented Dec 12, 2022

Changes:

  • added shellcheck linter to CI, resolved issues with an existing script,
  • added bundle-size file denoting the currently expected bundle size. This file gets automatically updated on a push to master (see LesnyRumcajs@3d4e6f4),
  • bot message to every PR summarising WASM bundle size changes - only one message will be posted to the thread, afterwards it will get updated on new commits,
  • Makefile rule plus a generator script.

The bundle-size is off by one in this PR to illustrate how it works. It will get updated automatically once it is merged.

There were several ways to accomplish this, but I believe this is the least invasive one for developers while keeping track of the final bundle size and adding it to the PR process.

Closes #501

@LesnyRumcajs LesnyRumcajs force-pushed the bundle-size-delta branch 5 times, most recently from 8cc9f70 to 6651a3d Compare December 12, 2022 15:07
@codecov-commenter
Copy link

codecov-commenter commented Dec 12, 2022

Codecov Report

Merging #937 (c1adeed) into master (5ec2a6b) will decrease coverage by 0.08%.
Report is 5 commits behind head on master.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #937      +/-   ##
==========================================
- Coverage   91.06%   90.98%   -0.08%     
==========================================
  Files         145      145              
  Lines       27798    27798              
==========================================
- Hits        25313    25292      -21     
- Misses       2485     2506      +21     

see 3 files with indirect coverage changes

@LesnyRumcajs LesnyRumcajs changed the title Bundle size delta [wip] Bundle size delta Dec 12, 2022
@LesnyRumcajs LesnyRumcajs force-pushed the bundle-size-delta branch 5 times, most recently from a004132 to b965add Compare December 13, 2022 12:56
@filecoin-project filecoin-project deleted a comment from github-actions bot Dec 13, 2022
@LesnyRumcajs LesnyRumcajs force-pushed the bundle-size-delta branch 6 times, most recently from 2398954 to 1fa6e7c Compare December 13, 2022 14:37
@filecoin-project filecoin-project deleted a comment from github-actions bot Dec 13, 2022
@github-actions
Copy link

github-actions bot commented Dec 13, 2022

WASM bundle summary 📦

Old bundle size: 6030519
New bundle size: 6030520
Delta:           1 byte(s)

@filecoin-project filecoin-project deleted a comment from github-actions bot Dec 13, 2022
@filecoin-project filecoin-project deleted a comment from github-actions bot Dec 13, 2022
@LesnyRumcajs LesnyRumcajs force-pushed the bundle-size-delta branch 2 times, most recently from 84ffa92 to d85556b Compare December 13, 2022 17:18
@LesnyRumcajs LesnyRumcajs marked this pull request as ready for review December 13, 2022 17:31
@LesnyRumcajs LesnyRumcajs changed the title [wip] Bundle size delta Bundle size delta Dec 13, 2022
@LesnyRumcajs
Copy link
Contributor Author

@anorth @jennijuju Given nothing was born out of this one after nine months, should we close this PR or is the change still wanted?

@anorth
Copy link
Member

anorth commented Aug 30, 2023

Thanks for raising this, I'm sorry it has languished.

I'm a bit torn here. On the one hand there is some real value here, exploding the bundle size could cause problems. But small changes to it are inevitable and no problem. How likely and quickly are downstream teams or processes to detect a big change in size anyway, even if not automated here? Probably somewhat, but far from perfectly.

On the other hand, simplicity is really important and I'd like to keep our auxilliary code and processes as tight as possible.

On balance I'm inclined to say yet let's merge this. I've reviewed in more detail now and it looks fine. I would just like another actors maintainer to concur before we ship it.

@anorth anorth requested a review from arajasek August 30, 2023 22:33
@Stebalien
Copy link
Member

This will change for every PR. Can we make it fuzzy and check if we're within 20% of the expected value?

@LesnyRumcajs
Copy link
Contributor Author

This will change for every PR. Can we make it fuzzy and check if we're within 20% of the expected value?

We could; this would avoid spamming the commit history on master. At the same time, the tracking size value would be decreased. Say I push a commit that increases the bundle size by 15%, and it's accepted. Every consecutive PR would show a message with a large delta until the bundle size file is updated again. I fear folks would ignore those messages. In such a case, maybe the message itself is not worth having, and we could do with, e.g., weekly bundle size updates. If something is really large, it could be investigated manually and potentially reverted. Someone would have to watch it constantly, though.

I'm not sure where lies the right balance to not have spam notifications, relatively fast CI and immediate alerts. What do you think?

@anorth
Copy link
Member

anorth commented Aug 31, 2023

I don't see the problem with this changing on every PR. We mandate squashed commits anyway (❤️) so there'll be no noise in the commit history.

Note if we didn't squash commits we could implement this a different way, not with CI magic that makes commits, but just an assertion that the size is right, and implicit requirement that authors need to run the tool to write the correct bundle size before pushing.

@Stebalien
Copy link
Member

Hm. As far as I can tell, this change pushes the commit to master so it will cause a commit in master per PR merged. Not a huge issue, but still annoying spam.

However, if we pushed the commit to PR branches, things would get ugly fast (every push would require a pull and rebasing would get annoying).

@anorth
Copy link
Member

anorth commented Aug 31, 2023

Hmm, I might have misunderstood the configuration then, and yes I can see how pushing commits to branches would actually be annoying in common workflows of not getting your PR perfect first time. In that case, I agree that this CI-based way of doing it probably won't work for us.

I've used the scheme where CI just checks the value, that must be updated alongside commits to the actual code, in prior projects and it wasn't much pain. Those projects probably had faster CI overall, but it's a thing I'd at least suggest is worth trying here.

@Stebalien
Copy link
Member

I don't think that'll work because there is no reproducibility guarantee. On CI, this kind of works because it tends to build in a consistent environment. But I think we need some wiggle room regardless. It can be a percent, but it needs to be there.

@anorth
Copy link
Member

anorth commented Aug 31, 2023

Sounds like we need a reproducible build first, then. #171

@LesnyRumcajs
Copy link
Contributor Author

Yes, this relies on the build being reproducible, which I would assume the CI kind of represents? Of course it's kind of, given that the image for GH runner is not set in stone and may all of a sudden change.

Should we mark it as blocked, then? If so, once there is a reproducible build, how would we want to approach this subject?

Another idea (yet to be tested somewhere) that would not spam the master and limit the amount of annoyance for development is to execute the bundle size update in a merge_group. This would require using merge queues (I highly recommend them, we use them in Forest). The update would be triggered only after the PR is added to the merge queue, which is only possible if all checks are passing and it is approved. The commit would get squashed with others.

@anorth
Copy link
Member

anorth commented Sep 3, 2023

Another idea ... is to execute the bundle size update in a merge_group.

We do in fact already use merge queues, though I am also about to suggest we end the experiment using them since I don't think we see the benefits with our work patterns, but it increases latency to land PRs (higher throughput, but we don't have a throughput problem).

However, calculating bundle size there wouldn't give anyone an opportunity to notice changes before committing them. We could bisect later to find big changes though.

@LesnyRumcajs
Copy link
Contributor Author

However, calculating bundle size there wouldn't give anyone an opportunity to notice changes before committing them. We could bisect later to find big changes though.

We would see the bundle delta as one of the first messages in the PR thread, the same as coverage reports.

@anorth
Copy link
Member

anorth commented Sep 18, 2023

However, calculating bundle size there wouldn't give anyone an opportunity to notice changes before committing them. We could bisect later to find big changes though.

We would see the bundle delta as one of the first messages in the PR thread, the same as coverage reports.

As I understand it (and could very well be wrong), using merge_group will only run in the merge queue, i.e. after someone hits "merge" on the PR, so there'd be no commit/comment in the PR. Using pull_request would put a comment where it could be responded to, but then the extra commit causes pain for dev cycles.

The valid paths I see are where CI doesn't make a commit, only checks the value. The value must be set/updated by the dev (via Make) before pushing. For these we either need a reproducible build, or wiggle room in the check. We could prototype it now with the wiggle room, and I think that could work ok.

@LesnyRumcajs
Copy link
Contributor Author

LesnyRumcajs commented Sep 19, 2023

As I understand it (and could very well be wrong), using merge_group will only run in the merge queue, i.e. after someone hits "merge" on the PR, so there'd be no commit/comment in the PR. Using pull_request would put a comment where it could be responded to, but then the extra commit causes pain for dev cycles.

I believe that with a limited amount of ifs (~2) in the workflow, we could get the good stuff from both worlds:

  1. On pull_request event, run the delta against the current value (or better, current main value to avoid potential clashes). Create/update the comment in the PR thread.
  2. On merge_group event, update the file.

What do you think?

@anorth
Copy link
Member

anorth commented Sep 19, 2023 via email

@LesnyRumcajs LesnyRumcajs marked this pull request as draft September 29, 2023 13:45
@LesnyRumcajs
Copy link
Contributor Author

For the record, before I update the current files, in 9 months the bundle size increased by 1.2 MB.

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.

Bundle-size delta check/message on PR
4 participants