Only compare latest 20 checkpoints (#1034)

pull/1037/head
Asa Oines 2 years ago committed by GitHub
parent bbc65ff7a4
commit edbf197d51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      typescript/infra/src/agents/aws/validator.ts

@ -50,7 +50,7 @@ export class S3Validator extends BaseValidator {
this.s3Bucket = new S3Wrapper(s3Bucket);
}
async compare(other: S3Validator): Promise<CheckpointMetric[]> {
async compare(other: S3Validator, count = 20): Promise<CheckpointMetric[]> {
const latestCheckpointIndex = await this.s3Bucket.getS3Obj<number>(
LATEST_KEY,
);
@ -84,7 +84,9 @@ export class S3Validator extends BaseValidator {
};
}
for (; checkpointIndex > 0; checkpointIndex--) {
const stop = Math.max(maxIndex - count, 0);
for (; checkpointIndex > stop; checkpointIndex--) {
const expected = await other.getCheckpointReceipt(checkpointIndex);
const actual = await this.getCheckpointReceipt(checkpointIndex);
@ -118,7 +120,7 @@ export class S3Validator extends BaseValidator {
checkpointMetrics[checkpointIndex] = metric;
}
return checkpointMetrics;
return checkpointMetrics.slice(-1 * count);
}
private async getCheckpointReceipt(

Loading…
Cancel
Save