brson · GitHub

re #2036

In many error messages we display byte units (MiB, KiB, etc.). Sometimes these units are displayed differently based on the compile-time configuration (see https://github.com/tigerbeetle/tigerbeetle/pull/2036/files#diff-104744d347a9d7ea7a7e958f254327603a52f6e79517adbdba9950e8af779c97R499).

This code is becoming unwieldy. Per the above PR it may make sense to use custom formatters to automatically pick the best unit to display in these situations.

Ours would be similar to std.fmt.fmtIntSizeBin except that we want to use @divExact, expecting our number to always be evenly divisible by the displayed unit. We also want to continue to use comptime to ensure these numbers are evenly divisible during the build, and not have unexpected divExact failures at runtime.

Read the original on github.com ↗