Skip to content

Commit 1e76165

Browse files
authoredApr 19, 2022
doc: consolidate use of multiple-byte units
Refs: https://en.wikipedia.org/wiki/Byte#Multiple-byte_units PR-URL: nodejs#42587 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Mestery <[email protected]>
1 parent 51fd5db commit 1e76165

26 files changed

+46
-46
lines changed
 

‎doc/api/buffer.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ _may contain sensitive data_. Use [`buf.fill(0)`][`buf.fill()`] to initialize
833833
such `Buffer` instances with zeroes.
834834

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

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

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

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

‎doc/api/cli.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -666,10 +666,10 @@ added:
666666
changes:
667667
- version: v13.13.0
668668
pr-url: https://github.com/nodejs/node/pull/32520
669-
description: Change maximum default size of HTTP headers from 8 KB to 16 KB.
669+
description: Change maximum default size of HTTP headers from 8 KiB to 16 KiB.
670670
-->
671671

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

674674
### `--napi-modules`
675675

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

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

19991999
```console
20002000
$ node --max-old-space-size=1536 index.js

‎doc/api/errors.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2951,11 +2951,11 @@ changes:
29512951
- v10.15.0
29522952
commit: 186035243fad247e3955f
29532953
pr-url: https://github.com/nodejs-private/node-private/pull/143
2954-
description: Max header size in `http_parser` was set to 8 KB.
2954+
description: Max header size in `http_parser` was set to 8 KiB.
29552955
-->
29562956

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

‎doc/api/fs.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ added: v16.11.0
262262
* `highWaterMark` {integer} **Default:** `64 * 1024`
263263
* Returns: {fs.ReadStream}
264264
265-
Unlike the 16 kb default `highWaterMark` for a {stream.Readable}, the stream
266-
returned by this method has a default `highWaterMark` of 64 kb.
265+
Unlike the 16 KiB default `highWaterMark` for a {stream.Readable}, the stream
266+
returned by this method has a default `highWaterMark` of 64 KiB.
267267
268268
`options` can include `start` and `end` values to read a range of bytes from
269269
the file instead of the entire file. Both `start` and `end` are inclusive and
@@ -2186,8 +2186,8 @@ changes:
21862186
* `fs` {Object|null} **Default:** `null`
21872187
* Returns: {fs.ReadStream}
21882188
2189-
Unlike the 16 kb default `highWaterMark` for a {stream.Readable}, the stream
2190-
returned by this method has a default `highWaterMark` of 64 kb.
2189+
Unlike the 16 KiB default `highWaterMark` for a {stream.Readable}, the stream
2190+
returned by this method has a default `highWaterMark` of 64 KiB.
21912191
21922192
`options` can include `start` and `end` values to read a range of bytes from
21932193
the file instead of the entire file. Both `start` and `end` are inclusive and
@@ -3430,8 +3430,8 @@ to read a complete file into memory.
34303430
The additional read overhead can vary broadly on different systems and depends
34313431
on the type of file being read. If the file type is not a regular file (a pipe
34323432
for instance) and Node.js is unable to determine an actual file size, each read
3433-
operation will load on 64 KB of data. For regular files, each read will process
3434-
512 KB of data.
3433+
operation will load on 64 KiB of data. For regular files, each read will process
3434+
512 KiB of data.
34353435

34363436
For applications that require as-fast-as-possible reading of file contents, it
34373437
is better to use `fs.read()` directly and for application code to manage

‎doc/api/http.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2998,7 +2998,7 @@ changes:
29982998
* `maxHeaderSize` {number} Optionally overrides the value of
29992999
[`--max-http-header-size`][] for requests received by this server, i.e.
30003000
the maximum length of request headers in bytes.
3001-
**Default:** 16384 (16 KB).
3001+
**Default:** 16384 (16 KiB).
30023002
* `noDelay` {boolean} If set to `true`, it disables the use of Nagle's
30033003
algorithm immediately after a new incoming connection is received.
30043004
**Default:** `true`.
@@ -3154,7 +3154,7 @@ added:
31543154
* {number}
31553155

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

31603160
This can be overridden for servers and client requests by passing the
@@ -3231,7 +3231,7 @@ changes:
32313231
* `maxHeaderSize` {number} Optionally overrides the value of
32323232
[`--max-http-header-size`][] (the maximum length of response headers in
32333233
bytes) for responses received from the server.
3234-
**Default:** 16384 (16 KB).
3234+
**Default:** 16384 (16 KiB).
32353235
* `method` {string} A string specifying the HTTP request method. **Default:**
32363236
`'GET'`.
32373237
* `path` {string} Request path. Should include query string if any.

‎doc/api/stream.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1674,7 +1674,7 @@ If the loop terminates with a `break`, `return`, or a `throw`, the stream will
16741674
be destroyed. In other terms, iterating over a stream will consume the stream
16751675
fully. The stream will be read in chunks of size equal to the `highWaterMark`
16761676
option. In the code example above, data will be in a single chunk if the file
1677-
has less then 64 KB of data because no `highWaterMark` option is provided to
1677+
has less then 64 KiB of data because no `highWaterMark` option is provided to
16781678
[`fs.createReadStream()`][].
16791679

16801680
##### `readable.iterator([options])`
@@ -3047,7 +3047,7 @@ changes:
30473047
* `options` {Object}
30483048
* `highWaterMark` {number} Buffer level when
30493049
[`stream.write()`][stream-write] starts returning `false`. **Default:**
3050-
`16384` (16 KB), or `16` for `objectMode` streams.
3050+
`16384` (16 KiB), or `16` for `objectMode` streams.
30513051
* `decodeStrings` {boolean} Whether to encode `string`s passed to
30523052
[`stream.write()`][stream-write] to `Buffer`s (with the encoding
30533053
specified in the [`stream.write()`][stream-write] call) before passing
@@ -3420,7 +3420,7 @@ changes:
34203420
* `options` {Object}
34213421
* `highWaterMark` {number} The maximum [number of bytes][hwm-gotcha] to store
34223422
in the internal buffer before ceasing to read from the underlying resource.
3423-
**Default:** `16384` (16 KB), or `16` for `objectMode` streams.
3423+
**Default:** `16384` (16 KiB), or `16` for `objectMode` streams.
34243424
* `encoding` {string} If specified, then buffers will be decoded to
34253425
strings using the specified encoding. **Default:** `null`.
34263426
* `objectMode` {boolean} Whether this stream should behave

‎doc/api/util.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ changes:
536536
description: The `depth` default changed to `20`.
537537
- version: v11.0.0
538538
pr-url: https://github.com/nodejs/node/pull/22756
539-
description: The inspection output is now limited to about 128 MB. Data
539+
description: The inspection output is now limited to about 128 MiB. Data
540540
above that size will not be fully inspected.
541541
- version: v10.12.0
542542
pr-url: https://github.com/nodejs/node/pull/22788
@@ -778,7 +778,7 @@ console.log(thousand, million, bigNumber, bigDecimal);
778778
```
779779

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

