[Bug]: O(n*m) behavior in useDisplayPayee #2489

Closed
opened 2026-02-28 20:15:40 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @thromer on GitHub (Sep 20, 2025).

Verified issue does not already exist?

  • I have searched and found no existing issue

What happened?

I used Chrome dev tools to profile the app when switching between accounts in a budget with a 8000+ payees and two accounts with 1000+ transactions. CPU spikes to over 100% for over 30s. The profile showed a significant amount of time in useDisplayPayee, which calls usePayee, which in turn calls payees.find. So I think performance is O(m*n) in the number of transactions and payees.

I expect changing PayeeState.payees in payeesSlice.ts from a PayeeEntity[] to a Map<string, PayeeEntity> would improve things. I can put together a PR, which will involve a little surgery to update all the existing uses of payees in desktop-client.

Let me know if I'm off track. I'm an infrastructure engineer by trade, not a React/Redux engineer!

How can we reproduce the issue?

See above.

Where are you hosting Actual?

Locally via Yarn

What browsers are you seeing the problem on?

Chrome

Operating System

Linux

Originally created by @thromer on GitHub (Sep 20, 2025). ### Verified issue does not already exist? - [x] I have searched and found no existing issue ### What happened? I used Chrome dev tools to profile the app when switching between accounts in a budget with a 8000+ payees and two accounts with 1000+ transactions. CPU spikes to over 100% for over 30s. The profile showed a significant amount of time in [`useDisplayPayee`](https://github.com/actualbudget/actual/blob/master/packages/desktop-client/src/hooks/useDisplayPayee.ts#L26), which calls [`usePayee`](https://github.com/actualbudget/actual/blob/master/packages/desktop-client/src/hooks/usePayee.ts), which in turn calls `payees.find`. So I think performance is O(m*n) in the number of transactions and payees. I expect changing `PayeeState.payees` in [`payeesSlice.ts`](https://github.com/actualbudget/actual/blob/master/packages/desktop-client/src/payees/payeesSlice.ts) from a `PayeeEntity[]` to a `Map<string, PayeeEntity>` would improve things. I can put together a PR, which will involve a little surgery to update all the existing uses of `payees` in `desktop-client`. Let me know if I'm off track. I'm an infrastructure engineer by trade, not a React/Redux engineer! ### How can we reproduce the issue? See above. ### Where are you hosting Actual? Locally via Yarn ### What browsers are you seeing the problem on? Chrome ### Operating System Linux
GiteaMirror added the user interfacebug labels 2026-02-28 20:15:40 -06:00
Author
Owner

@thromer commented on GitHub (Sep 21, 2025):

With #5761, switching between the 2 accounts is noticeably more responsive and the spike in CPU is single digit seconds.

@thromer commented on GitHub (Sep 21, 2025): With #5761, switching between the 2 accounts is noticeably more responsive and the spike in CPU is single digit seconds.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#2489