⚡ Bolt: [performance improvement] Parallelize notification scheduling in autoNotifications#4
Conversation
Replaced sequential for-of loops containing asynchronous I/O (Notifications.scheduleNotificationAsync) with parallel execution using array mapping and Promise.all(). This significantly reduces the total time required to schedule multiple notifications concurrently by overlapping the async I/O. Co-authored-by: TargetMisser <52361977+TargetMisser@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What:
Refactored the
autoScheduleNotificationsfunction insrc/utils/autoNotifications.ts. Replaced the sequentialfor-ofloops that individually awaitedNotifications.scheduleNotificationAsyncwithPromise.all()over arrays of mapped promises. This schedules all notifications concurrently.🎯 Why:
The previous implementation scheduled notifications sequentially, awaiting the completion of each I/O operation before beginning the next one. This caused an unnecessary bottleneck since scheduling notifications can happen concurrently. Using
Promise.all()overlaps the I/O, leading to much faster total execution time, especially for busy shifts with many flights.📊 Measured Improvement:
A mock benchmark using 40 scheduled flights (20 arrivals, 20 departures with multiple notifications) showed a massive improvement:
PR created automatically by Jules for task 3844593416615938838 started by @TargetMisser