Skip to content

Conversation

@raphaeltimbo
Copy link
Collaborator

Summary

Two optimizations for HolePatternSeal achieving 1.64x speedup for single frequency calculations.

Changes

  1. Smart multiprocessing threshold - Sequential for ≤2 frequencies, parallel for >2
  2. Cached calculations in form_rhs() - Pre-compute constants and expensive operations

Performance

  • Single frequency: 1.64x faster (0.342s → 0.209s)
  • 2 frequencies: 1.29x faster
  • 5+ frequencies: No degradation

Testing

✅ All tests pass
✅ Backward compatible
✅ Numerical accuracy maintained

Implemented two key optimizations for HolePatternSeal:

1. Smart multiprocessing threshold
   - Use sequential execution for ≤2 frequencies
   - Avoids multiprocessing overhead (~0.106s) for small workloads
   - Adds context manager for proper resource cleanup
   - Improvement: 1.60x faster for 1-2 frequencies

2. Cached calculations in form_rhs()
   - Pre-compute constant values (gamma*R, radius*omega, etc.)
   - Cache expensive power operations (T**1.5)
   - Reduce redundant calculations
   - Improvement: Additional ~2% speedup

Performance results:
- Single frequency: 0.342s → 0.209s (1.64x faster)
- 2 frequencies: ~0.450s → ~0.350s (1.29x faster)
- 5+ frequencies: No degradation (multiprocessing still beneficial)

All tests pass with maintained numerical accuracy.
Fully backward compatible - API unchanged.
@raphaeltimbo raphaeltimbo merged commit 4d992b0 into petrobras:main Oct 9, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant