Use power-of-2 labels

What does this MR do and why?

Fixes #407876 https://gitlab.com/gitlab-org/gitlab/-/issues/407869, partially https://gitlab.com/gitlab-org/gitlab/-/issues/385409, and generally addresses SPIKE https://gitlab.com/gitlab-org/gitlab/-/issues/391546+

Long story short: we use power-of-2 values for storage sizes (1024 order multiplier), while we tend to label them with power-of-10 labels (KB, which is CI 1000 multiplier). See https://gitlab.com/gitlab-org/gitlab/-/issues/385409, and SPIKE results https://gitlab.com/gitlab-org/gitlab/-/issues/391546#note_1313262374 for more.

This MR changes labels for storage size notation from power-of-10 labels (KB, MB, GB) to power-of-2 labels (KiB, MiB, GiB). This MR does not change the underlying math, it only uses a more precise labels for backend driven labels (the frontend already uses power-of-2 labels).

It also updates Bytes notation to be just B (shorthand that both CI and IEC use). Agreed with UX team (link).

The MR is big but pretty straightforward. It consists of two parts, which might ease the review process:

  1. 666d1d62 — changes translations that are used in number_to_human_size (source) labelling.
  2. f1839d99 — updates all related specs that use a power-of-10 strings for testing.

Screenshots or screen recordings

This is not an exhaustive list of changes (there are some 50 affected places, including banners, emails, CLI output, etc), and these changes don't affect all the labels (the JS counter-part already labels values in power-of-2, but labels < 1 KiB values with bytes, and not B as this change proposes.

Project landing page: (e.g. http://localhost:3000/h5bp/html5-boilerplate)

Note the MiB use in the top banner, and GiB in the project status line:

image.png

System info: (e.g. http://localhost:3000/admin/system_info)

image

How to set up and validate locally

I think the easiest way to reproduce the behaviour, would be to run rails c with following:

ActiveSupport::NumberHelper.number_to_human_size(1.megabytes)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Kos Palchyk

Merge request reports

Loading