bin/runcpu: don't wrap programs under systemd, parse the result instead
This commit is contained in:
@@ -1,10 +1,8 @@
|
|||||||
import yargs from 'yargs';
|
import yargs from 'yargs';
|
||||||
import { spawn } from 'child_process';
|
import { spawn } from 'child_process';
|
||||||
import { promisifySpawn } from '../cli.js';
|
|
||||||
import { RunCPUOptions, runcpuOptions } from '../commands/spec.js';
|
import { RunCPUOptions, runcpuOptions } from '../commands/spec.js';
|
||||||
import { systemdRunOptions } from '../commands/systemd.js';
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { ConfigOptions, mkSPEC, renderConfig } from '../spec/index.js';
|
import { ConfigOptions, mkSPEC, renderConfig, getBaseRatios } from '../spec/index.js';
|
||||||
import { sw64TargetOptions } from '../commands/compiler.js';
|
import { sw64TargetOptions } from '../commands/compiler.js';
|
||||||
import crypto from 'crypto';
|
import crypto from 'crypto';
|
||||||
import { hideBin } from 'yargs/helpers';
|
import { hideBin } from 'yargs/helpers';
|
||||||
@@ -85,31 +83,16 @@ console.log(`using sysroot: ${chalk.red(sysroot)}`);
|
|||||||
|
|
||||||
const specPath = path.resolve(argv.spec);
|
const specPath = path.resolve(argv.spec);
|
||||||
|
|
||||||
interface systemdRunSPECOptions {
|
|
||||||
specConfig: string;
|
|
||||||
id: string;
|
|
||||||
runcpuOverride?: (old: RunCPUOptions) => RunCPUOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
function systemdRunSPEC({
|
function runspec(specConfig: string, id: string) {
|
||||||
specConfig,
|
|
||||||
id,
|
|
||||||
runcpuOverride,
|
|
||||||
}: systemdRunSPECOptions) {
|
|
||||||
const config = `${id}.cfg`;
|
const config = `${id}.cfg`;
|
||||||
|
|
||||||
const spec = mkSPEC(specPath);
|
const spec = mkSPEC(specPath);
|
||||||
|
|
||||||
spec.newConfig(config, specConfig);
|
spec.newConfig(config, specConfig);
|
||||||
|
|
||||||
return spawn('systemd-run', [
|
return spawn('runcpu', [
|
||||||
...systemdRunOptions({
|
...runcpuOptions({
|
||||||
scope: false,
|
|
||||||
unit: id,
|
|
||||||
user: true,
|
|
||||||
}),
|
|
||||||
'runcpu',
|
|
||||||
...runcpuOptions((runcpuOverride || (x => x))({
|
|
||||||
outputRoot: path.resolve(path.resolve(argv.output), id),
|
outputRoot: path.resolve(path.resolve(argv.output), id),
|
||||||
config,
|
config,
|
||||||
setprocgroup: true,
|
setprocgroup: true,
|
||||||
@@ -117,8 +100,8 @@ function systemdRunSPEC({
|
|||||||
buildType: argv.buildType as RunCPUOptions["buildType"],
|
buildType: argv.buildType as RunCPUOptions["buildType"],
|
||||||
benchmarks: argv.benchmarks as RunCPUOptions["benchmarks"],
|
benchmarks: argv.benchmarks as RunCPUOptions["benchmarks"],
|
||||||
action: argv.action as RunCPUOptions["action"],
|
action: argv.action as RunCPUOptions["action"],
|
||||||
})),
|
}),
|
||||||
], { env: spec.getEnvironment(), stdio: "inherit" });
|
], { env: spec.getEnvironment() });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to convert hash to prefix
|
// Function to convert hash to prefix
|
||||||
@@ -128,8 +111,6 @@ const uuid = crypto.randomUUID();
|
|||||||
|
|
||||||
const prefix = path.resolve(argv.compilerPrefix);
|
const prefix = path.resolve(argv.compilerPrefix);
|
||||||
|
|
||||||
console.log(prefix);
|
|
||||||
|
|
||||||
const o3LTOFlags = [
|
const o3LTOFlags = [
|
||||||
"-O3",
|
"-O3",
|
||||||
"-flto",
|
"-flto",
|
||||||
@@ -143,8 +124,11 @@ const unalignedFlags = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
// SPEC configuration
|
console.log(`Running SPEC compiled from ${prefix} as ${uuid}`);
|
||||||
const specConfig = renderConfig({
|
console.log(`View: ${path.resolve(argv.output, uuid)}`)
|
||||||
|
|
||||||
|
const specProc = runspec(
|
||||||
|
renderConfig({
|
||||||
prefix,
|
prefix,
|
||||||
optimize: [
|
optimize: [
|
||||||
"-O2",
|
"-O2",
|
||||||
@@ -157,15 +141,9 @@ const specConfig = renderConfig({
|
|||||||
],
|
],
|
||||||
sysroot,
|
sysroot,
|
||||||
compiler: argv.compilerSuite as ConfigOptions["compiler"],
|
compiler: argv.compilerSuite as ConfigOptions["compiler"],
|
||||||
});
|
}),
|
||||||
|
uuid
|
||||||
|
);
|
||||||
|
|
||||||
console.log(`Running SPEC compiled from ${prefix} as ${uuid}`);
|
const baseRatios = await getBaseRatios(specProc);
|
||||||
|
console.log(baseRatios);
|
||||||
await promisifySpawn(systemdRunSPEC({
|
|
||||||
specConfig,
|
|
||||||
id: uuid,
|
|
||||||
}));
|
|
||||||
|
|
||||||
console.log(`Command suggest:`);
|
|
||||||
console.log(chalk.green(`systemctl --user status ${uuid}`));
|
|
||||||
console.log(chalk.green(`journalctl --user -xeu ${uuid}`));
|
|
||||||
Reference in New Issue
Block a user