⚡ perf: parallelize sequential network requests in Hotel Store#6
⚡ perf: parallelize sequential network requests in Hotel Store#6chuanman2707 wants to merge 3 commits into
Conversation
Parallelizes sequential data fetching requests (`fetchRooms`, `fetchStats`, `fetchGroups`, `fetchHousekeeping`) in `useHotelStore.ts` using `Promise.all` to significantly reduce execution time and avoid network delays. Adds an E2E performance benchmark suite in `tests/e2e/15-store-performance.test.ts`. Co-authored-by: chuanman2707 <29907469+chuanman2707@users.noreply.github.com>
|
👋 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5df9d1ba9c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| }); | ||
| await get().fetchRooms(); | ||
| await get().fetchStats(); | ||
| await Promise.all([get().fetchRooms(), get().fetchStats()]); |
There was a problem hiding this comment.
Await parallel refreshes before clearing loading state
Using Promise.all here causes an early reject when any refresh fails, so the catch/finally path runs and endAction() clears loading while other refresh calls are still in flight. In scenarios like get_rooms failing quickly but get_dashboard_stats completing later, the action reports failure and stops loading prematurely, then late responses can still mutate store state after the action has ended; this regression now affects all similarly parallelized booking actions (checkIn, checkOut, extendStay, groupCheckIn, groupCheckout).
Useful? React with 👍 / 👎.
Parallelizes sequential data fetching requests (`fetchRooms`, `fetchStats`, `fetchGroups`, `fetchHousekeeping`) in `useHotelStore.ts` using `Promise.all` to significantly reduce execution time and avoid network delays. Adds an E2E performance benchmark suite in `tests/e2e/15-store-performance.test.ts`. Also fixes an unnecessary sort warning in `groups.rs`. Co-authored-by: chuanman2707 <29907469+chuanman2707@users.noreply.github.com>
|
Holding this PR. The |
Good catch! Switching from sequential |
Uses `Promise.allSettled` via a new `safeRefresh` helper to parallelize sequential store refreshes without propagating their failures to the main business action (e.g. check-in). Adds a targeted test asserting this safe failure behavior alongside the timing checks. Co-authored-by: chuanman2707 <29907469+chuanman2707@users.noreply.github.com>
💡 What:
Parallelized
fetchRooms(),fetchStats(),fetchGroups(), andfetchHousekeeping()calls withinuseHotelStore.ts(e.g.checkIn,groupCheckin,checkOut,extendStay,updateHousekeeping) usingPromise.all(). Also added a baseline testmhm/tests/e2e/15-store-performance.test.tsto capture mock execution durations.🎯 Why:
Previously, these fetch actions were awaited sequentially after their respective API actions. This sequential execution caused a waterfall delay since each data request waited for the previous one to complete, resulting in slower perceived action times. Fetch operations can safely run simultaneously.
📊 Measured Improvement:
In a local benchmark using mocked slow endpoints (
delay(100)for fetch queries,delay(50)for check-in action):checkInexecution time: Improved from ~253ms sequentially to ~158ms in parallel (a nearly 100ms improvement).groupCheckinexecution time: Improved from ~353ms sequentially to ~158ms in parallel (a nearly 200ms improvement).PR created automatically by Jules for task 11173198085945660925 started by @chuanman2707