perf(strategy): fuse validated state copying and freezing (P08)
This commit is contained in:
parent
dbb6f4f5d1
commit
70d173a908
6 changed files with 6016 additions and 9 deletions
|
|
@ -7,6 +7,7 @@
|
|||
* bun run scripts/benchmark-research.ts --session --measure # 1k/10k bars, actual TS decisions
|
||||
* bun run scripts/benchmark-research.ts --session --measure --profile=sparse --bars=10000
|
||||
* bun run scripts/benchmark-research.ts --session --measure --profile=all --format=both --bars=10000
|
||||
* bun run scripts/benchmark-research.ts --sma --measure # SMA vs exact recorded decisions
|
||||
* Build workspace libraries/config and the local engine first. JSON stdout; diagnostics stderr.
|
||||
*/
|
||||
import { createHash } from 'node:crypto';
|
||||
|
|
@ -254,7 +255,7 @@ function command(args: string[]): string {
|
|||
return result.stdout.toString().trimEnd();
|
||||
}
|
||||
|
||||
function identity() {
|
||||
export function identity() {
|
||||
const paths = command(['git', 'ls-files', '--cached', '--others', '--exclude-standard', '-z'])
|
||||
.split('\0')
|
||||
.filter(Boolean)
|
||||
|
|
@ -342,6 +343,7 @@ export function verifyRepeats(
|
|||
export function parseBenchmarkArguments(args: string[]) {
|
||||
const options = {
|
||||
session: false,
|
||||
sma: false,
|
||||
measured: false,
|
||||
large: false,
|
||||
selfTest: false,
|
||||
|
|
@ -357,6 +359,9 @@ export function parseBenchmarkArguments(args: string[]) {
|
|||
}
|
||||
seen.add(flag);
|
||||
switch (flag) {
|
||||
case '--sma':
|
||||
options.sma = true;
|
||||
break;
|
||||
case '--session':
|
||||
options.session = true;
|
||||
break;
|
||||
|
|
@ -406,10 +411,19 @@ export function parseBenchmarkArguments(args: string[]) {
|
|||
if (options.totalBars !== undefined && (!options.measured || options.large)) {
|
||||
throw new Error('--bars requires --measure and cannot be combined with --large');
|
||||
}
|
||||
if (options.sma && (options.session || options.large || ['--profile', '--format', '--bars'].some(flag => seen.has(flag)))) {
|
||||
throw new Error('--sma supports only --measure or --self-test');
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
async function main(args: string[]) {
|
||||
if (args[0] === '--sma-child') {
|
||||
const { smaChild } = await import('./benchmark-sma');
|
||||
const { workload, mode } = JSON.parse(args[1] ?? '');
|
||||
process.stdout.write(JSON.stringify(await smaChild(root, workload, mode)) + '\n');
|
||||
return;
|
||||
}
|
||||
if (args[0] === '--session-child') {
|
||||
const { sessionChild } = await import('./benchmark-replay');
|
||||
process.stdout.write(JSON.stringify(await sessionChild(JSON.parse(args[1] ?? ''))) + '\n');
|
||||
|
|
@ -422,6 +436,11 @@ async function main(args: string[]) {
|
|||
const selection = parseBenchmarkArguments(args);
|
||||
const metadata = identity(); // Excluded from workload timings.
|
||||
const measured = selection.measured;
|
||||
if (selection.sma) {
|
||||
const { smaBenchmark } = await import('./benchmark-sma');
|
||||
await smaBenchmark(root, fileURLToPath(import.meta.url), metadata, measured);
|
||||
return;
|
||||
}
|
||||
if (selection.session) {
|
||||
const { sessionBenchmark } = await import('./benchmark-replay');
|
||||
await sessionBenchmark(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue