HamzaHassanain / HamzaHassanain/polyman

Implement Parallel Execution for Independent Operations to Improve Performance

Open
#7 0 comments 0 reactions 0 assignees View on GitHub
enhancement good first issue help wanted performance
Dominant language
TypeScript
Stars
35
Forks
3
PR merge metrics
No merged PRs in 30d

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**
```ts
// Current: Sequential (slow)
for (const command of commands) {
await generateFromCommand(command);
}
// With 20 tests: ~20 seconds
```
**2. Test Validation**
```ts
// Current: Sequential (slow)
for (const test of tests) {
await validateTest(test);
}
// With 50 tests: ~50 seconds
```
3. Solution Compilation
```ts
// Current: Sequential (slow)
for (const solution of solutions) {
await compileSolution(solution);
}
// With 5 solutions: ~10-15 seconds
```
4. Multiple Solution Execution
```ts
// 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

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.