784784
### Customizing `util.inspect` colors

‎doc/contributing/investigating-native-memory-leaks.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Leaks can be introduced in native addons and the following is a simple
101101
example leak based on the "Hello world" addon from
102102
[node-addon-examples](https://github.com/nodejs/node-addon-examples).
103103

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

107107
```cpp

‎doc/node.1

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ This flag is inherited from V8 and is subject to change upstream. It may
270270
disappear in a non-semver-major release.
271271
.
272272
.It Fl -max-http-header-size Ns = Ns Ar size
273-
Specify the maximum size of HTTP headers in bytes. Defaults to 16 KB.
273+
Specify the maximum size of HTTP headers in bytes. Defaults to 16 KiB.
274274
.
275275
.It Fl -napi-modules
276276
This option is a no-op.

‎lib/assert.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ function getCode(fd, line, column) {
213213
let lines = 0;
214214
// Prevent blocking the event loop by limiting the maximum amount of
215215
// data that may be read.
216-
let maxReads = 32; // bytesPerRead * maxReads = 512 kb
216+
let maxReads = 32; // bytesPerRead * maxReads = 512 KiB
217217
const bytesPerRead = 16384;
218218
// Use a single buffer up front that is reused until the call site is found.
219219
let buffer = Buffer.allocUnsafe(bytesPerRead);

‎lib/fs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2879,7 +2879,7 @@ function lazyLoadStreams() {
28792879

28802880
/**
28812881
* Creates a readable stream with a default `highWaterMark`
2882-
* of 64 kb.
2882+
* of 64 KiB.
28832883
* @param {string | Buffer | URL} path
28842884
* @param {string | {
28852885
* flags?: string;

‎lib/internal/crypto/scrypt.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const defaults = {
4141
N: 16384,
4242
r: 8,
4343
p: 1,
44-
maxmem: 32 << 20, // 32 MB, matches SCRYPT_MAX_MEM.
44+
maxmem: 32 << 20, // 32 MiB, matches SCRYPT_MAX_MEM.
4545
};
4646

4747
function scrypt(password, salt, keylen, options, callback = defaults) {

‎lib/internal/errors.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ E('ERR_FS_CP_SYMLINK_TO_SUBDIRECTORY',
10041004
'Cannot overwrite symlink in subdirectory of self', SystemError);
10051005
E('ERR_FS_CP_UNKNOWN', 'Cannot copy an unknown file type', SystemError);
10061006
E('ERR_FS_EISDIR', 'Path is a directory', SystemError);
1007-
E('ERR_FS_FILE_TOO_LARGE', 'File size (%s) is greater than 2 GB', RangeError);
1007+
E('ERR_FS_FILE_TOO_LARGE', 'File size (%s) is greater than 2 GiB', RangeError);
10081008
E('ERR_FS_INVALID_SYMLINK_TYPE',
10091009
'Symlink type must be one of "dir", "file", or "junction". Received "%s"',
10101010
Error); // Switch to TypeError. The current implementation does not seem right

‎lib/internal/fs/utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ const kMaximumCopyMode = COPYFILE_EXCL |
122122
COPYFILE_FICLONE |
123123
COPYFILE_FICLONE_FORCE;
124124

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

‎src/inspector_agent.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ static int StartDebugSignalHandler() {
9797
pthread_attr_t attr;
9898
CHECK_EQ(0, pthread_attr_init(&attr));
9999
#if defined(PTHREAD_STACK_MIN) && !defined(__FreeBSD__)
100-
// PTHREAD_STACK_MIN is 2 KB with musl libc, which is too small to safely
101-
// receive signals. PTHREAD_STACK_MIN + MINSIGSTKSZ is 8 KB on arm64, which
100+
// PTHREAD_STACK_MIN is 2 KiB with musl libc, which is too small to safely
101+
// receive signals. PTHREAD_STACK_MIN + MINSIGSTKSZ is 8 KiB on arm64, which
102102
// is the musl architecture with the biggest MINSIGSTKSZ so let's use that
103103
// as a lower bound and let's quadruple it just in case. The goal is to avoid
104-
// creating a big 2 or 4 MB address space gap (problematic on 32 bits
104+
// creating a big 2 or 4 MiB address space gap (problematic on 32 bits
105105
// because of fragmentation), not squeeze out every last byte.
106106
// Omitted on FreeBSD because it doesn't seem to like small stacks.
107107
const size_t stack_size = std::max(static_cast<size_t>(4 * 8192),

‎test/common/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ On non-Windows platforms, this always returns `true`.
5959

6060
### `createZeroFilledFile(filename)`
6161

62-
Creates a 10 MB file of all null characters.
62+
Creates a 10 MiB file of all null characters.
6363

6464
### `enoughTestMem`
6565

‎test/parallel/test-crypto-scrypt.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const good = [
2424
},
2525
// Test vectors from https://tools.ietf.org/html/rfc7914#page-13 that
2626
// should pass. Note that the test vector with N=1048576 is omitted
27-
// because it takes too long to complete and uses over 1 GB of memory.
27+
// because it takes too long to complete and uses over 1 GiB of memory.
2828
{
2929
pass: '',
3030
salt: '',

‎test/parallel/test-fs-util-validateoffsetlength.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const {
5050
);
5151
}
5252

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

‎test/parallel/test-http2-max-session-memory-leak.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const http2 = require('http2');
99
// mechanism.
1010

1111
const bodyLength = 8192;
12-
const maxSessionMemory = 1; // 1 MB
12+
const maxSessionMemory = 1; // 1 MiB
1313
const requestCount = 1000;
1414

1515
const server = http2.createServer({ maxSessionMemory });

‎test/parallel/test-tls-securepair-leak.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ setImmediate(() => {
2020
global.gc();
2121
const after = process.memoryUsage().external;
2222

23-
// It's not an exact science but a SecurePair grows .external by about 45 kB.
23+
// It's not an exact science but a SecurePair grows .external by about 45 KiB.
2424
// Unless AdjustAmountOfExternalAllocatedMemory() is called on destruction,
25-
// 10,000 instances make it grow by well over 400 MB. Allow for some slop
25+
// 10,000 instances make it grow by well over 400 MiB. Allow for some slop
2626
// because objects like buffers also affect the external limit.
2727
assert(after - before < 25 << 20);
2828
});

‎tools/compress_json.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

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

2727
step = 20

‎tools/gyp/pylib/gyp/generator/ninja.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2112,8 +2112,8 @@ class MEMORYSTATUSEX(ctypes.Structure):
21122112
ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat))
21132113

21142114
# VS 2015 uses 20% more working set than VS 2013 and can consume all RAM
2115-
# on a 64 GB machine.
2116-
mem_limit = max(1, stat.ullTotalPhys // (5 * (2 ** 30))) # total / 5GB
2115+
# on a 64 GiB machine.
2116+
mem_limit = max(1, stat.ullTotalPhys // (5 * (2 ** 30))) # total / 5GiB
21172117
hard_cap = max(1, int(os.environ.get("GYP_LINK_CONCURRENCY_MAX", 2 ** 32)))
21182118
return min(mem_limit, hard_cap)
21192119
elif sys.platform.startswith("linux"):

‎tools/inspector_protocol/encoding/encoding.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ namespace cbor {
167167
// must use a 32 bit wide length.
168168
// - At the top level, a message must be an indefinite length map
169169
// wrapped by an envelope.
170-
// - Maximal size for messages is 2^32 (4 GB).
170+
// - Maximal size for messages is 2^32 (4 GiB).
171171
// - For scalars, we support only the int32_t range, encoded as
172172
// UNSIGNED/NEGATIVE (major types 0 / 1).
173173
// - UTF16 strings, including with unbalanced surrogate pairs, are encoded

‎tools/inspector_protocol/lib/encoding_h.template

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ namespace cbor {
176176
// must use a 32 bit wide length.
177177
// - At the top level, a message must be an indefinite length map
178178
// wrapped by an envelope.
179-
// - Maximal size for messages is 2^32 (4 GB).
179+
// - Maximal size for messages is 2^32 (4 GiB).
180180
// - For scalars, we support only the int32_t range, encoded as
181181
// UNSIGNED/NEGATIVE (major types 0 / 1).
182182
// - UTF16 strings, including with unbalanced surrogate pairs, are encoded

‎tools/msvs/install_tools/install_tools.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ echo This script will install Python and the Visual Studio Build Tools, necessar
1313
echo to compile Node.js native modules. Note that Chocolatey and required Windows
1414
echo updates will also be installed.
1515
echo.
16-
echo This will require about 3 Gb of free disk space, plus any space necessary to
16+
echo This will require about 3 GiB of free disk space, plus any space necessary to
1717
echo install Windows updates. This will take a while to run.
1818
echo.
1919
echo Please close all open programs for the duration of the installation. If the

‎tools/v8_gypfiles/features.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@
275275
# will fail.
276276
'v8_enable_webassembly%': 1,
277277

278-
# Enable advanced BigInt algorithms, costing about 10-30 KB binary size
278+
# Enable advanced BigInt algorithms, costing about 10-30 KiB binary size
279279
# depending on platform.
280280
'v8_advanced_bigint_algorithms%': 1
281281
},

0 commit comments

Comments
 (0)
Please sign in to comment.