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

Confusing project budgets #27580

Closed
Ghostbird opened this issue May 2, 2024 · 1 comment · Fixed by #27602
Closed

Confusing project budgets #27580

Ghostbird opened this issue May 2, 2024 · 1 comment · Fixed by #27602
Labels
area: devkit/build-angular freq1: low Only reported by a handful of users who observe it rarely severity1: confusing type: bug/fix

Comments

@Ghostbird
Copy link

Ghostbird commented May 2, 2024

Command

build

Is this a regression?

I don't think so.

Description

When generating a new project, budgets are automatically assigned, however the generated values are really confusing. I accidentally ran into some of these limits. I had to grab a calculator, the build output, make some assumptions, run some calculations, before I could actually understand what these options meant.

It would be nice if these were unambiguous.

The generated project limits rules-as-written are:

  • Initial maximum warning: 500 kilobits
  • Initial maximum error: 1millibit
  • Any component style maximum warning: 2 kilobits
  • Any component style maximum error: 6 kilobits

First of all, let's assume that the the m in mb should be M, that's a factor 10⁹ difference, but ¹/₁₀₀₀ bits makes no sense here, since we're talking about real storage here. I've only ever used millibits in calculations on pure information.

I analysed this output:

Budget 500.00 kB was not met by 589.00 kB with a total of 1.06 MB

This quickly points in the direction that the b should be a B, it's bytes, not bits.
Finally if I run some calculations on this, it clears up another thing (but the output is faulty here too).

(500 + 589)×10³ ≠ 1.06 × 10⁶ (rules-as-written ISO prefixes)
(500 + 589)×2¹⁰ ≠ 1.06 × 10³ × 2¹⁰ (floppy disk megabytes)
(500 + 589)×2¹⁰ = 1.06 × 10²⁰ (actually intended ISO/IEC 80000-13 binary prefix standard)

From this I can conclude that the numbers used in calculations are actually using the binary measures according to ISO/IEC 80000 (which is the most common for modern systems AFAIK), and the k should be ki and the m should ultimately be Mi.

As you can see, it's no trivial matter to understand what the configuration file actually means with these values:

  • Initial maximum warning: 500 kiB (kibibytes) or 500 × 10¹⁰ bytes = 512000 bytes
  • Initial maximum error: 1 MiB (mebibyte) or 1 × 10²⁰ bytes = 1048576 bytes
  • Any component style maximum warning: 2 kiB or 2 × 10¹⁰ bytes = 2048 bytes
  • Any component style maximum error: 6 kiB or 6 × 10¹⁰ bytes = 6144 bytes

Note that you now suddenly can see that the initial maximum warning is not half of the initial maximum error but is approximately 48.8% of the maximum error.

While not a big priority, as it is unlikely to cause problems whose solution isn't obvious (increase the limits), it is annoying as it can unexpectedly cause errors whose exact cause is hard to understand.

Minimal Reproduction

ng g new app
Check angular.json » project » app » architect » build » configuration » production » budgets

Exception or Error

No response

Your Environment

$ ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 17.3.6
Node: 22.0.0 (Unsupported)
Package Manager: npm 10.5.1
OS: linux x64

Angular: 
... 

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1703.6 (cli-only)
@angular-devkit/core         17.3.6 (cli-only)
@angular-devkit/schematics   17.3.6 (cli-only)
@schematics/angular          17.3.6 (cli-only)
    
Warning: The current version of Node (22.0.0) is not supported by Angular.

Anything else relevant?

No response

@alan-agius4 alan-agius4 added type: bug/fix freq1: low Only reported by a handful of users who observe it rarely area: devkit/build-angular severity1: confusing labels May 2, 2024
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue May 6, 2024
Ensure that file sizes are consistently formatted using decimal byte units, adhering to the International System of Units (SI) convention. This aligns with clarity and standardization across the project.

- Kilobyte (kB): 10^3 bytes (1000 bytes)
- Megabyte (MB): 10^6 bytes (1,000,000 bytes)
- Gigabyte (GB): 10^9 bytes (1,000,000,000 bytes)

Closes: angular#27580
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue May 6, 2024
Ensure that file sizes are consistently formatted using decimal byte units, adhering to the International System of Units (SI) convention. This aligns with clarity and standardization across the project.

- Kilobyte (kB): 10^3 bytes (1000 bytes)
- Megabyte (MB): 10^6 bytes (1,000,000 bytes)
- Gigabyte (GB): 10^9 bytes (1,000,000,000 bytes)

Closes: angular#27580
alan-agius4 added a commit that referenced this issue May 6, 2024
Ensure that file sizes are consistently formatted using decimal byte units, adhering to the International System of Units (SI) convention. This aligns with clarity and standardization across the project.

- Kilobyte (kB): 10^3 bytes (1000 bytes)
- Megabyte (MB): 10^6 bytes (1,000,000 bytes)
- Gigabyte (GB): 10^9 bytes (1,000,000,000 bytes)

Closes: #27580
alan-agius4 added a commit that referenced this issue May 6, 2024
Ensure that file sizes are consistently formatted using decimal byte units, adhering to the International System of Units (SI) convention. This aligns with clarity and standardization across the project.

- Kilobyte (kB): 10^3 bytes (1000 bytes)
- Megabyte (MB): 10^6 bytes (1,000,000 bytes)
- Gigabyte (GB): 10^9 bytes (1,000,000,000 bytes)

Closes: #27580
(cherry picked from commit 9e13a8b)
@Ghostbird
Copy link
Author

Thanks for fixing this so quickly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: devkit/build-angular freq1: low Only reported by a handful of users who observe it rarely severity1: confusing type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants