ppef 1.0.0 → 1.1.0
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.
- package/README.md +172 -0
- package/bin/ppef.mjs +20 -0
- package/dist/__tests__/framework-pipeline.integration.test.d.ts +7 -0
- package/dist/__tests__/framework-pipeline.integration.test.d.ts.map +1 -0
- package/dist/__tests__/framework-pipeline.integration.test.js +415 -0
- package/dist/__tests__/framework-pipeline.integration.test.js.map +1 -0
- package/dist/__tests__/index-exports.unit.test.d.ts +8 -0
- package/dist/__tests__/index-exports.unit.test.d.ts.map +1 -0
- package/dist/__tests__/index-exports.unit.test.js +127 -0
- package/dist/__tests__/index-exports.unit.test.js.map +1 -0
- package/dist/__tests__/registry-executor.integration.test.d.ts +5 -0
- package/dist/__tests__/registry-executor.integration.test.d.ts.map +1 -0
- package/dist/__tests__/registry-executor.integration.test.js +352 -0
- package/dist/__tests__/registry-executor.integration.test.js.map +1 -0
- package/dist/__tests__/test-helpers.d.ts +94 -0
- package/dist/__tests__/test-helpers.d.ts.map +1 -0
- package/dist/__tests__/test-helpers.js +271 -0
- package/dist/__tests__/test-helpers.js.map +1 -0
- package/dist/aggregation/__tests__/aggregators.unit.test.d.ts +7 -0
- package/dist/aggregation/__tests__/aggregators.unit.test.d.ts.map +1 -0
- package/dist/aggregation/__tests__/aggregators.unit.test.js +350 -0
- package/dist/aggregation/__tests__/aggregators.unit.test.js.map +1 -0
- package/dist/aggregation/__tests__/pipeline.unit.test.d.ts +7 -0
- package/dist/aggregation/__tests__/pipeline.unit.test.d.ts.map +1 -0
- package/dist/aggregation/__tests__/pipeline.unit.test.js +213 -0
- package/dist/aggregation/__tests__/pipeline.unit.test.js.map +1 -0
- package/dist/aggregation/aggregators.d.ts +63 -0
- package/dist/aggregation/aggregators.d.ts.map +1 -0
- package/dist/aggregation/aggregators.js +228 -0
- package/dist/aggregation/aggregators.js.map +1 -0
- package/dist/aggregation/index.d.ts +8 -0
- package/dist/aggregation/index.d.ts.map +1 -0
- package/dist/aggregation/index.js +8 -0
- package/dist/aggregation/index.js.map +1 -0
- package/dist/aggregation/pipeline.d.ts +38 -0
- package/dist/aggregation/pipeline.d.ts.map +1 -0
- package/dist/aggregation/pipeline.js +198 -0
- package/dist/aggregation/pipeline.js.map +1 -0
- package/dist/claims/__tests__/evaluator.unit.test.d.ts +12 -0
- package/dist/claims/__tests__/evaluator.unit.test.d.ts.map +1 -0
- package/dist/claims/__tests__/evaluator.unit.test.js +801 -0
- package/dist/claims/__tests__/evaluator.unit.test.js.map +1 -0
- package/dist/claims/evaluator.d.ts +33 -0
- package/dist/claims/evaluator.d.ts.map +1 -0
- package/dist/claims/evaluator.js +174 -0
- package/dist/claims/evaluator.js.map +1 -0
- package/dist/claims/index.d.ts +7 -0
- package/dist/claims/index.d.ts.map +1 -0
- package/dist/claims/index.js +7 -0
- package/dist/claims/index.js.map +1 -0
- package/dist/cli/__tests__/aggregate.command.unit.test.d.ts +7 -0
- package/dist/cli/__tests__/aggregate.command.unit.test.d.ts.map +1 -0
- package/dist/cli/__tests__/aggregate.command.unit.test.js +396 -0
- package/dist/cli/__tests__/aggregate.command.unit.test.js.map +1 -0
- package/dist/cli/__tests__/commands.unit.test.d.ts +10 -0
- package/dist/cli/__tests__/commands.unit.test.d.ts.map +1 -0
- package/dist/cli/__tests__/commands.unit.test.js +217 -0
- package/dist/cli/__tests__/commands.unit.test.js.map +1 -0
- package/dist/cli/__tests__/index.unit.test.d.ts +10 -0
- package/dist/cli/__tests__/index.unit.test.d.ts.map +1 -0
- package/dist/cli/__tests__/index.unit.test.js +65 -0
- package/dist/cli/__tests__/index.unit.test.js.map +1 -0
- package/dist/cli/__tests__/logger.unit.test.d.ts +11 -0
- package/dist/cli/__tests__/logger.unit.test.d.ts.map +1 -0
- package/dist/cli/__tests__/logger.unit.test.js +180 -0
- package/dist/cli/__tests__/logger.unit.test.js.map +1 -0
- package/dist/cli/__tests__/module-loader.unit.test.d.ts +11 -0
- package/dist/cli/__tests__/module-loader.unit.test.d.ts.map +1 -0
- package/dist/cli/__tests__/module-loader.unit.test.js +262 -0
- package/dist/cli/__tests__/module-loader.unit.test.js.map +1 -0
- package/dist/cli/__tests__/output-writer.unit.test.d.ts +10 -0
- package/dist/cli/__tests__/output-writer.unit.test.d.ts.map +1 -0
- package/dist/cli/__tests__/output-writer.unit.test.js +216 -0
- package/dist/cli/__tests__/output-writer.unit.test.js.map +1 -0
- package/dist/cli/__tests__/plan.command.unit.test.d.ts +7 -0
- package/dist/cli/__tests__/plan.command.unit.test.d.ts.map +1 -0
- package/dist/cli/__tests__/plan.command.unit.test.js +289 -0
- package/dist/cli/__tests__/plan.command.unit.test.js.map +1 -0
- package/dist/cli/__tests__/run.command.unit.test.d.ts +7 -0
- package/dist/cli/__tests__/run.command.unit.test.d.ts.map +1 -0
- package/dist/cli/__tests__/run.command.unit.test.js +422 -0
- package/dist/cli/__tests__/run.command.unit.test.js.map +1 -0
- package/dist/cli/__tests__/validate.command.unit.test.d.ts +7 -0
- package/dist/cli/__tests__/validate.command.unit.test.d.ts.map +1 -0
- package/dist/cli/__tests__/validate.command.unit.test.js +226 -0
- package/dist/cli/__tests__/validate.command.unit.test.js.map +1 -0
- package/dist/cli/command-deps.d.ts +125 -0
- package/dist/cli/command-deps.d.ts.map +1 -0
- package/dist/cli/command-deps.js +7 -0
- package/dist/cli/command-deps.js.map +1 -0
- package/dist/cli/commands/aggregate.d.ts +35 -0
- package/dist/cli/commands/aggregate.d.ts.map +1 -0
- package/dist/cli/commands/aggregate.js +121 -0
- package/dist/cli/commands/aggregate.js.map +1 -0
- package/dist/cli/commands/plan.d.ts +36 -0
- package/dist/cli/commands/plan.d.ts.map +1 -0
- package/dist/cli/commands/plan.js +109 -0
- package/dist/cli/commands/plan.js.map +1 -0
- package/dist/cli/commands/run.d.ts +33 -0
- package/dist/cli/commands/run.d.ts.map +1 -0
- package/dist/cli/commands/run.js +185 -0
- package/dist/cli/commands/run.js.map +1 -0
- package/dist/cli/commands/validate.d.ts +27 -0
- package/dist/cli/commands/validate.d.ts.map +1 -0
- package/dist/cli/commands/validate.js +88 -0
- package/dist/cli/commands/validate.js.map +1 -0
- package/dist/cli/config-loader.d.ts +30 -0
- package/dist/cli/config-loader.d.ts.map +1 -0
- package/dist/cli/config-loader.js +181 -0
- package/dist/cli/config-loader.js.map +1 -0
- package/dist/cli/index.d.ts +26 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +58 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/logger.d.ts +75 -0
- package/dist/cli/logger.d.ts.map +1 -0
- package/dist/cli/logger.js +131 -0
- package/dist/cli/logger.js.map +1 -0
- package/dist/cli/module-loader.d.ts +46 -0
- package/dist/cli/module-loader.d.ts.map +1 -0
- package/dist/cli/module-loader.js +116 -0
- package/dist/cli/module-loader.js.map +1 -0
- package/dist/cli/output-writer.d.ts +51 -0
- package/dist/cli/output-writer.d.ts.map +1 -0
- package/dist/cli/output-writer.js +65 -0
- package/dist/cli/output-writer.js.map +1 -0
- package/dist/cli/types.d.ts +174 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +7 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/collector/__tests__/result-collector.unit.test.d.ts +7 -0
- package/dist/collector/__tests__/result-collector.unit.test.d.ts.map +1 -0
- package/dist/collector/__tests__/result-collector.unit.test.js +1021 -0
- package/dist/collector/__tests__/result-collector.unit.test.js.map +1 -0
- package/dist/collector/__tests__/schema.unit.test.d.ts +7 -0
- package/dist/collector/__tests__/schema.unit.test.d.ts.map +1 -0
- package/dist/collector/__tests__/schema.unit.test.js +360 -0
- package/dist/collector/__tests__/schema.unit.test.js.map +1 -0
- package/dist/collector/index.d.ts +8 -0
- package/dist/collector/index.d.ts.map +1 -0
- package/dist/collector/index.js +8 -0
- package/dist/collector/index.js.map +1 -0
- package/dist/collector/result-collector.d.ts +159 -0
- package/dist/collector/result-collector.d.ts.map +1 -0
- package/dist/collector/result-collector.js +213 -0
- package/dist/collector/result-collector.js.map +1 -0
- package/dist/collector/schema.d.ts +34 -0
- package/dist/collector/schema.d.ts.map +1 -0
- package/dist/collector/schema.js +145 -0
- package/dist/collector/schema.js.map +1 -0
- package/dist/executor/__tests__/checkpoint-hash-bug.diagnostic.test.d.ts +10 -0
- package/dist/executor/__tests__/checkpoint-hash-bug.diagnostic.test.d.ts.map +1 -0
- package/dist/executor/__tests__/checkpoint-hash-bug.diagnostic.test.js +122 -0
- package/dist/executor/__tests__/checkpoint-hash-bug.diagnostic.test.js.map +1 -0
- package/dist/executor/__tests__/checkpoint-manager.integration.test.d.ts +7 -0
- package/dist/executor/__tests__/checkpoint-manager.integration.test.d.ts.map +1 -0
- package/dist/executor/__tests__/checkpoint-manager.integration.test.js +330 -0
- package/dist/executor/__tests__/checkpoint-manager.integration.test.js.map +1 -0
- package/dist/executor/__tests__/checkpoint-manager.unit.test.d.ts +7 -0
- package/dist/executor/__tests__/checkpoint-manager.unit.test.d.ts.map +1 -0
- package/dist/executor/__tests__/checkpoint-manager.unit.test.js +531 -0
- package/dist/executor/__tests__/checkpoint-manager.unit.test.js.map +1 -0
- package/dist/executor/__tests__/checkpoint-merge-bug.diagnostic.test.d.ts +8 -0
- package/dist/executor/__tests__/checkpoint-merge-bug.diagnostic.test.d.ts.map +1 -0
- package/dist/executor/__tests__/checkpoint-merge-bug.diagnostic.test.js +493 -0
- package/dist/executor/__tests__/checkpoint-merge-bug.diagnostic.test.js.map +1 -0
- package/dist/executor/__tests__/checkpoint-merge-bug.unit.test.d.ts +8 -0
- package/dist/executor/__tests__/checkpoint-merge-bug.unit.test.d.ts.map +1 -0
- package/dist/executor/__tests__/checkpoint-merge-bug.unit.test.js +164 -0
- package/dist/executor/__tests__/checkpoint-merge-bug.unit.test.js.map +1 -0
- package/dist/executor/__tests__/checkpoint-storage.unit.test.d.ts +7 -0
- package/dist/executor/__tests__/checkpoint-storage.unit.test.d.ts.map +1 -0
- package/dist/executor/__tests__/checkpoint-storage.unit.test.js +490 -0
- package/dist/executor/__tests__/checkpoint-storage.unit.test.js.map +1 -0
- package/dist/executor/__tests__/executor.unit.test.d.ts +7 -0
- package/dist/executor/__tests__/executor.unit.test.d.ts.map +1 -0
- package/dist/executor/__tests__/executor.unit.test.js +202 -0
- package/dist/executor/__tests__/executor.unit.test.js.map +1 -0
- package/dist/executor/__tests__/memory-monitor.unit.test.d.ts +7 -0
- package/dist/executor/__tests__/memory-monitor.unit.test.d.ts.map +1 -0
- package/dist/executor/__tests__/memory-monitor.unit.test.js +285 -0
- package/dist/executor/__tests__/memory-monitor.unit.test.js.map +1 -0
- package/dist/executor/__tests__/parallel-checkpoint-merge.integration.test.d.ts +12 -0
- package/dist/executor/__tests__/parallel-checkpoint-merge.integration.test.d.ts.map +1 -0
- package/dist/executor/__tests__/parallel-checkpoint-merge.integration.test.js +196 -0
- package/dist/executor/__tests__/parallel-checkpoint-merge.integration.test.js.map +1 -0
- package/dist/executor/__tests__/parallel-executor.integration.test.d.ts +7 -0
- package/dist/executor/__tests__/parallel-executor.integration.test.d.ts.map +1 -0
- package/dist/executor/__tests__/parallel-executor.integration.test.js +249 -0
- package/dist/executor/__tests__/parallel-executor.integration.test.js.map +1 -0
- package/dist/executor/__tests__/parallel-executor.unit.test.d.ts +8 -0
- package/dist/executor/__tests__/parallel-executor.unit.test.d.ts.map +1 -0
- package/dist/executor/__tests__/parallel-executor.unit.test.js +473 -0
- package/dist/executor/__tests__/parallel-executor.unit.test.js.map +1 -0
- package/dist/executor/__tests__/run-id.unit.test.d.ts +8 -0
- package/dist/executor/__tests__/run-id.unit.test.d.ts.map +1 -0
- package/dist/executor/__tests__/run-id.unit.test.js +156 -0
- package/dist/executor/__tests__/run-id.unit.test.js.map +1 -0
- package/dist/executor/__tests__/worker-entry.integration.test.d.ts +24 -0
- package/dist/executor/__tests__/worker-entry.integration.test.d.ts.map +1 -0
- package/dist/executor/__tests__/worker-entry.integration.test.js +82 -0
- package/dist/executor/__tests__/worker-entry.integration.test.js.map +1 -0
- package/dist/executor/__tests__/worker-entry.unit.test.d.ts +7 -0
- package/dist/executor/__tests__/worker-entry.unit.test.d.ts.map +1 -0
- package/dist/executor/__tests__/worker-entry.unit.test.js +364 -0
- package/dist/executor/__tests__/worker-entry.unit.test.js.map +1 -0
- package/dist/executor/checkpoint-manager.d.ts +231 -0
- package/dist/executor/checkpoint-manager.d.ts.map +1 -0
- package/dist/executor/checkpoint-manager.js +395 -0
- package/dist/executor/checkpoint-manager.js.map +1 -0
- package/dist/executor/checkpoint-storage.d.ts +230 -0
- package/dist/executor/checkpoint-storage.d.ts.map +1 -0
- package/dist/executor/checkpoint-storage.js +370 -0
- package/dist/executor/checkpoint-storage.js.map +1 -0
- package/dist/executor/checkpoint-types.d.ts +48 -0
- package/dist/executor/checkpoint-types.d.ts.map +1 -0
- package/dist/executor/checkpoint-types.js +8 -0
- package/dist/executor/checkpoint-types.js.map +1 -0
- package/dist/executor/executor.d.ts +164 -0
- package/dist/executor/executor.d.ts.map +1 -0
- package/dist/executor/executor.js +408 -0
- package/dist/executor/executor.js.map +1 -0
- package/dist/executor/index.d.ts +11 -0
- package/dist/executor/index.d.ts.map +1 -0
- package/dist/executor/index.js +11 -0
- package/dist/executor/index.js.map +1 -0
- package/dist/executor/memory-monitor.d.ts +115 -0
- package/dist/executor/memory-monitor.d.ts.map +1 -0
- package/dist/executor/memory-monitor.js +168 -0
- package/dist/executor/memory-monitor.js.map +1 -0
- package/dist/executor/parallel-executor.d.ts +239 -0
- package/dist/executor/parallel-executor.d.ts.map +1 -0
- package/dist/executor/parallel-executor.js +329 -0
- package/dist/executor/parallel-executor.js.map +1 -0
- package/dist/executor/run-id.d.ts +71 -0
- package/dist/executor/run-id.d.ts.map +1 -0
- package/dist/executor/run-id.js +74 -0
- package/dist/executor/run-id.js.map +1 -0
- package/dist/executor/worker-entry.d.ts +10 -0
- package/dist/executor/worker-entry.d.ts.map +1 -0
- package/dist/executor/worker-entry.js +42 -0
- package/dist/executor/worker-entry.js.map +1 -0
- package/dist/executor/worker-executor.d.ts +156 -0
- package/dist/executor/worker-executor.d.ts.map +1 -0
- package/dist/executor/worker-executor.js +88 -0
- package/dist/executor/worker-executor.js.map +1 -0
- package/dist/index.cjs +11 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/registry/case-registry.d.ts +113 -0
- package/dist/registry/case-registry.d.ts.map +1 -0
- package/dist/registry/case-registry.js +160 -0
- package/dist/registry/case-registry.js.map +1 -0
- package/dist/registry/index.d.ts +8 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +8 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/registry/sut-registry.d.ts +96 -0
- package/dist/registry/sut-registry.d.ts.map +1 -0
- package/dist/registry/sut-registry.js +126 -0
- package/dist/registry/sut-registry.js.map +1 -0
- package/dist/renderers/index.d.ts +10 -0
- package/dist/renderers/index.d.ts.map +1 -0
- package/dist/renderers/index.js +9 -0
- package/dist/renderers/index.js.map +1 -0
- package/dist/renderers/latex-renderer.d.ts +84 -0
- package/dist/renderers/latex-renderer.d.ts.map +1 -0
- package/dist/renderers/latex-renderer.js +208 -0
- package/dist/renderers/latex-renderer.js.map +1 -0
- package/dist/renderers/types.d.ts +106 -0
- package/dist/renderers/types.d.ts.map +1 -0
- package/dist/renderers/types.js +23 -0
- package/dist/renderers/types.js.map +1 -0
- package/dist/robustness/__tests__/analyzer.unit.test.d.ts +11 -0
- package/dist/robustness/__tests__/analyzer.unit.test.d.ts.map +1 -0
- package/dist/robustness/__tests__/analyzer.unit.test.js +455 -0
- package/dist/robustness/__tests__/analyzer.unit.test.js.map +1 -0
- package/dist/robustness/__tests__/perturbations.unit.test.d.ts +11 -0
- package/dist/robustness/__tests__/perturbations.unit.test.d.ts.map +1 -0
- package/dist/robustness/__tests__/perturbations.unit.test.js +284 -0
- package/dist/robustness/__tests__/perturbations.unit.test.js.map +1 -0
- package/dist/robustness/analyzer.d.ts +61 -0
- package/dist/robustness/analyzer.d.ts.map +1 -0
- package/dist/robustness/analyzer.js +191 -0
- package/dist/robustness/analyzer.js.map +1 -0
- package/dist/robustness/index.d.ts +8 -0
- package/dist/robustness/index.d.ts.map +1 -0
- package/dist/robustness/index.js +8 -0
- package/dist/robustness/index.js.map +1 -0
- package/dist/robustness/perturbations.d.ts +46 -0
- package/dist/robustness/perturbations.d.ts.map +1 -0
- package/dist/robustness/perturbations.js +184 -0
- package/dist/robustness/perturbations.js.map +1 -0
- package/dist/statistical/__tests__/mann-whitney-u.unit.test.d.ts +7 -0
- package/dist/statistical/__tests__/mann-whitney-u.unit.test.d.ts.map +1 -0
- package/dist/statistical/__tests__/mann-whitney-u.unit.test.js +185 -0
- package/dist/statistical/__tests__/mann-whitney-u.unit.test.js.map +1 -0
- package/dist/statistical/index.d.ts +8 -0
- package/dist/statistical/index.d.ts.map +1 -0
- package/dist/statistical/index.js +8 -0
- package/dist/statistical/index.js.map +1 -0
- package/dist/statistical/mann-whitney-u.d.ts +62 -0
- package/dist/statistical/mann-whitney-u.d.ts.map +1 -0
- package/dist/statistical/mann-whitney-u.js +127 -0
- package/dist/statistical/mann-whitney-u.js.map +1 -0
- package/dist/types/aggregate.d.ts +124 -0
- package/dist/types/aggregate.d.ts.map +1 -0
- package/dist/types/aggregate.js +9 -0
- package/dist/types/aggregate.js.map +1 -0
- package/dist/types/case.d.ts +105 -0
- package/dist/types/case.d.ts.map +1 -0
- package/dist/types/case.js +10 -0
- package/dist/types/case.js.map +1 -0
- package/dist/types/claims.d.ts +122 -0
- package/dist/types/claims.d.ts.map +1 -0
- package/dist/types/claims.js +14 -0
- package/dist/types/claims.js.map +1 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +7 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/perturbation.d.ts +105 -0
- package/dist/types/perturbation.d.ts.map +1 -0
- package/dist/types/perturbation.js +9 -0
- package/dist/types/perturbation.js.map +1 -0
- package/dist/types/result.d.ts +150 -0
- package/dist/types/result.d.ts.map +1 -0
- package/dist/types/result.js +12 -0
- package/dist/types/result.js.map +1 -0
- package/dist/types/sut.d.ts +128 -0
- package/dist/types/sut.d.ts.map +1 -0
- package/dist/types/sut.js +12 -0
- package/dist/types/sut.js.map +1 -0
- package/package.json +290 -7
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory Monitoring for Experiment Execution
|
|
3
|
+
*
|
|
4
|
+
* Tracks memory usage during experiment execution to:
|
|
5
|
+
* 1. Detect memory leaks and excessive consumption
|
|
6
|
+
* 2. Provide early warning before OOM kills
|
|
7
|
+
* 3. Record memory statistics in provenance data
|
|
8
|
+
* 4. Enable automatic throttling or abort on memory pressure
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Memory usage statistics.
|
|
12
|
+
*/
|
|
13
|
+
export interface MemoryStats {
|
|
14
|
+
/** Resident set size in bytes (actual physical memory used) */
|
|
15
|
+
rssBytes: number;
|
|
16
|
+
/** Total heap size in bytes (allocated + unused) */
|
|
17
|
+
heapTotalBytes: number;
|
|
18
|
+
/** Heap used in bytes (actually used) */
|
|
19
|
+
heapUsedBytes: number;
|
|
20
|
+
/** External memory in bytes (C++ objects, etc) */
|
|
21
|
+
externalBytes: number;
|
|
22
|
+
/** Array buffers in bytes */
|
|
23
|
+
arrayBuffersBytes: number;
|
|
24
|
+
/** RSS in MB for human readability */
|
|
25
|
+
rssMb: number;
|
|
26
|
+
/** Heap usage percentage */
|
|
27
|
+
heapUsagePercent: number;
|
|
28
|
+
/** Timestamp when stats were collected */
|
|
29
|
+
timestamp: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Memory warning levels.
|
|
33
|
+
*/
|
|
34
|
+
export declare enum MemoryWarningLevel {
|
|
35
|
+
/** No warning (memory usage is normal) */
|
|
36
|
+
NORMAL = "normal",
|
|
37
|
+
/** Warning (memory usage is elevated) */
|
|
38
|
+
WARNING = "warning",
|
|
39
|
+
/** Critical (memory usage is dangerously high) */
|
|
40
|
+
CRITICAL = "critical",
|
|
41
|
+
/** Emergency (process is near OOM) */
|
|
42
|
+
EMERGENCY = "emergency"
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Memory monitoring configuration.
|
|
46
|
+
*/
|
|
47
|
+
export interface MemoryMonitorConfig {
|
|
48
|
+
/** Warning threshold (MB) - default: 1GB */
|
|
49
|
+
warningThresholdMb: number;
|
|
50
|
+
/** Critical threshold (MB) - default: 2GB */
|
|
51
|
+
criticalThresholdMb: number;
|
|
52
|
+
/** Emergency threshold (MB) - default: 80% of system memory */
|
|
53
|
+
emergencyThresholdMb: number;
|
|
54
|
+
/** Whether to log memory usage */
|
|
55
|
+
verbose: boolean;
|
|
56
|
+
/** Callback when warning level changes */
|
|
57
|
+
onWarningLevelChange?: (level: MemoryWarningLevel, stats: MemoryStats) => void;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Default memory monitoring configuration.
|
|
61
|
+
*/
|
|
62
|
+
export declare const DEFAULT_MEMORY_CONFIG: MemoryMonitorConfig;
|
|
63
|
+
/**
|
|
64
|
+
* Memory monitor for tracking usage during execution.
|
|
65
|
+
*/
|
|
66
|
+
export declare class MemoryMonitor {
|
|
67
|
+
private readonly config;
|
|
68
|
+
private currentLevel;
|
|
69
|
+
private startTime;
|
|
70
|
+
constructor(config?: Partial<MemoryMonitorConfig>);
|
|
71
|
+
/**
|
|
72
|
+
* Get current memory usage statistics.
|
|
73
|
+
*/
|
|
74
|
+
getStats(): MemoryStats;
|
|
75
|
+
/**
|
|
76
|
+
* Get current warning level based on memory usage.
|
|
77
|
+
* @param stats
|
|
78
|
+
*/
|
|
79
|
+
getWarningLevel(stats?: MemoryStats): MemoryWarningLevel;
|
|
80
|
+
/**
|
|
81
|
+
* Check memory usage and trigger warnings if needed.
|
|
82
|
+
*
|
|
83
|
+
* @returns Current warning level
|
|
84
|
+
*/
|
|
85
|
+
check(): MemoryWarningLevel;
|
|
86
|
+
/**
|
|
87
|
+
* Log memory warning with details.
|
|
88
|
+
* @param level
|
|
89
|
+
* @param stats
|
|
90
|
+
*/
|
|
91
|
+
private logWarning;
|
|
92
|
+
/**
|
|
93
|
+
* Create a memory snapshot for provenance tracking.
|
|
94
|
+
*/
|
|
95
|
+
snapshot(): MemoryStats;
|
|
96
|
+
/**
|
|
97
|
+
* Format memory stats for logging.
|
|
98
|
+
* @param stats
|
|
99
|
+
*/
|
|
100
|
+
format(stats?: MemoryStats): string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Get or create the global memory monitor.
|
|
104
|
+
* @param config
|
|
105
|
+
*/
|
|
106
|
+
export declare const getGlobalMemoryMonitor: (config?: Partial<MemoryMonitorConfig>) => MemoryMonitor;
|
|
107
|
+
/**
|
|
108
|
+
* Check memory usage using the global monitor.
|
|
109
|
+
*/
|
|
110
|
+
export declare const checkMemoryUsage: () => MemoryWarningLevel;
|
|
111
|
+
/**
|
|
112
|
+
* Get current memory stats using the global monitor.
|
|
113
|
+
*/
|
|
114
|
+
export declare const getMemoryStats: () => MemoryStats;
|
|
115
|
+
//# sourceMappingURL=memory-monitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-monitor.d.ts","sourceRoot":"","sources":["../../src/executor/memory-monitor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,CAAC;IAEjB,oDAAoD;IACpD,cAAc,EAAE,MAAM,CAAC;IAEvB,yCAAyC;IACzC,aAAa,EAAE,MAAM,CAAC;IAEtB,kDAAkD;IAClD,aAAa,EAAE,MAAM,CAAC;IAEtB,6BAA6B;IAC7B,iBAAiB,EAAE,MAAM,CAAC;IAE1B,sCAAsC;IACtC,KAAK,E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sB,GAAI,SAAS,OAAO,CAAC,mBAAmB,CAAC,KAAG,aAG9E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,QAAO,kBAGnC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,QAAO,WAGjC,CAAC"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory Monitoring for Experiment Execution
|
|
3
|
+
*
|
|
4
|
+
* Tracks memory usage during experiment execution to:
|
|
5
|
+
* 1. Detect memory leaks and excessive consumption
|
|
6
|
+
* 2. Provide early warning before OOM kills
|
|
7
|
+
* 3. Record memory statistics in provenance data
|
|
8
|
+
* 4. Enable automatic throttling or abort on memory pressure
|
|
9
|
+
*/
|
|
10
|
+
import { hrtime } from "node:process";
|
|
11
|
+
/**
|
|
12
|
+
* Memory warning levels.
|
|
13
|
+
*/
|
|
14
|
+
export var MemoryWarningLevel;
|
|
15
|
+
(function (MemoryWarningLevel) {
|
|
16
|
+
/** No warning (memory usage is normal) */
|
|
17
|
+
MemoryWarningLevel["NORMAL"] = "normal";
|
|
18
|
+
/** Warning (memory usage is elevated) */
|
|
19
|
+
MemoryWarningLevel["WARNING"] = "warning";
|
|
20
|
+
/** Critical (memory usage is dangerously high) */
|
|
21
|
+
MemoryWarningLevel["CRITICAL"] = "critical";
|
|
22
|
+
/** Emergency (process is near OOM) */
|
|
23
|
+
MemoryWarningLevel["EMERGENCY"] = "emergency";
|
|
24
|
+
})(MemoryWarningLevel || (MemoryWarningLevel = {}));
|
|
25
|
+
/**
|
|
26
|
+
* Default memory monitoring configuration.
|
|
27
|
+
*/
|
|
28
|
+
export const DEFAULT_MEMORY_CONFIG = {
|
|
29
|
+
warningThresholdMb: 1024, // 1GB
|
|
30
|
+
criticalThresholdMb: 2048, // 2GB
|
|
31
|
+
emergencyThresholdMb: Math.floor((Number(process.env.MEMORY_LIMIT_MB) || 16_384) * 0.8), // 80% of limit or 13GB
|
|
32
|
+
verbose: false,
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Memory monitor for tracking usage during execution.
|
|
36
|
+
*/
|
|
37
|
+
export class MemoryMonitor {
|
|
38
|
+
config;
|
|
39
|
+
currentLevel = MemoryWarningLevel.NORMAL;
|
|
40
|
+
startTime;
|
|
41
|
+
constructor(config) {
|
|
42
|
+
this.config = { ...DEFAULT_MEMORY_CONFIG, ...config };
|
|
43
|
+
this.startTime = hrtime.bigint();
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get current memory usage statistics.
|
|
47
|
+
*/
|
|
48
|
+
getStats() {
|
|
49
|
+
const mem = process.memoryUsage();
|
|
50
|
+
// RSS is already in bytes on most platforms
|
|
51
|
+
const rssBytes = mem.rss;
|
|
52
|
+
const rssMb = rssBytes / (1024 * 1024);
|
|
53
|
+
const heapTotalBytes = mem.heapTotal;
|
|
54
|
+
const heapUsedBytes = mem.heapUsed;
|
|
55
|
+
const heapUsagePercent = (heapUsedBytes / heapTotalBytes) * 100;
|
|
56
|
+
// Calculate elapsed time in milliseconds
|
|
57
|
+
const elapsedHr = hrtime.bigint() - this.startTime;
|
|
58
|
+
const timestamp = Number(elapsedHr) / 1_000_000;
|
|
59
|
+
return {
|
|
60
|
+
rssBytes,
|
|
61
|
+
heapTotalBytes,
|
|
62
|
+
heapUsedBytes,
|
|
63
|
+
externalBytes: mem.external,
|
|
64
|
+
arrayBuffersBytes: mem.arrayBuffers,
|
|
65
|
+
rssMb,
|
|
66
|
+
heapUsagePercent,
|
|
67
|
+
timestamp,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get current warning level based on memory usage.
|
|
72
|
+
* @param stats
|
|
73
|
+
*/
|
|
74
|
+
getWarningLevel(stats) {
|
|
75
|
+
const current = stats ?? this.getStats();
|
|
76
|
+
if (current.rssMb >= this.config.emergencyThresholdMb) {
|
|
77
|
+
return MemoryWarningLevel.EMERGENCY;
|
|
78
|
+
}
|
|
79
|
+
if (current.rssMb >= this.config.criticalThresholdMb) {
|
|
80
|
+
return MemoryWarningLevel.CRITICAL;
|
|
81
|
+
}
|
|
82
|
+
if (current.rssMb >= this.config.warningThresholdMb) {
|
|
83
|
+
return MemoryWarningLevel.WARNING;
|
|
84
|
+
}
|
|
85
|
+
return MemoryWarningLevel.NORMAL;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Check memory usage and trigger warnings if needed.
|
|
89
|
+
*
|
|
90
|
+
* @returns Current warning level
|
|
91
|
+
*/
|
|
92
|
+
check() {
|
|
93
|
+
const stats = this.getStats();
|
|
94
|
+
const level = this.getWarningLevel(stats);
|
|
95
|
+
// Trigger callback if level changed
|
|
96
|
+
if (level !== this.currentLevel) {
|
|
97
|
+
this.currentLevel = level;
|
|
98
|
+
if (this.config.onWarningLevelChange) {
|
|
99
|
+
this.config.onWarningLevelChange(level, stats);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// Log warning if verbose
|
|
103
|
+
if (this.config.verbose && level !== MemoryWarningLevel.NORMAL) {
|
|
104
|
+
this.logWarning(level, stats);
|
|
105
|
+
}
|
|
106
|
+
return level;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Log memory warning with details.
|
|
110
|
+
* @param level
|
|
111
|
+
* @param stats
|
|
112
|
+
*/
|
|
113
|
+
logWarning(level, stats) {
|
|
114
|
+
const levelColors = {
|
|
115
|
+
[MemoryWarningLevel.WARNING]: "\u001B[33m", // Yellow
|
|
116
|
+
[MemoryWarningLevel.CRITICAL]: "\u001B[31m", // Red
|
|
117
|
+
[MemoryWarningLevel.EMERGENCY]: "\u001B[35m", // Magenta
|
|
118
|
+
[MemoryWarningLevel.NORMAL]: "\u001B[32m", // Green
|
|
119
|
+
};
|
|
120
|
+
const reset = "\u001B[0m";
|
|
121
|
+
const color = levelColors[level];
|
|
122
|
+
console.warn(`${color}[Memory ${level.toUpperCase()}]${reset} ` +
|
|
123
|
+
`RSS: ${stats.rssMb.toFixed(1)}MB ` +
|
|
124
|
+
`| Heap: ${(stats.heapUsedBytes / 1024 / 1024).toFixed(1)}MB / ${(stats.heapTotalBytes / 1024 / 1024).toFixed(1)}MB ` +
|
|
125
|
+
`(${stats.heapUsagePercent.toFixed(1)}%)`);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Create a memory snapshot for provenance tracking.
|
|
129
|
+
*/
|
|
130
|
+
snapshot() {
|
|
131
|
+
return this.getStats();
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Format memory stats for logging.
|
|
135
|
+
* @param stats
|
|
136
|
+
*/
|
|
137
|
+
format(stats) {
|
|
138
|
+
const current = stats ?? this.getStats();
|
|
139
|
+
return `RSS: ${current.rssMb.toFixed(1)}MB, Heap: ${(current.heapUsedBytes / 1024 / 1024).toFixed(1)}MB`;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Global memory monitor instance for convenience.
|
|
144
|
+
*/
|
|
145
|
+
let globalMonitor = null;
|
|
146
|
+
/**
|
|
147
|
+
* Get or create the global memory monitor.
|
|
148
|
+
* @param config
|
|
149
|
+
*/
|
|
150
|
+
export const getGlobalMemoryMonitor = (config) => {
|
|
151
|
+
globalMonitor ??= new MemoryMonitor(config);
|
|
152
|
+
return globalMonitor;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Check memory usage using the global monitor.
|
|
156
|
+
*/
|
|
157
|
+
export const checkMemoryUsage = () => {
|
|
158
|
+
const monitor = getGlobalMemoryMonitor();
|
|
159
|
+
return monitor.check();
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Get current memory stats using the global monitor.
|
|
163
|
+
*/
|
|
164
|
+
export const getMemoryStats = () => {
|
|
165
|
+
const monitor = getGlobalMemoryMonitor();
|
|
166
|
+
return monitor.getStats();
|
|
167
|
+
};
|
|
168
|
+
//# sourceMappingURL=memory-monitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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KAAK;YACrH,IAAI,KAAK,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAC1C,CAAC;IACH,CAAC;IAED;;OAEG;IACH,QAAQ;QACP,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,KAAmB;QACzB,MAAM,OAAO,GAAG,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QACzC,OAAO,QAAQ,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,aAAa,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IAC1G,CAAC;CACD;AAED;;GAEG;AACH,IAAI,aAAa,GAAyB,IAAI,CAAC;AAE/C;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,MAAqC,EAAiB,EAAE;IAC9F,aAAa,KAAK,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;IAC5C,OAAO,aAAa,CAAC;AACtB,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAuB,EAAE;IACxD,MAAM,OAAO,GAAG,sBAAsB,EAAE,CAAC;IACzC,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;AACxB,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,GAAgB,EAAE;IAC/C,MAAM,OAAO,GAAG,sBAAsB,EAAE,CAAC;IACzC,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAC;AAC3B,CAAC,CAAC"}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parallel executor using child processes.
|
|
3
|
+
*
|
|
4
|
+
* Spawns multiple Node.js processes, each executing a subset of runs.
|
|
5
|
+
* Each worker writes to its own sharded checkpoint file to avoid race conditions.
|
|
6
|
+
*
|
|
7
|
+
* Sharded checkpoint files:
|
|
8
|
+
* results/execute/checkpoint-worker-00.json
|
|
9
|
+
* results/execute/checkpoint-worker-01.json
|
|
10
|
+
* ...
|
|
11
|
+
*
|
|
12
|
+
* Dependency Injection:
|
|
13
|
+
* - Logger interface enables testing of log output
|
|
14
|
+
* - ProcessSpawner interface enables mocking spawn() calls
|
|
15
|
+
* - SystemInfo interface enables testing CPU count and node path logic
|
|
16
|
+
*/
|
|
17
|
+
import type { EvaluationResult } from "../types/result.js";
|
|
18
|
+
import type { ExecutorConfig, PlannedRun } from "./executor.js";
|
|
19
|
+
/**
|
|
20
|
+
* Logger interface for output handling.
|
|
21
|
+
* Enables testing of log messages.
|
|
22
|
+
*/
|
|
23
|
+
export interface ILogger {
|
|
24
|
+
log(message: string): void;
|
|
25
|
+
debug(message: string): void;
|
|
26
|
+
info(message: string): void;
|
|
27
|
+
warn(message: string): void;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Production logger using console.
|
|
31
|
+
*/
|
|
32
|
+
export declare class ConsoleLogger implements ILogger {
|
|
33
|
+
log(message: string): void;
|
|
34
|
+
debug(message: string): void;
|
|
35
|
+
info(message: string): void;
|
|
36
|
+
warn(message: string): void;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Spawn options matching child_process.spawn signature.
|
|
40
|
+
*/
|
|
41
|
+
export interface SpawnOptions {
|
|
42
|
+
cwd?: string;
|
|
43
|
+
stdio?: "inherit" | "pipe" | "ignore";
|
|
44
|
+
env?: Record<string, string | undefined>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Child process interface.
|
|
48
|
+
* Abstraction over Node.js ChildProcess.
|
|
49
|
+
*/
|
|
50
|
+
export interface IChildProcess {
|
|
51
|
+
on(event: string, listener: (...args: unknown[]) => void): void;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Process spawner interface.
|
|
55
|
+
* Enables mocking of spawn() for testing.
|
|
56
|
+
*/
|
|
57
|
+
export interface IProcessSpawner {
|
|
58
|
+
spawn(command: string, args: string[], options: SpawnOptions): IChildProcess;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Production process spawner using node:child_process.
|
|
62
|
+
*/
|
|
63
|
+
export declare class ProcessSpawner implements IProcessSpawner {
|
|
64
|
+
spawn(command: string, args: string[], options: SpawnOptions): IChildProcess;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* System information interface.
|
|
68
|
+
* Enables testing of CPU count and node path logic.
|
|
69
|
+
*/
|
|
70
|
+
export interface ISystemInfo {
|
|
71
|
+
/** Number of CPU cores available */
|
|
72
|
+
cpuCount: number;
|
|
73
|
+
/** Path to the Node.js executable */
|
|
74
|
+
nodePath: string;
|
|
75
|
+
/** Package root directory */
|
|
76
|
+
packageRoot: string;
|
|
77
|
+
/** Current process environment */
|
|
78
|
+
env: Record<string, string | undefined>;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Production system info using node:os and process.
|
|
82
|
+
*/
|
|
83
|
+
export declare class SystemInfo implements ISystemInfo {
|
|
84
|
+
cpuCount: number;
|
|
85
|
+
nodePath: string;
|
|
86
|
+
env: NodeJS.ProcessEnv;
|
|
87
|
+
readonly packageRoot: string;
|
|
88
|
+
constructor();
|
|
89
|
+
/**
|
|
90
|
+
* Get the package root directory by resolving from the entry point script.
|
|
91
|
+
* The CLI entry point is dist/cli.js, so we go up one level from there.
|
|
92
|
+
*/
|
|
93
|
+
private getPackageRoot;
|
|
94
|
+
}
|
|
95
|
+
export interface ParallelExecutorOptions {
|
|
96
|
+
/** Number of parallel processes (default: CPU count) */
|
|
97
|
+
workers?: number;
|
|
98
|
+
/** Path to node executable */
|
|
99
|
+
nodePath?: string;
|
|
100
|
+
/** Checkpoint directory (defaults to "results/execute") */
|
|
101
|
+
checkpointDir?: string;
|
|
102
|
+
/** Per-run timeout in milliseconds (0 = no timeout) */
|
|
103
|
+
timeoutMs?: number;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Generate random worker names using tech-themed adjectives.
|
|
107
|
+
* Returns unique names for each worker.
|
|
108
|
+
* @param count
|
|
109
|
+
*/
|
|
110
|
+
export declare const generateWorkerNames: (count: number) => string[];
|
|
111
|
+
/**
|
|
112
|
+
* Generate sharded checkpoint path for a worker.
|
|
113
|
+
*
|
|
114
|
+
* @param checkpointDir - Base checkpoint directory
|
|
115
|
+
* @param workerIndex - Worker index (0-based)
|
|
116
|
+
* @returns Path to the worker's checkpoint file
|
|
117
|
+
*/
|
|
118
|
+
export declare const shardPath: (checkpointDir: string, workerIndex: number) => string;
|
|
119
|
+
/**
|
|
120
|
+
* Batch of runs for a worker.
|
|
121
|
+
*/
|
|
122
|
+
export interface RunBatch {
|
|
123
|
+
/** Batch index */
|
|
124
|
+
index: number;
|
|
125
|
+
/** Run IDs in this batch */
|
|
126
|
+
runIds: string[];
|
|
127
|
+
/** JSON filter string for CLI */
|
|
128
|
+
filter: string;
|
|
129
|
+
/** First run ID in batch */
|
|
130
|
+
firstRunId: string;
|
|
131
|
+
/** Last run ID in batch */
|
|
132
|
+
lastRunId: string;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Worker configuration.
|
|
136
|
+
*/
|
|
137
|
+
export interface WorkerConfig {
|
|
138
|
+
/** Worker index */
|
|
139
|
+
index: number;
|
|
140
|
+
/** Worker name */
|
|
141
|
+
name: string;
|
|
142
|
+
/** Checkpoint path for this worker */
|
|
143
|
+
checkpointPath: string;
|
|
144
|
+
/** CLI arguments */
|
|
145
|
+
arguments: string[];
|
|
146
|
+
/** Environment variables */
|
|
147
|
+
env: Record<string, string | undefined>;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Parallel executor class with dependency injection.
|
|
151
|
+
*
|
|
152
|
+
* Spawns multiple Node.js processes, each executing a subset of runs.
|
|
153
|
+
* Each worker writes to its own sharded checkpoint file to avoid race conditions.
|
|
154
|
+
*/
|
|
155
|
+
export declare class ParallelExecutor {
|
|
156
|
+
private readonly logger;
|
|
157
|
+
private readonly spawner;
|
|
158
|
+
private readonly systemInfo;
|
|
159
|
+
constructor(logger?: ILogger, spawner?: IProcessSpawner, systemInfo?: ISystemInfo);
|
|
160
|
+
/**
|
|
161
|
+
* Split runs into batches for parallel processing.
|
|
162
|
+
* @param runs - Runs to distribute
|
|
163
|
+
* @param numberWorkers - Number of worker processes
|
|
164
|
+
* @returns Array of run batches
|
|
165
|
+
*/
|
|
166
|
+
_createBatches(runs: PlannedRun[], numberWorkers: number): RunBatch[];
|
|
167
|
+
/**
|
|
168
|
+
* Create worker configurations for all batches.
|
|
169
|
+
* @param batches - Run batches
|
|
170
|
+
* @param workerNames - Names for each worker
|
|
171
|
+
* @param cliPath - Path to CLI entry point
|
|
172
|
+
* @param checkpointDir - Base checkpoint directory
|
|
173
|
+
* @param timeoutMs - Per-run timeout in milliseconds
|
|
174
|
+
* @returns Array of worker configurations
|
|
175
|
+
*/
|
|
176
|
+
_createWorkerConfigs(batches: RunBatch[], workerNames: string[], cliPath: string, checkpointDir: string, timeoutMs: number): WorkerConfig[];
|
|
177
|
+
/**
|
|
178
|
+
* Spawn worker processes for all configurations.
|
|
179
|
+
* @param workerConfigs - Worker configurations
|
|
180
|
+
* @param nodePath - Path to node executable
|
|
181
|
+
* @param packageRoot - Package root directory
|
|
182
|
+
* @returns Array of child processes
|
|
183
|
+
*/
|
|
184
|
+
_spawnWorkers(workerConfigs: WorkerConfig[], nodePath: string, packageRoot: string): IChildProcess[];
|
|
185
|
+
/**
|
|
186
|
+
* Wait for all workers to complete.
|
|
187
|
+
* @param workers - Child processes
|
|
188
|
+
* @returns Promise that resolves when all workers exit
|
|
189
|
+
*/
|
|
190
|
+
_waitForWorkers(workers: IChildProcess[]): Promise<number[]>;
|
|
191
|
+
/**
|
|
192
|
+
* Execute runs using multiple parallel processes.
|
|
193
|
+
*
|
|
194
|
+
* Each worker writes to its own sharded checkpoint file to avoid race conditions.
|
|
195
|
+
* After all workers complete, the main process should merge the shards.
|
|
196
|
+
*
|
|
197
|
+
* @param runs - Planned runs to execute
|
|
198
|
+
* @param suts - SUT definitions (not used directly, passed to workers)
|
|
199
|
+
* @param cases - Case definitions (not used directly, passed to workers)
|
|
200
|
+
* @param config - Executor configuration
|
|
201
|
+
* @param options - Parallel executor options
|
|
202
|
+
* @returns Execution results (empty - CLI will load from shards)
|
|
203
|
+
*/
|
|
204
|
+
execute(runs: PlannedRun[], _suts: unknown, _cases: unknown[], config: ExecutorConfig & {
|
|
205
|
+
onResult?: (result: EvaluationResult) => void;
|
|
206
|
+
}, options?: ParallelExecutorOptions): Promise<{
|
|
207
|
+
results: EvaluationResult[];
|
|
208
|
+
errors: {
|
|
209
|
+
runId: string;
|
|
210
|
+
error: string;
|
|
211
|
+
}[];
|
|
212
|
+
}>;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Execute runs using multiple parallel processes.
|
|
216
|
+
*
|
|
217
|
+
* Each worker writes to its own sharded checkpoint file to avoid race conditions.
|
|
218
|
+
* After all workers complete, the main process should merge the shards.
|
|
219
|
+
*
|
|
220
|
+
* This is a convenience function that creates a ParallelExecutor with default dependencies.
|
|
221
|
+
* For testing or custom behavior, use the ParallelExecutor class directly.
|
|
222
|
+
*
|
|
223
|
+
* @param runs - Planned runs to execute
|
|
224
|
+
* @param suts - SUT definitions (not used directly, passed to workers)
|
|
225
|
+
* @param cases - Case definitions (not used directly, passed to workers)
|
|
226
|
+
* @param config - Executor configuration
|
|
227
|
+
* @param options - Parallel executor options
|
|
228
|
+
* @returns Execution results (empty - CLI will load from shards)
|
|
229
|
+
*/
|
|
230
|
+
export declare const executeParallel: (runs: PlannedRun[], suts: unknown, cases: unknown[], config: ExecutorConfig & {
|
|
231
|
+
onResult?: (result: EvaluationResult) => void;
|
|
232
|
+
}, options?: ParallelExecutorOptions) => Promise<{
|
|
233
|
+
results: EvaluationResult[];
|
|
234
|
+
errors: {
|
|
235
|
+
runId: string;
|
|
236
|
+
error: string;
|
|
237
|
+
}[];
|
|
238
|
+
}>;
|
|
239
|
+
//# sourceMappingURL=parallel-executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parallel-executor.d.ts","sourceRoot":"","sources":["../../src/executor/parallel-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAOH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhE;;;GAGG;AACH,MAAM,WAAW,OAAO;IACvB,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED;;GAEG;AACH,qBAAa,aAAc,YAAW,OAAO;IAC5C,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI1B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI5B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI3B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAG3B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC;IACtC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CACzC;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC7B,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,IAA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