A case study in identifying software scaling bottlenecks, profiling CPU-bound execution environments, and engineering an alternative algorithmic architecture to achieve a 99.99% latency reduction.
This repository uses a mathematical sandbox (generating perfect square numbers) to visually map out and contrast an unoptimized brute-force search space against a linear generation pipeline.
By restructuring the underlying math logic, the execution time for calculating large sets of targets dropped from 2.25 hours down to 0.36 seconds, enabling a scale factor shift capable of generating 1,000,000 targets in under 6 seconds.
Our initial brute-force approach relied on an
As a result, tracking data points revealed a classic, flattening Square Root Curve (
During Phase 1 of development, the initial goal was to simply push the heavy brute-force math loops into the background using a ProcessPoolExecutor to bypass Python's Global Interpreter Lock (GIL).
However, an analysis of the
The bottleneck was broken by flipping the structural paradigm: shifting from an iterative search-and-verify model to a direct algebraic generation model using Python generators (yield). This compressed the search space into an explicit
- Process Isolation: Leveraged a non-blocking
asyncioevent loop paired withProcessPoolExecutorto offload heavy CPU calculations to dedicated, background OS worker pools, successfully bypassing Python's Global Interpreter Lock (GIL). - Lazy Evaluation: Engineered memory-safe data streaming via infinite generators to maintain a totally flat RAM footprint.
- Deterministic Logging: Automated comprehensive execution metric captures, dumping atomic timestamps and iteration tracking directly into overwrite-safe JSON manifests.