Commit 14805d9
perf(concurrency): cancel remaining goroutines when has error (#9484)
**Description**
This PR optimizes goroutine execution in multi-task scenarios:
- Uses errgroup.WithContext to manage multiple goroutines and propagate
cancellation signals.
- When any goroutine encounters an error, errgroup automatically cancels
the remaining goroutines, allowing them to exit early.
- Reduces unnecessary computation and resource usage when partial
failures occur.
This improves system responsiveness and reduces wasted CPU cycles in
error cases.
**Checklist**
- [x] Code compiles correctly and linting passes locally
- [ ] For all _code_ changes, an entry added to the `CHANGELOG.md` file
describing and linking to
this PR
- [ ] Tests added for new functionality, or regression tests for bug
fixes added as applicable
---------
Co-authored-by: Harshil Goel <[email protected]>
Co-authored-by: Matthew McNeely <[email protected]>1 parent 80cf21c commit 14805d9
1 file changed
Lines changed: 24 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
823 | 823 | | |
824 | 824 | | |
825 | 825 | | |
826 | | - | |
827 | 826 | | |
828 | 827 | | |
| 828 | + | |
829 | 829 | | |
830 | 830 | | |
831 | 831 | | |
| |||
834 | 834 | | |
835 | 835 | | |
836 | 836 | | |
837 | | - | |
838 | | - | |
| 837 | + | |
| 838 | + | |
839 | 839 | | |
840 | 840 | | |
841 | 841 | | |
| |||
978 | 978 | | |
979 | 979 | | |
980 | 980 | | |
981 | | - | |
982 | | - | |
983 | | - | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
984 | 984 | | |
985 | | - | |
986 | | - | |
987 | | - | |
988 | | - | |
| 985 | + | |
| 986 | + | |
989 | 987 | | |
990 | 988 | | |
991 | 989 | | |
| |||
1635 | 1633 | | |
1636 | 1634 | | |
1637 | 1635 | | |
| 1636 | + | |
1638 | 1637 | | |
1639 | 1638 | | |
1640 | 1639 | | |
1641 | 1640 | | |
1642 | | - | |
| 1641 | + | |
| 1642 | + | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
1643 | 1650 | | |
1644 | 1651 | | |
1645 | 1652 | | |
| |||
1661 | 1668 | | |
1662 | 1669 | | |
1663 | 1670 | | |
1664 | | - | |
1665 | 1671 | | |
1666 | 1672 | | |
1667 | 1673 | | |
1668 | 1674 | | |
1669 | 1675 | | |
1670 | 1676 | | |
1671 | | - | |
1672 | | - | |
1673 | | - | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
1674 | 1681 | | |
1675 | | - | |
1676 | | - | |
1677 | | - | |
1678 | | - | |
| 1682 | + | |
| 1683 | + | |
1679 | 1684 | | |
1680 | 1685 | | |
1681 | 1686 | | |
| |||
0 commit comments