@forgezero/agent 0.1.113 → 0.1.115

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -572,6 +572,7 @@ function validateCapacityCalibrationOptions(options) {
572
572
  const endpoint = localCalibrationEndpoint(options.endpoint);
573
573
  const maxConcurrency = options.maxConcurrency ?? 256;
574
574
  const requestsPerWorker = options.requestsPerWorker ?? 8;
575
+ const maximumRequestsPerWorker = options.maximumRequestsPerWorker ?? 100;
575
576
  const maxP95Ms = options.maxP95Ms ?? 250;
576
577
  const maxErrorRate = options.maxErrorRate ?? 0.01;
577
578
  const safetyRatio = options.safetyRatio ?? 0.8;
@@ -579,13 +580,14 @@ function validateCapacityCalibrationOptions(options) {
579
580
  const minimumStageDurationMs = options.minimumStageDurationMs ?? 5000;
580
581
  const maxCpuUtilizationPercent = options.maxCpuUtilizationPercent ?? 90;
581
582
  const maxMemoryUtilizationPercent = options.maxMemoryUtilizationPercent ?? 90;
582
- if (!Number.isSafeInteger(maxConcurrency) || maxConcurrency < 1 || maxConcurrency > 4096 || !Number.isSafeInteger(requestsPerWorker) || requestsPerWorker < 2 || requestsPerWorker > 100 || !Number.isFinite(maxP95Ms) || maxP95Ms < 1 || !Number.isFinite(maxErrorRate) || maxErrorRate < 0 || maxErrorRate > 0.2 || !Number.isFinite(safetyRatio) || safetyRatio < 0.25 || safetyRatio > 0.95 || !Number.isSafeInteger(requestTimeoutMs) || requestTimeoutMs < 100 || requestTimeoutMs > 30000 || !Number.isSafeInteger(minimumStageDurationMs) || minimumStageDurationMs < 100 || minimumStageDurationMs > 60000 || !Number.isFinite(maxCpuUtilizationPercent) || maxCpuUtilizationPercent < 25 || maxCpuUtilizationPercent > 100 || !Number.isFinite(maxMemoryUtilizationPercent) || maxMemoryUtilizationPercent < 25 || maxMemoryUtilizationPercent > 100) {
583
+ if (!Number.isSafeInteger(maxConcurrency) || maxConcurrency < 1 || maxConcurrency > 4096 || !Number.isSafeInteger(requestsPerWorker) || requestsPerWorker < 2 || requestsPerWorker > 100 || !Number.isSafeInteger(maximumRequestsPerWorker) || maximumRequestsPerWorker < requestsPerWorker || maximumRequestsPerWorker > 100 || !Number.isFinite(maxP95Ms) || maxP95Ms < 1 || !Number.isFinite(maxErrorRate) || maxErrorRate < 0 || maxErrorRate > 0.2 || !Number.isFinite(safetyRatio) || safetyRatio < 0.25 || safetyRatio > 0.95 || !Number.isSafeInteger(requestTimeoutMs) || requestTimeoutMs < 100 || requestTimeoutMs > 30000 || !Number.isSafeInteger(minimumStageDurationMs) || minimumStageDurationMs < 100 || minimumStageDurationMs > 60000 || !Number.isFinite(maxCpuUtilizationPercent) || maxCpuUtilizationPercent < 25 || maxCpuUtilizationPercent > 100 || !Number.isFinite(maxMemoryUtilizationPercent) || maxMemoryUtilizationPercent < 25 || maxMemoryUtilizationPercent > 100) {
583
584
  throw new Error("Capacity calibration bounds are invalid.");
584
585
  }
585
586
  return {
586
587
  endpoint,
587
588
  maxConcurrency,
588
589
  requestsPerWorker,
590
+ maximumRequestsPerWorker,
589
591
  maxP95Ms,
590
592
  maxErrorRate,
591
593
  safetyRatio,
@@ -595,7 +597,7 @@ function validateCapacityCalibrationOptions(options) {
595
597
  maxMemoryUtilizationPercent
596
598
  };
597
599
  }
598
- async function stage(endpoint, concurrency, requestsPerWorker, timeoutMs, minimumDurationMs, fetcher, sampler) {
600
+ async function stage(endpoint, concurrency, requestsPerWorker, maximumRequestsPerWorker, timeoutMs, minimumDurationMs, fetcher, sampler) {
599
601
  const latencies = [];
600
602
  let succeeded = 0;
601
603
  let failed = 0;
@@ -604,7 +606,7 @@ async function stage(endpoint, concurrency, requestsPerWorker, timeoutMs, minimu
604
606
  const started = performance.now();
605
607
  await Promise.all(Array.from({ length: concurrency }, async () => {
606
608
  let request = 0;
607
- while (request < requestsPerWorker || performance.now() - started < minimumDurationMs) {
609
+ while (request < maximumRequestsPerWorker && (request < requestsPerWorker || performance.now() - started < minimumDurationMs)) {
608
610
  request += 1;
609
611
  const requestStarted = performance.now();
610
612
  try {
@@ -663,6 +665,7 @@ async function calibrateHttpConcurrency(options, fetcher = fetch, sampler = host
663
665
  safetyRatio,
664
666
  requestTimeoutMs: timeoutMs,
665
667
  minimumStageDurationMs,
668
+ maximumRequestsPerWorker,
666
669
  maxCpuUtilizationPercent,
667
670
  maxMemoryUtilizationPercent
668
671
  } = validateCapacityCalibrationOptions(options);
@@ -670,7 +673,7 @@ async function calibrateHttpConcurrency(options, fetcher = fetch, sampler = host
670
673
  let lastSafe;
671
674
  let stopReason = "maximum-tested";
672
675
  for (let concurrency = 1;; concurrency = Math.min(maxConcurrency, concurrency * 2)) {
673
- const measured = await stage(endpoint, concurrency, requestsPerWorker, timeoutMs, minimumStageDurationMs, fetcher, sampler);
676
+ const measured = await stage(endpoint, concurrency, requestsPerWorker, maximumRequestsPerWorker, timeoutMs, minimumStageDurationMs, fetcher, sampler);
674
677
  stages.push(measured);
675
678
  const previous = stages.at(-2);
676
679
  const throughputRegressed = Boolean(previous && concurrency > 1 && measured.successfulRequestsPerSecond < previous.successfulRequestsPerSecond * 0.9);
@@ -771,6 +774,7 @@ function capacityCalibration(value, where) {
771
774
  "endpoint",
772
775
  "maxConcurrency",
773
776
  "requestsPerWorker",
777
+ "maximumRequestsPerWorker",
774
778
  "maxP95Ms",
775
779
  "maxErrorRate",
776
780
  "safetyRatio",
@@ -799,6 +803,7 @@ function capacityCalibration(value, where) {
799
803
  ...Object.fromEntries([
800
804
  "maxConcurrency",
801
805
  "requestsPerWorker",
806
+ "maximumRequestsPerWorker",
802
807
  "maxP95Ms",
803
808
  "maxErrorRate",
804
809
  "safetyRatio",
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  /** One package version shared by both public binaries. Pinned to package.json by tests. */
2
- export declare const VERSION = "0.1.113";
2
+ export declare const VERSION = "0.1.115";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forgezero/agent",
3
- "version": "0.1.113",
3
+ "version": "0.1.115",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "check": "tsc --noEmit",