Skip to content

Commit 1b4ab4b

Browse files
committed
Remove STOP_AFTER env variable from performance regression framework
1 parent fc0ec8f commit 1b4ab4b

File tree

2 files changed

+57
-93
lines changed

2 files changed

+57
-93
lines changed

src/lib/testing/perf-regression.ts

Lines changed: 52 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,6 @@ if (DUMP) {
8585
if (!fs.existsSync(FILE_PATH)) fs.writeFileSync(FILE_PATH, '{}', 'utf8');
8686
}
8787

88-
// Stops the process after the N-th end() call, if STOP_AFTER env is set.
89-
// If STOP_AFTER is not set or invalid, the script runs through normally.
90-
const STOP_AFTER = Number.isFinite(Number(process.env.STOP_AFTER ?? ''))
91-
? Number(process.env.STOP_AFTER)
92-
: undefined;
93-
9488
/**
9589
* Create a new performance tracking session for a program.
9690
*
@@ -106,19 +100,8 @@ function createPerformanceSession(
106100
log = true
107101
) {
108102
const perfStack: PerfStack[] = [];
109-
let endCounter = 0;
110-
111103
const shouldLog = SILENT ? false : log;
112104

113-
function maybeStop() {
114-
if (STOP_AFTER && STOP_AFTER > 0) {
115-
endCounter++;
116-
if (endCounter >= STOP_AFTER) {
117-
process.exit(0);
118-
}
119-
}
120-
}
121-
122105
return {
123106
/**
124107
* Start measuring performance for a given phase.
@@ -160,17 +143,11 @@ function createPerformanceSession(
160143
);
161144
}
162145

163-
// If neither --dump nor --check, just optionally log and honor STOP_AFTER
164-
if (!DUMP && !CHECK) {
165-
maybeStop();
166-
return;
167-
}
146+
// If neither --dump nor --check, just optionally log
147+
if (!DUMP && !CHECK) return;
168148

169149
// Only act for compile/prove with required context
170-
if (!programName || (label !== 'compile' && label !== 'prove')) {
171-
maybeStop();
172-
return;
173-
}
150+
if (!programName || (label !== 'compile' && label !== 'prove')) return;
174151

175152
// Load the baseline JSON used for both DUMP and CHECK modes.
176153
// - In DUMP mode: merge new data with existing entries so multiple methods remain grouped.
@@ -189,7 +166,6 @@ function createPerformanceSession(
189166
digest: '',
190167
actualTime: time,
191168
});
192-
maybeStop();
193169
return;
194170
}
195171

@@ -202,77 +178,64 @@ function createPerformanceSession(
202178

203179
perfRegressionJson[programName] = merged;
204180
fs.writeFileSync(FILE_PATH, JSON.stringify(perfRegressionJson, null, 2));
205-
maybeStop();
206181
return;
207182
}
208183
}
209184

210-
// For prove we need the analyzed methods and a valid methodName
211-
if (!cs) {
212-
maybeStop();
213-
return;
214-
}
185+
if (label === 'prove') {
186+
// For prove we need the analyzed methods and a valid methodName
187+
if (!cs) return;
215188

216-
const csMethodNames = Object.keys(cs);
217-
if (csMethodNames.length === 0) {
218-
maybeStop();
219-
return;
220-
}
189+
const csMethodNames = Object.keys(cs);
190+
if (csMethodNames.length === 0) return;
221191

222-
if (!methodName) {
223-
throw new Error(
224-
'Please provide the method name you are proving (pass it to start(..., methodName)).'
225-
);
226-
}
192+
if (!methodName) {
193+
throw new Error(
194+
'Please provide the method name you are proving (pass it to start(..., methodName)).'
195+
);
196+
}
227197

228-
if (!Object.prototype.hasOwnProperty.call(cs, methodName)) {
229-
throw new Error(
230-
`The method "${methodName}" does not exist in the analyzed constraint systems for "${programName}". ` +
231-
`Available: ${csMethodNames.join(', ')}`
232-
);
233-
}
198+
if (!Object.prototype.hasOwnProperty.call(cs, methodName)) {
199+
throw new Error(
200+
`The method "${methodName}" does not exist in the analyzed constraint system for "${programName}". ` +
201+
`Available: ${csMethodNames.join(', ')}`
202+
);
203+
}
234204

235-
const info = cs[methodName];
236-
if (!info) {
237-
maybeStop();
238-
return;
239-
}
205+
const info = cs[methodName];
206+
if (!info) return;
240207

241-
// CHECK: validate only, no writes
242-
if (CHECK) {
243-
checkAgainstBaseline({
244-
perfRegressionJson,
245-
programName,
246-
label: 'prove',
247-
methodName,
248-
digest: info.digest,
249-
actualTime: time,
250-
});
251-
maybeStop();
252-
return;
253-
}
208+
// CHECK: validate only, no writes
209+
if (CHECK) {
210+
checkAgainstBaseline({
211+
perfRegressionJson,
212+
programName,
213+
label: 'prove',
214+
methodName,
215+
digest: info.digest,
216+
actualTime: time,
217+
});
218+
return;
219+
}
254220

255-
// DUMP: update per-method rows/digest and proveTime; leave compileTime untouched
256-
if (DUMP) {
257-
const prev = perfRegressionJson[programName];
258-
const merged: PerfRegressionEntry = prev
259-
? { ...prev, methods: { ...prev.methods } }
260-
: { methods: {} };
261-
262-
merged.methods[methodName] = {
263-
rows: info.rows,
264-
digest: info.digest,
265-
proveTime: time,
266-
};
267-
268-
perfRegressionJson[programName] = merged;
269-
fs.writeFileSync(FILE_PATH, JSON.stringify(perfRegressionJson, null, 2));
270-
maybeStop();
271-
return;
272-
}
221+
// DUMP: update per-method rows/digest and proveTime; leave compileTime untouched
222+
if (DUMP) {
223+
const prev = perfRegressionJson[programName];
224+
const merged: PerfRegressionEntry = prev
225+
? { ...prev, methods: { ...prev.methods } }
226+
: { methods: {} };
273227

274-
// Fallback
275-
maybeStop();
228+
merged.methods[methodName] = {
229+
rows: info.rows,
230+
digest: info.digest,
231+
proveTime: time,
232+
};
233+
234+
perfRegressionJson[programName] = merged;
235+
fs.writeFileSync(FILE_PATH, JSON.stringify(perfRegressionJson, null, 2));
236+
return;
237+
}
238+
}
276239
},
277240
};
278241
}
@@ -294,7 +257,8 @@ const Performance = {
294257
* - When set to `false`, disables all console output for both general labels
295258
* and compile/prove phase logs.
296259
* - When the `--silent` flag is provided, it overrides this setting and disables
297-
* all logging regardless of the `log` value. */
260+
* all logging regardless of the `log` value.
261+
*/
298262
create(
299263
programName?: string,
300264
methodsSummary?: Record<string, ConstraintSystemSummary>,

tests/perf-regression/perf-regression.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ fi
99

1010
MODE=$1
1111

12-
# Run ZkProgram performance regression tests with STOP_AFTER controls
13-
STOP_AFTER=2 ./run src/examples/crypto/sha256/run.ts --bundle "$MODE"
14-
STOP_AFTER=4 ./run src/examples/crypto/ecdsa/run.ts --bundle "$MODE"
15-
STOP_AFTER=2 ./run src/examples/crypto/blake2b/run.ts --bundle "$MODE"
16-
STOP_AFTER=2 ./run src/examples/crypto/rsa/run.ts --bundle "$MODE"
12+
# Run ZkProgram performance regression tests
13+
./run src/examples/crypto/sha256/run.ts --bundle "$MODE"
14+
./run src/examples/crypto/ecdsa/run.ts --bundle "$MODE"
15+
./run src/examples/crypto/blake2b/run.ts --bundle "$MODE"
16+
./run src/examples/crypto/rsa/run.ts --bundle "$MODE"
1717

1818
# Run CS + zkApps performance regression tests
1919
./run tests/perf-regression/perf-regression.ts --bundle "$MODE"

0 commit comments

Comments
 (0)