Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@ See [`example-configs/`](./example-configs/) for annotated templates (`evm.base.
| `rbeTlsClientCert` | string (optional) | TLS client certificate path, replaces the credential helper (`siso` only) |
| `rbeTlsClientKey` | string (optional) | Private key path for `rbeTlsClientCert` (`siso` only) |
| `rbePlatformProperties` | object (optional) | Remote platform properties, replaces the default backend config (`siso` only) |
| `rbeRemoteJobs` | integer (default: 200) | Maximum number of build steps to run remotely at once (`siso` only) |
| `preserveSDK` | integer (default: 5) | Number of recent macOS SDKs to keep on disk |
| `configValidationLevel` | `strict` \| `warn` \| `none` | How strictly to validate the config file (default: `strict`) |
| `extends` | string (optional) | Name of a base config to inherit from; arrays concatenate and objects deep-merge |
Expand Down Expand Up @@ -818,6 +819,8 @@ gen:
- Some backends reject outputs outside the working directory. Add
`clang_diagnostic_dir = "clang-crashreports"` to `gen.args` to keep the clang crash directory in
the output directory.
- Set `rbeRemoteJobs` to match the capacity of the backend. For a single build, pass the flag
instead: `e build -remote_jobs 500`.

## Environment variables

Expand Down
7 changes: 7 additions & 0 deletions evm-config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@
},
"description": "Remote platform properties, replacing the default backend config. siso only"
},
"rbeRemoteJobs": {
"type": "integer",
"minimum": 1,
"maximum": 9007199254740991,
"description": "Maximum number of build steps to run remotely at once. siso only",
"default": 200
},
"root": {
"type": "string",
"minLength": 1,
Expand Down
2 changes: 1 addition & 1 deletion src/e-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async function runNinja(
}

if (config.remoteBuild === 'siso') {
ninjaArgs.push(...siso.flags(config, hasExecute).map(String));
ninjaArgs.push(...siso.flags(config, hasExecute, ninjaArgs).map(String));
}
} else {
console.info(`${color.info} Building ${target} with remote execution disabled`);
Expand Down
7 changes: 7 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ const baseConfigShape = z.strictObject({
.record(z.string(), z.string())
.describe('Remote platform properties, replacing the default backend config. siso only')
.optional(),
rbeRemoteJobs: z
.number()
.int()
.min(1)
.describe('Maximum number of build steps to run remotely at once. siso only')
.meta({ default: 200 })
.optional(),
root: z
.string()
.min(1)
Expand Down
23 changes: 18 additions & 5 deletions src/utils/siso.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import type { SanitizedConfig } from '../types.js';
// scoped to); everything else uses the shared CI/local namespace.
const DEFAULT_REAPI_INSTANCE = 'projects/electron-rbe/instances/default_instance';

const DEFAULT_REMOTE_JOBS = 200;

type ConfigLike = Pick<
SanitizedConfig,
| 'remoteBuild'
Expand All @@ -19,6 +21,7 @@ type ConfigLike = Pick<
| 'rbeTlsClientCert'
| 'rbeTlsClientKey'
| 'rbePlatformProperties'
| 'rbeRemoteJobs'
| 'root'
>;

Expand Down Expand Up @@ -53,20 +56,30 @@ function getStarFile(envVar: string, filename: string): string {
return path.resolve(import.meta.dirname, '../../tools', filename);
}

export function flags(config: ConfigLike, hasExecute: boolean): (string | number)[] {
export function flags(
config: ConfigLike,
hasExecute: boolean,
userArgs: string[] = [],
): (string | number)[] {
if (config.remoteBuild !== 'siso') return [];

const result: (string | number)[] = [
'-remote_jobs',
200,
const result: (string | number)[] = [];

// These flags go after the user's and siso keeps the last value it sees, so
// leave -remote_jobs out when the user passed their own.
if (!userArgs.some((arg) => /^--?remote_jobs(=|$)/.test(arg.trim()))) {
result.push('-remote_jobs', config.rbeRemoteJobs ?? DEFAULT_REMOTE_JOBS);
}

result.push(
// Keep each value in its flag's token: the Windows shell join drops empty arguments.
`-project=${project(config)}`,
`-reapi_instance=${reapiInstance(config)}`,
'-reapi_address',
reclient.serviceAddress(config),
'-load',
getStarFile('ELECTRON_BUILD_TOOLS_MAIN_STAR', 'main.star'),
];
);

if (reclient.usesTlsClientAuth(config)) {
result.push(
Expand Down
27 changes: 27 additions & 0 deletions tests/siso.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,33 @@ describe('siso alternative RBE backends', () => {
});
});

describe('siso remote jobs', () => {
const remoteJobs = (result) => result[result.indexOf('-remote_jobs') + 1];

it('defaults to 200', () => {
expect(remoteJobs(flags({ remoteBuild: 'siso' }, true))).toBe(200);
});

it('uses rbeRemoteJobs when configured', () => {
expect(remoteJobs(flags({ remoteBuild: 'siso', rbeRemoteJobs: 500 }, true))).toBe(500);
});

it.each([
[['-remote_jobs', '50']],
[['-remote_jobs=50']],
[['--remote_jobs', '50']],
[['--remote_jobs=50']],
])('leaves the flag out when the user passes %j', (userArgs) => {
const result = flags({ remoteBuild: 'siso', rbeRemoteJobs: 500 }, true, userArgs);
expect(result).not.toContain('-remote_jobs');
});

it('is not fooled by other flags', () => {
const result = flags({ remoteBuild: 'siso' }, true, ['-local_jobs', '8', '-remote_jobs_foo=1']);
expect(remoteJobs(result)).toBe(200);
});
});

describe('ensureBackendStarlark', () => {
let root;
const backendStar = () => path.join(root, 'src/build/config/siso/backend_config/backend.star');
Expand Down
Loading