@memlab/cli 1.0.25 → 1.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/heap/DiffLeakCommand.d.ts +1 -1
- package/dist/commands/heap/DiffLeakCommand.js +6 -6
- package/dist/lib/CLIUtils.js +15 -2
- package/dist/options/experiment/ExperimentOptionUtils.d.ts +13 -0
- package/dist/options/experiment/ExperimentOptionUtils.js +39 -0
- package/dist/options/experiment/SetControlWorkDirOption.d.ts +1 -2
- package/dist/options/experiment/SetControlWorkDirOption.js +3 -25
- package/dist/options/experiment/SetTreatmentWorkDirOption.d.ts +2 -2
- package/dist/options/experiment/SetTreatmentWorkDirOption.js +4 -13
- package/package.json +1 -1
|
@@ -13,7 +13,7 @@ import type { CheckLeakCommandOptions } from './CheckLeakCommand';
|
|
|
13
13
|
import BaseCommand, { CommandCategory } from '../../BaseCommand';
|
|
14
14
|
export declare type WorkDirSettings = {
|
|
15
15
|
controlWorkDirs: Array<string>;
|
|
16
|
-
|
|
16
|
+
treatmentWorkDirs: Array<string>;
|
|
17
17
|
};
|
|
18
18
|
export default class CheckLeakCommand extends BaseCommand {
|
|
19
19
|
private isMLClustering;
|
|
@@ -103,30 +103,30 @@ class CheckLeakCommand extends BaseCommand_1.default {
|
|
|
103
103
|
var _a, _b;
|
|
104
104
|
// double check parameters
|
|
105
105
|
if (!((_a = options.configFromOptions) === null || _a === void 0 ? void 0 : _a.controlWorkDirs) ||
|
|
106
|
-
!((_b = options.configFromOptions) === null || _b === void 0 ? void 0 : _b.
|
|
106
|
+
!((_b = options.configFromOptions) === null || _b === void 0 ? void 0 : _b.treatmentWorkDirs)) {
|
|
107
107
|
core_1.info.error('Please specify control and test working directory');
|
|
108
108
|
throw core_1.utils.haltOrThrow('No control or test working directory specified');
|
|
109
109
|
}
|
|
110
110
|
// get parameters
|
|
111
111
|
const controlWorkDirs = options.configFromOptions['controlWorkDirs'];
|
|
112
|
-
const
|
|
112
|
+
const treatmentWorkDirs = options.configFromOptions['treatmentWorkDirs'];
|
|
113
113
|
return {
|
|
114
114
|
controlWorkDirs,
|
|
115
|
-
|
|
115
|
+
treatmentWorkDirs,
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
118
|
run(options) {
|
|
119
119
|
return __awaiter(this, void 0, void 0, function* () {
|
|
120
120
|
core_1.config.chaseWeakMapEdge = false;
|
|
121
|
-
const { controlWorkDirs,
|
|
121
|
+
const { controlWorkDirs, treatmentWorkDirs } = this.getWorkDirs(options);
|
|
122
122
|
const { runMetaInfoManager } = core_1.runInfoUtils;
|
|
123
123
|
runMetaInfoManager.setConfigFromRunMeta({
|
|
124
|
-
workDir:
|
|
124
|
+
workDir: treatmentWorkDirs[0],
|
|
125
125
|
silentFail: true,
|
|
126
126
|
});
|
|
127
127
|
// diff memory leaks
|
|
128
128
|
this.useDefaultMLClusteringSetting(options.cliArgs);
|
|
129
|
-
yield core_1.analysis.diffLeakByWorkDir({ controlWorkDirs,
|
|
129
|
+
yield core_1.analysis.diffLeakByWorkDir({ controlWorkDirs, treatmentWorkDirs });
|
|
130
130
|
this.restoreDefaultMLClusteringSetting(options.cliArgs);
|
|
131
131
|
});
|
|
132
132
|
}
|
package/dist/lib/CLIUtils.js
CHANGED
|
@@ -39,6 +39,19 @@ function filterAndGetUndefinedArgs(cliArgs) {
|
|
|
39
39
|
return ret;
|
|
40
40
|
}
|
|
41
41
|
exports.filterAndGetUndefinedArgs = filterAndGetUndefinedArgs;
|
|
42
|
+
function quoteIfNecessary(v) {
|
|
43
|
+
if (typeof v !== 'string') {
|
|
44
|
+
return v;
|
|
45
|
+
}
|
|
46
|
+
// if the string contains any whitespace character
|
|
47
|
+
if (/\s/.test(v)) {
|
|
48
|
+
// escape any existing " character
|
|
49
|
+
v = v.replace(/"/g, '\\"');
|
|
50
|
+
// wrap the string with "
|
|
51
|
+
v = `"${v}"`;
|
|
52
|
+
}
|
|
53
|
+
return v;
|
|
54
|
+
}
|
|
42
55
|
function argsToString(args) {
|
|
43
56
|
let ret = '';
|
|
44
57
|
for (const optionName of Object.keys(args)) {
|
|
@@ -51,11 +64,11 @@ function argsToString(args) {
|
|
|
51
64
|
}
|
|
52
65
|
else if (Array.isArray(value)) {
|
|
53
66
|
value.forEach(v => {
|
|
54
|
-
ret += `--${optionName}=${v} `;
|
|
67
|
+
ret += `--${optionName}=${quoteIfNecessary(v)} `;
|
|
55
68
|
});
|
|
56
69
|
}
|
|
57
70
|
else {
|
|
58
|
-
ret += `--${optionName}=${value} `;
|
|
71
|
+
ret += `--${optionName}=${quoteIfNecessary(value)} `;
|
|
59
72
|
}
|
|
60
73
|
}
|
|
61
74
|
return ret.trim();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall web_perf_infra
|
|
9
|
+
*/
|
|
10
|
+
import type { ParsedArgs } from 'minimist';
|
|
11
|
+
import type { Nullable } from '@memlab/core';
|
|
12
|
+
export declare function extractAndCheckWorkDirs(optionName: string, args: ParsedArgs): Nullable<string[]>;
|
|
13
|
+
//# sourceMappingURL=ExperimentOptionUtils.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
* @format
|
|
9
|
+
* @oncall web_perf_infra
|
|
10
|
+
*/
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.extractAndCheckWorkDirs = void 0;
|
|
16
|
+
const fs_1 = __importDefault(require("fs"));
|
|
17
|
+
const core_1 = require("@memlab/core");
|
|
18
|
+
function extractAndCheckWorkDirs(optionName, args) {
|
|
19
|
+
let dirs = [];
|
|
20
|
+
const flagValue = args[optionName];
|
|
21
|
+
if (!flagValue) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
if (Array.isArray(flagValue)) {
|
|
25
|
+
dirs = flagValue;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
dirs = [flagValue];
|
|
29
|
+
}
|
|
30
|
+
for (const dir of dirs) {
|
|
31
|
+
if (fs_1.default.existsSync(dir)) {
|
|
32
|
+
core_1.fileManager.createDefaultVisitOrderMetaFile({
|
|
33
|
+
workDir: dir,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return dirs;
|
|
38
|
+
}
|
|
39
|
+
exports.extractAndCheckWorkDirs = extractAndCheckWorkDirs;
|
|
@@ -13,8 +13,7 @@ import { BaseOption } from '@memlab/core';
|
|
|
13
13
|
export default class SetControlWorkDirOption extends BaseOption {
|
|
14
14
|
getOptionName(): string;
|
|
15
15
|
getDescription(): string;
|
|
16
|
-
|
|
17
|
-
parse(config: MemLabConfig, args: ParsedArgs): Promise<{
|
|
16
|
+
parse(_config: MemLabConfig, args: ParsedArgs): Promise<{
|
|
18
17
|
controlWorkDirs?: Nullable<string[]>;
|
|
19
18
|
}>;
|
|
20
19
|
}
|
|
@@ -21,9 +21,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
21
21
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
22
|
};
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
const fs_1 = __importDefault(require("fs"));
|
|
25
24
|
const core_1 = require("@memlab/core");
|
|
26
25
|
const OptionConstant_1 = __importDefault(require("../lib/OptionConstant"));
|
|
26
|
+
const ExperimentOptionUtils_1 = require("./ExperimentOptionUtils");
|
|
27
27
|
class SetControlWorkDirOption extends core_1.BaseOption {
|
|
28
28
|
getOptionName() {
|
|
29
29
|
return OptionConstant_1.default.optionNames.CONTROL_WORK_DIR;
|
|
@@ -31,31 +31,9 @@ class SetControlWorkDirOption extends core_1.BaseOption {
|
|
|
31
31
|
getDescription() {
|
|
32
32
|
return 'set the working directory of the control run';
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
let dirs = [];
|
|
36
|
-
const name = this.getOptionName();
|
|
37
|
-
const flagValue = args[name];
|
|
38
|
-
if (!flagValue) {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
if (Array.isArray(flagValue)) {
|
|
42
|
-
dirs = flagValue;
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
dirs = [flagValue];
|
|
46
|
-
}
|
|
47
|
-
for (const dir of dirs) {
|
|
48
|
-
if (fs_1.default.existsSync(dir)) {
|
|
49
|
-
core_1.fileManager.createDefaultVisitOrderMetaFile({
|
|
50
|
-
workDir: dir,
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return dirs;
|
|
55
|
-
}
|
|
56
|
-
parse(config, args) {
|
|
34
|
+
parse(_config, args) {
|
|
57
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
const dirs =
|
|
36
|
+
const dirs = (0, ExperimentOptionUtils_1.extractAndCheckWorkDirs)(this.getOptionName(), args);
|
|
59
37
|
return { controlWorkDirs: dirs };
|
|
60
38
|
});
|
|
61
39
|
}
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
* @oncall web_perf_infra
|
|
9
9
|
*/
|
|
10
10
|
import type { ParsedArgs } from 'minimist';
|
|
11
|
-
import type { MemLabConfig } from '@memlab/core';
|
|
11
|
+
import type { MemLabConfig, Nullable } from '@memlab/core';
|
|
12
12
|
import { BaseOption } from '@memlab/core';
|
|
13
13
|
export default class SetTreatmentWorkDirOption extends BaseOption {
|
|
14
14
|
getOptionName(): string;
|
|
15
15
|
getDescription(): string;
|
|
16
16
|
parse(config: MemLabConfig, args: ParsedArgs): Promise<{
|
|
17
|
-
|
|
17
|
+
treatmentWorkDirs?: Nullable<string[]>;
|
|
18
18
|
}>;
|
|
19
19
|
}
|
|
20
20
|
//# sourceMappingURL=SetTreatmentWorkDirOption.d.ts.map
|
|
@@ -21,29 +21,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
21
21
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
22
|
};
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
const fs_1 = __importDefault(require("fs"));
|
|
25
24
|
const core_1 = require("@memlab/core");
|
|
26
25
|
const OptionConstant_1 = __importDefault(require("../lib/OptionConstant"));
|
|
26
|
+
const ExperimentOptionUtils_1 = require("./ExperimentOptionUtils");
|
|
27
27
|
class SetTreatmentWorkDirOption extends core_1.BaseOption {
|
|
28
28
|
getOptionName() {
|
|
29
29
|
return OptionConstant_1.default.optionNames.TREATMENT_WORK_DIR;
|
|
30
30
|
}
|
|
31
31
|
getDescription() {
|
|
32
|
-
return 'set the working directory of the
|
|
32
|
+
return 'set the working directory of the treatment run';
|
|
33
33
|
}
|
|
34
34
|
parse(config, args) {
|
|
35
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
if (args[name]) {
|
|
39
|
-
ret.treatmentWorkDir = args[name];
|
|
40
|
-
if (fs_1.default.existsSync(ret.treatmentWorkDir)) {
|
|
41
|
-
core_1.fileManager.createDefaultVisitOrderMetaFile({
|
|
42
|
-
workDir: ret.treatmentWorkDir,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return ret;
|
|
36
|
+
const dirs = (0, ExperimentOptionUtils_1.extractAndCheckWorkDirs)(this.getOptionName(), args);
|
|
37
|
+
return { treatmentWorkDirs: dirs };
|
|
47
38
|
});
|
|
48
39
|
}
|
|
49
40
|
}
|