Second-last step towards migrating from legacy (Kb, Mb, ...) to IEC (KiB, MiB, ...) units #28
Closed
4 of 5 tasks
Labels
Misc
Issues that cannot be classified otherwise
needs patch
Implement the agreed fix and prepare a patch for review
PLUS 2024
Issues reserved for R Dev Day @ PLUS 2024
Background
R uses home-made ("legacy") units for object and file sizes that, e.g.
Note that it uses 'Gb', which is actually Gigabits (=1000^3 bits).
It should really be using 'GiB' per the official IEC standard, which are defined as KiB (1024 bytes), MiB (1024^2 bytes), GiB (1024^3 bytes), TiB (1024^4 bytes). FWIW, there is also an SI standard: kB (1000 bytes), MB (1000^2 bytes), GB (1000^3 bytes), TB (1000^4 bytes).
Actions
Gist:
utils:::format.object_size()
method already supports outputting legacy, IEC and SI units via argumentlegacy
,IEC
, andSI
.error(_("cannot allocate memory block of size %0.f Tb"), size)
->error(_("cannot allocate memory block of size %0.f %s"), size, "Tb")
make check
.Special care has to be taken to avoid triggering additional memory allocations when producing these error messages. This is because in several cases these are triggered when we run out of memory.
After we know the above works as it should, it can be pushed to the R source. After this, we should:
%s
, e.g. from"cannot allocate memory block of size %0.f Tb"
to"cannot allocate memory block of size %0.f %s"
Eventually, we can switch to IEC units updating the above unit string constants to the IEC standard, e.g.
sed -i 's/"Tb"/"TiB"/'
.Note that with this strategy, if we later on would like to move from IEC to SI units, we don't have to update the message format strings and also not the translations - just the unit string constants and how we calculate the values.
R-Core Member
See also
For full background and more details, see HenrikBengtsson/Wishlist-for-R#6.
The text was updated successfully, but these errors were encountered: