Skip to content

Commit

Permalink
doc: consolidate use of multiple-byte units
Browse files Browse the repository at this point in the history
Refs: https://en.wikipedia.org/wiki/Byte#Multiple-byte_units

PR-URL: #42587
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Mestery <mestery@protonmail.com>
  • Loading branch information
aduh95 authored and danielleadams committed Jun 27, 2022
1 parent 1ae31c4 commit b65293f
Show file tree
Hide file tree
Showing 26 changed files with 46 additions and 46 deletions.
6 changes: 3 additions & 3 deletions doc/api/buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ _may contain sensitive data_. Use [`buf.fill(0)`][`buf.fill()`] to initialize
such `Buffer` instances with zeroes.

When using [`Buffer.allocUnsafe()`][] to allocate new `Buffer` instances,
allocations under 4 KB are sliced from a single pre-allocated `Buffer`. This
allocations under 4 KiB are sliced from a single pre-allocated `Buffer`. This
allows applications to avoid the garbage collection overhead of creating many
individually allocated `Buffer` instances. This approach improves both
performance and memory usage by eliminating the need to track and clean up as
Expand Down Expand Up @@ -5182,9 +5182,9 @@ changes:
* {integer} The largest size allowed for a single `Buffer` instance.

On 32-bit architectures, this value currently is 2<sup>30</sup> - 1 (about 1
GB).
GiB).

On 64-bit architectures, this value currently is 2<sup>32</sup> (about 4 GB).
On 64-bit architectures, this value currently is 2<sup>32</sup> (about 4 GiB).

It reflects [`v8::TypedArray::kMaxLength`][] under the hood.

Expand Down
8 changes: 4 additions & 4 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -656,10 +656,10 @@ added:
changes:
- version: v13.13.0
pr-url: https://github.com/nodejs/node/pull/32520
description: Change maximum default size of HTTP headers from 8 KB to 16 KB.
description: Change maximum default size of HTTP headers from 8 KiB to 16 KiB.
-->

Specify the maximum size, in bytes, of HTTP headers. Defaults to 16 KB.
Specify the maximum size, in bytes, of HTTP headers. Defaults to 16 KiB.

### `--napi-modules`

Expand Down Expand Up @@ -1940,8 +1940,8 @@ Sets the max memory size of V8's old memory section. As memory
consumption approaches the limit, V8 will spend more time on
garbage collection in an effort to free unused memory.

On a machine with 2 GB of memory, consider setting this to
1536 (1.5 GB) to leave some memory for other uses and avoid swapping.
On a machine with 2 GiB of memory, consider setting this to
1536 (1.5 GiB) to leave some memory for other uses and avoid swapping.

```console
$ node --max-old-space-size=1536 index.js
Expand Down
4 changes: 2 additions & 2 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -2914,11 +2914,11 @@ changes:
- v10.15.0
commit: 186035243fad247e3955f
pr-url: https://github.com/nodejs-private/node-private/pull/143
description: Max header size in `http_parser` was set to 8 KB.
description: Max header size in `http_parser` was set to 8 KiB.
-->

Too much HTTP header data was received. In order to protect against malicious or
malconfigured clients, if more than 8 KB of HTTP header data is received then
malconfigured clients, if more than 8 KiB of HTTP header data is received then
HTTP parsing will abort without a request or response object being created, and
an `Error` with this code will be emitted.

Expand Down
12 changes: 6 additions & 6 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ added: v16.11.0
* `highWaterMark` {integer} **Default:** `64 * 1024`
* Returns: {fs.ReadStream}
Unlike the 16 kb default `highWaterMark` for a {stream.Readable}, the stream
returned by this method has a default `highWaterMark` of 64 kb.
Unlike the 16 KiB default `highWaterMark` for a {stream.Readable}, the stream
returned by this method has a default `highWaterMark` of 64 KiB.
`options` can include `start` and `end` values to read a range of bytes from
the file instead of the entire file. Both `start` and `end` are inclusive and
Expand Down Expand Up @@ -2094,8 +2094,8 @@ changes:
* `fs` {Object|null} **Default:** `null`
* Returns: {fs.ReadStream}
Unlike the 16 kb default `highWaterMark` for a {stream.Readable}, the stream
returned by this method has a default `highWaterMark` of 64 kb.
Unlike the 16 KiB default `highWaterMark` for a {stream.Readable}, the stream
returned by this method has a default `highWaterMark` of 64 KiB.
`options` can include `start` and `end` values to read a range of bytes from
the file instead of the entire file. Both `start` and `end` are inclusive and
Expand Down Expand Up @@ -3233,8 +3233,8 @@ to read a complete file into memory.
The additional read overhead can vary broadly on different systems and depends
on the type of file being read. If the file type is not a regular file (a pipe
for instance) and Node.js is unable to determine an actual file size, each read
operation will load on 64 KB of data. For regular files, each read will process
512 KB of data.
operation will load on 64 KiB of data. For regular files, each read will process
512 KiB of data.

For applications that require as-fast-as-possible reading of file contents, it
is better to use `fs.read()` directly and for application code to manage
Expand Down
6 changes: 3 additions & 3 deletions doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -2959,7 +2959,7 @@ changes:
* `maxHeaderSize` {number} Optionally overrides the value of
[`--max-http-header-size`][] for requests received by this server, i.e.
the maximum length of request headers in bytes.
**Default:** 16384 (16 KB).
**Default:** 16384 (16 KiB).
* `noDelay` {boolean} If set to `true`, it disables the use of Nagle's
algorithm immediately after a new incoming connection is received.
**Default:** `false`.
Expand Down Expand Up @@ -3115,7 +3115,7 @@ added:
* {number}

Read-only property specifying the maximum allowed size of HTTP headers in bytes.
Defaults to 16 KB. Configurable using the [`--max-http-header-size`][] CLI
Defaults to 16 KiB. Configurable using the [`--max-http-header-size`][] CLI
option.

This can be overridden for servers and client requests by passing the
Expand Down Expand Up @@ -3190,7 +3190,7 @@ changes:
* `maxHeaderSize` {number} Optionally overrides the value of
[`--max-http-header-size`][] (the maximum length of response headers in
bytes) for responses received from the server.
**Default:** 16384 (16 KB).
**Default:** 16384 (16 KiB).
* `method` {string} A string specifying the HTTP request method. **Default:**
`'GET'`.
* `path` {string} Request path. Should include query string if any.
Expand Down
6 changes: 3 additions & 3 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -1616,7 +1616,7 @@ If the loop terminates with a `break`, `return`, or a `throw`, the stream will
be destroyed. In other terms, iterating over a stream will consume the stream
fully. The stream will be read in chunks of size equal to the `highWaterMark`
option. In the code example above, data will be in a single chunk if the file
has less then 64 KB of data because no `highWaterMark` option is provided to
has less then 64 KiB of data because no `highWaterMark` option is provided to
[`fs.createReadStream()`][].

##### `readable.iterator([options])`
Expand Down Expand Up @@ -2879,7 +2879,7 @@ changes:
* `options` {Object}
* `highWaterMark` {number} Buffer level when
[`stream.write()`][stream-write] starts returning `false`. **Default:**
`16384` (16 KB), or `16` for `objectMode` streams.
`16384` (16 KiB), or `16` for `objectMode` streams.
* `decodeStrings` {boolean} Whether to encode `string`s passed to
[`stream.write()`][stream-write] to `Buffer`s (with the encoding
specified in the [`stream.write()`][stream-write] call) before passing
Expand Down Expand Up @@ -3252,7 +3252,7 @@ changes:
* `options` {Object}
* `highWaterMark` {number} The maximum [number of bytes][hwm-gotcha] to store
in the internal buffer before ceasing to read from the underlying resource.
**Default:** `16384` (16 KB), or `16` for `objectMode` streams.
**Default:** `16384` (16 KiB), or `16` for `objectMode` streams.
* `encoding` {string} If specified, then buffers will be decoded to
strings using the specified encoding. **Default:** `null`.
* `objectMode` {boolean} Whether this stream should behave
Expand Down
4 changes: 2 additions & 2 deletions doc/api/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ changes:
description: The `depth` default changed to `20`.
- version: v11.0.0
pr-url: https://github.com/nodejs/node/pull/22756
description: The inspection output is now limited to about 128 MB. Data
description: The inspection output is now limited to about 128 MiB. Data
above that size will not be fully inspected.
- version: v10.12.0
pr-url: https://github.com/nodejs/node/pull/22788
Expand Down Expand Up @@ -774,7 +774,7 @@ console.log(thousand, million, bigNumber, bigDecimal);
```

`util.inspect()` is a synchronous method intended for debugging. Its maximum
output length is approximately 128 MB. Inputs that result in longer output will
output length is approximately 128 MiB. Inputs that result in longer output will
be truncated.

### Customizing `util.inspect` colors
Expand Down
2 changes: 1 addition & 1 deletion doc/contributing/investigating-native-memory-leaks.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Leaks can be introduced in native addons and the following is a simple
example leak based on the "Hello world" addon from
[node-addon-examples](https://github.com/nodejs/node-addon-examples).

In this example, a loop which allocates approximately 1 MB of memory and never
In this example, a loop which allocates approximately 1 MiB of memory and never
frees it has been added:

```cpp
Expand Down
2 changes: 1 addition & 1 deletion doc/node.1
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ This flag is inherited from V8 and is subject to change upstream. It may
disappear in a non-semver-major release.
.
.It Fl -max-http-header-size Ns = Ns Ar size
Specify the maximum size of HTTP headers in bytes. Defaults to 16 KB.
Specify the maximum size of HTTP headers in bytes. Defaults to 16 KiB.
.
.It Fl -napi-modules
This option is a no-op.
Expand Down
2 changes: 1 addition & 1 deletion lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ function getCode(fd, line, column) {
let lines = 0;
// Prevent blocking the event loop by limiting the maximum amount of
// data that may be read.
let maxReads = 32; // bytesPerRead * maxReads = 512 kb
let maxReads = 32; // bytesPerRead * maxReads = 512 KiB
const bytesPerRead = 16384;
// Use a single buffer up front that is reused until the call site is found.
let buffer = Buffer.allocUnsafe(bytesPerRead);
Expand Down
2 changes: 1 addition & 1 deletion lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2866,7 +2866,7 @@ function lazyLoadStreams() {

/**
* Creates a readable stream with a default `highWaterMark`
* of 64 kb.
* of 64 KiB.
* @param {string | Buffer | URL} path
* @param {string | {
* flags?: string;
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/crypto/scrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const defaults = {
N: 16384,
r: 8,
p: 1,
maxmem: 32 << 20, // 32 MB, matches SCRYPT_MAX_MEM.
maxmem: 32 << 20, // 32 MiB, matches SCRYPT_MAX_MEM.
};

function scrypt(password, salt, keylen, options, callback = defaults) {
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ E('ERR_FS_CP_SYMLINK_TO_SUBDIRECTORY',
'Cannot overwrite symlink in subdirectory of self', SystemError);
E('ERR_FS_CP_UNKNOWN', 'Cannot copy an unknown file type', SystemError);
E('ERR_FS_EISDIR', 'Path is a directory', SystemError);
E('ERR_FS_FILE_TOO_LARGE', 'File size (%s) is greater than 2 GB', RangeError);
E('ERR_FS_FILE_TOO_LARGE', 'File size (%s) is greater than 2 GiB', RangeError);
E('ERR_FS_INVALID_SYMLINK_TYPE',
'Symlink type must be one of "dir", "file", or "junction". Received "%s"',
Error); // Switch to TypeError. The current implementation does not seem right
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/fs/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const kMaximumCopyMode = COPYFILE_EXCL |
COPYFILE_FICLONE |
COPYFILE_FICLONE_FORCE;

// Most platforms don't allow reads or writes >= 2 GB.
// Most platforms don't allow reads or writes >= 2 GiB.
// See https://github.com/libuv/libuv/pull/1501.
const kIoMaxLength = 2 ** 31 - 1;

Expand Down
6 changes: 3 additions & 3 deletions src/inspector_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ static int StartDebugSignalHandler() {
pthread_attr_t attr;
CHECK_EQ(0, pthread_attr_init(&attr));
#if defined(PTHREAD_STACK_MIN) && !defined(__FreeBSD__)
// PTHREAD_STACK_MIN is 2 KB with musl libc, which is too small to safely
// receive signals. PTHREAD_STACK_MIN + MINSIGSTKSZ is 8 KB on arm64, which
// PTHREAD_STACK_MIN is 2 KiB with musl libc, which is too small to safely
// receive signals. PTHREAD_STACK_MIN + MINSIGSTKSZ is 8 KiB on arm64, which
// is the musl architecture with the biggest MINSIGSTKSZ so let's use that
// as a lower bound and let's quadruple it just in case. The goal is to avoid
// creating a big 2 or 4 MB address space gap (problematic on 32 bits
// creating a big 2 or 4 MiB address space gap (problematic on 32 bits
// because of fragmentation), not squeeze out every last byte.
// Omitted on FreeBSD because it doesn't seem to like small stacks.
const size_t stack_size = std::max(static_cast<size_t>(4 * 8192),
Expand Down
2 changes: 1 addition & 1 deletion test/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ On non-Windows platforms, this always returns `true`.

### `createZeroFilledFile(filename)`

Creates a 10 MB file of all null characters.
Creates a 10 MiB file of all null characters.

### `enoughTestMem`

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-crypto-scrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const good = [
},
// Test vectors from https://tools.ietf.org/html/rfc7914#page-13 that
// should pass. Note that the test vector with N=1048576 is omitted
// because it takes too long to complete and uses over 1 GB of memory.
// because it takes too long to complete and uses over 1 GiB of memory.
{
pass: '',
salt: '',
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-fs-util-validateoffsetlength.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const {
);
}

// Most platforms don't allow reads or writes >= 2 GB.
// Most platforms don't allow reads or writes >= 2 GiB.
// See https://github.com/libuv/libuv/pull/1501.
const kIoMaxLength = 2 ** 31 - 1;

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http2-max-session-memory-leak.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const http2 = require('http2');
// mechanism.

const bodyLength = 8192;
const maxSessionMemory = 1; // 1 MB
const maxSessionMemory = 1; // 1 MiB
const requestCount = 1000;

const server = http2.createServer({ maxSessionMemory });
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-tls-securepair-leak.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ setImmediate(() => {
global.gc();
const after = process.memoryUsage().external;

// It's not an exact science but a SecurePair grows .external by about 45 kB.
// It's not an exact science but a SecurePair grows .external by about 45 KiB.
// Unless AdjustAmountOfExternalAllocatedMemory() is called on destruction,
// 10,000 instances make it grow by well over 400 MB. Allow for some slop
// 10,000 instances make it grow by well over 400 MiB. Allow for some slop
// because objects like buffers also affect the external limit.
assert(after - before < 25 << 20);
});
2 changes: 1 addition & 1 deletion tools/compress_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

# To make decompression a little easier, we prepend the compressed data
# with the size of the uncompressed data as a 24 bits BE unsigned integer.
assert len(text) < 1 << 24, 'Uncompressed JSON must be < 16 MB.'
assert len(text) < 1 << 24, 'Uncompressed JSON must be < 16 MiB.'
data = struct.pack('>I', len(text))[1:4] + data

step = 20
Expand Down
4 changes: 2 additions & 2 deletions tools/gyp/pylib/gyp/generator/ninja.py
Original file line number Diff line number Diff line change
Expand Up @@ -2112,8 +2112,8 @@ class MEMORYSTATUSEX(ctypes.Structure):
ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat))

# VS 2015 uses 20% more working set than VS 2013 and can consume all RAM
# on a 64 GB machine.
mem_limit = max(1, stat.ullTotalPhys // (5 * (2 ** 30))) # total / 5GB
# on a 64 GiB machine.
mem_limit = max(1, stat.ullTotalPhys // (5 * (2 ** 30))) # total / 5GiB
hard_cap = max(1, int(os.environ.get("GYP_LINK_CONCURRENCY_MAX", 2 ** 32)))
return min(mem_limit, hard_cap)
elif sys.platform.startswith("linux"):
Expand Down
2 changes: 1 addition & 1 deletion tools/inspector_protocol/encoding/encoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ namespace cbor {
// must use a 32 bit wide length.
// - At the top level, a message must be an indefinite length map
// wrapped by an envelope.
// - Maximal size for messages is 2^32 (4 GB).
// - Maximal size for messages is 2^32 (4 GiB).
// - For scalars, we support only the int32_t range, encoded as
// UNSIGNED/NEGATIVE (major types 0 / 1).
// - UTF16 strings, including with unbalanced surrogate pairs, are encoded
Expand Down
2 changes: 1 addition & 1 deletion tools/inspector_protocol/lib/encoding_h.template
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ namespace cbor {
// must use a 32 bit wide length.
// - At the top level, a message must be an indefinite length map
// wrapped by an envelope.
// - Maximal size for messages is 2^32 (4 GB).
// - Maximal size for messages is 2^32 (4 GiB).
// - For scalars, we support only the int32_t range, encoded as
// UNSIGNED/NEGATIVE (major types 0 / 1).
// - UTF16 strings, including with unbalanced surrogate pairs, are encoded
Expand Down
2 changes: 1 addition & 1 deletion tools/msvs/install_tools/install_tools.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ echo This script will install Python and the Visual Studio Build Tools, necessar
echo to compile Node.js native modules. Note that Chocolatey and required Windows
echo updates will also be installed.
echo.
echo This will require about 3 Gb of free disk space, plus any space necessary to
echo This will require about 3 GiB of free disk space, plus any space necessary to
echo install Windows updates. This will take a while to run.
echo.
echo Please close all open programs for the duration of the installation. If the
Expand Down
2 changes: 1 addition & 1 deletion tools/v8_gypfiles/features.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
# will fail.
'v8_enable_webassembly%': 1,

# Enable advanced BigInt algorithms, costing about 10-30 KB binary size
# Enable advanced BigInt algorithms, costing about 10-30 KiB binary size
# depending on platform.
'v8_advanced_bigint_algorithms%': 1
},
Expand Down

0 comments on commit b65293f

Please sign in to comment.