Skip to content

Commit

Permalink
report: fix typos in report keys and bump the version
Browse files Browse the repository at this point in the history
Replace "kbytes" with "bytes" in `PrintSystemInformation()` in
`src/node_report.cc`, as RLIMIT_DATA, RLIMIT_RSS, and RLIMIT_AS are
given in bytes.
The report version is bumped from 4 to 5.

Refs: https://www.ibm.com/docs/en/aix/7.3?topic=k-kgetrlimit64-kernel-service
  • Loading branch information
technic960183 committed Dec 7, 2024
1 parent 9c046ea commit de272ff
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 12 deletions.
41 changes: 37 additions & 4 deletions doc/api/report.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ is provided below for reference.
```json
{
"header": {
"reportVersion": 4,
"reportVersion": 5,
"event": "exception",
"trigger": "Exception",
"filename": "report.20181221.005011.8974.0.001.json",
Expand Down Expand Up @@ -392,7 +392,7 @@ is provided below for reference.
"soft": "",
"hard": "unlimited"
},
"data_seg_size_kbytes": {
"data_seg_size_bytes": {
"soft": "unlimited",
"hard": "unlimited"
},
Expand All @@ -404,7 +404,7 @@ is provided below for reference.
"soft": "unlimited",
"hard": 65536
},
"max_memory_size_kbytes": {
"max_memory_size_bytes": {
"soft": "unlimited",
"hard": "unlimited"
},
Expand All @@ -424,7 +424,7 @@ is provided below for reference.
"soft": "unlimited",
"hard": 4127290
},
"virtual_memory_kbytes": {
"virtual_memory_bytes": {
"soft": "unlimited",
"hard": "unlimited"
}
Expand Down Expand Up @@ -588,6 +588,39 @@ Report version definitions are consistent across LTS releases.

### Version history

#### Version 5

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/56068
description: Fix typos in the memory limit units.
-->

Replace the keys `data_seg_size_kbytes`, `max_memory_size_kbytes` and `virtual_memory_kbytes` with `data_seg_size_bytes`, `max_memory_size_bytes` and `virtual_memory_bytes` respectively in `userLimits` section, as these values are given in bytes.

```json
{
"userLimits": {
// Skip some keys ...
"data_seg_size_kbytes": { // replaced with data_seg_size_bytes
"soft": "unlimited",
"hard": "unlimited"
},
// ...
"max_memory_size_kbytes": { // replaced with max_memory_size_bytes
"soft": "unlimited",
"hard": "unlimited"
},
// ...
"virtual_memory_kbytes": { // replaced with virtual_memory_bytes
"soft": "unlimited",
"hard": "unlimited"
}
}
}
```

#### Version 4

<!-- YAML
Expand Down
8 changes: 4 additions & 4 deletions src/node_report.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <cwctype>
#include <fstream>

constexpr int NODE_REPORT_VERSION = 4;
constexpr int NODE_REPORT_VERSION = 5;
constexpr int NANOS_PER_SEC = 1000 * 1000 * 1000;
constexpr double SEC_PER_MICROS = 1e-6;
constexpr int MAX_FRAME_COUNT = node::kMaxFrameCountForLogging;
Expand Down Expand Up @@ -732,13 +732,13 @@ static void PrintSystemInformation(JSONWriter* writer) {
int id;
} rlimit_strings[] = {
{"core_file_size_blocks", RLIMIT_CORE},
{"data_seg_size_kbytes", RLIMIT_DATA},
{"data_seg_size_bytes", RLIMIT_DATA},
{"file_size_blocks", RLIMIT_FSIZE},
#if !(defined(_AIX) || defined(__sun))
{"max_locked_memory_bytes", RLIMIT_MEMLOCK},
#endif
#ifndef __sun
{"max_memory_size_kbytes", RLIMIT_RSS},
{"max_memory_size_bytes", RLIMIT_RSS},
#endif
{"open_files", RLIMIT_NOFILE},
{"stack_size_bytes", RLIMIT_STACK},
Expand All @@ -747,7 +747,7 @@ static void PrintSystemInformation(JSONWriter* writer) {
{"max_user_processes", RLIMIT_NPROC},
#endif
#ifndef __OpenBSD__
{"virtual_memory_kbytes", RLIMIT_AS}
{"virtual_memory_bytes", RLIMIT_AS}
#endif
};

Expand Down
8 changes: 4 additions & 4 deletions test/common/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function _validateContent(report, fields = []) {
'glibcVersionRuntime', 'glibcVersionCompiler', 'cwd',
'reportVersion', 'networkInterfaces', 'threadId'];
checkForUnknownFields(header, headerFields);
assert.strictEqual(header.reportVersion, 4); // Increment as needed.
assert.strictEqual(header.reportVersion, 5); // Increment as needed.
assert.strictEqual(typeof header.event, 'string');
assert.strictEqual(typeof header.trigger, 'string');
assert(typeof header.filename === 'string' || header.filename === null);
Expand Down Expand Up @@ -309,11 +309,11 @@ function _validateContent(report, fields = []) {

// Verify the format of the userLimits section on non-Windows platforms.
if (!isWindows) {
const userLimitsFields = ['core_file_size_blocks', 'data_seg_size_kbytes',
const userLimitsFields = ['core_file_size_blocks', 'data_seg_size_bytes',
'file_size_blocks', 'max_locked_memory_bytes',
'max_memory_size_kbytes', 'open_files',
'max_memory_size_bytes', 'open_files',
'stack_size_bytes', 'cpu_time_seconds',
'max_user_processes', 'virtual_memory_kbytes'];
'max_user_processes', 'virtual_memory_bytes'];
checkForUnknownFields(report.userLimits, userLimitsFields);
for (const [type, limits] of Object.entries(report.userLimits)) {
assert.strictEqual(typeof type, 'string');
Expand Down

0 comments on commit de272ff

Please sign in to comment.