The Importance of Benchmarks
7 hours ago
- #Performance Optimization
- #Algorithm Improvement
- #Benchmarking
- Aha! Develop team found a sprint report taking 15 minutes to load due to a 1,000-day sprint, triggering a performance investigation.
- The performance bottleneck was identified in sprint progress parsing, affecting all sprint reports like retrospective and burndown.
- The original algorithm cloned data for each sprint day, including empty days, causing memory and speed issues.
- Hypothesis: memory usage scaled with days, making later days slower to clone as more records accumulated.
- Solution #1 introduced a new data structure (ParsedSprintProgressData) that stores empty days as null, reducing memory usage by up to 90%.
- Benchmarking revealed that memory improvements only led to a 20% runtime gain, disproving the initial hypothesis.
- Profiling identified two hot paths: lodash.cloneDeep() and moment.format(), which were major performance overheads.
- Solution #2 replaced cloneDeep() with explicit duplication and moment.format() with a custom date formatting function.
- Combining both approaches resulted in faster parsing, less memory usage, and minimal impact from empty days.
- The problematic report now parses in a fraction of a second, a three-order-of-magnitude improvement, though rendering still takes seconds.