HamzaHassanain/polyman

Implement Parallel Execution for Independent Operations to Improve Performance

Open

#7 opened on Nov 24, 2025

 (0 comments) (0 reactions) (0 assignees)TypeScript (2 forks)auto 404
enhancementgood first issuehelp wantedperformance

Repository metrics

Stars
 (33 stars)
PR merge metrics
 (PR metrics pending)

Description

Problem Currently, many operations in Polyman execute sequentially even when they could run in parallel. This leads to unnecessary delays, especially for problems with many tests, solutions, or generators.

Examples of Sequential Bottlenecks 1. Test Generation

// Current: Sequential (slow)
for (const command of commands) {
  await generateFromCommand(command);
}
// With 20 tests: ~20 seconds

2. Test Validation

// Current: Sequential (slow)
for (const test of tests) {
  await validateTest(test);
}
// With 50 tests: ~50 seconds
  1. Solution Compilation
// Current: Sequential (slow)
for (const solution of solutions) {
  await compileSolution(solution);
}
// With 5 solutions: ~10-15 seconds
  1. Multiple Solution Execution
// Current: Sequential in verification
for (const solution of solutions) {
  await runSolutionOnAllTests(solution);
}

Here's a refined GitHub issue:

Title: Implement Parallel Execution for Independent Operations to Improve Performance

Description: Problem Currently, many operations in Polyman execute sequentially even when they could run in parallel. This leads to unnecessary delays, especially for problems with many tests, solutions, or generators.

Examples of Sequential Bottlenecks

  1. Test Generation

  2. Test Validation

  3. Solution Compilation

  4. Multiple Solution Execution

Proposed Solution Implement parallel execution using Promise.all() for independent operations:

Operations That Can Be Parallelized

High Impact (Most Time Saved)

  • Test generation - Each generator run is independent
  • Test validation - Each validator run is independent
  • Solution compilation - Each compilation is independent
  • Solution execution on same test - Different solutions on same test can run simultaneously

Medium Impact

  • Checker/Validator self-tests - Independent test cases
  • File downloads during remote pull (statements, solutions, generators)
  • File uploads during remote push (can batch upload independent files)

Implementation Considerations

Safe to parallelize:

  • Test generation (independent generators)
  • Test validation (read-only operations)
  • Solution compilation (separate output files)
  • File I/O operations (different files)

Requires careful handling:

  • CPU-bound operations - Limit concurrency (e.g., p-limit with os.cpus().length)
  • Memory usage - Large test sets may need batching
  • File system locks - Ensure no write conflicts
  • Error handling - One failure shouldn't stop all operations

Must remain sequential:

  • Tests that depend on previous results
  • Operations with side effects that must occur in order
  • Solution execution on different tests (maintain test order for output)

Contributor guide