Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why MutableStateFlowStore send action need to run in dispatcherProvider.main? #86

Open
lxc7923 opened this issue Nov 20, 2024 · 1 comment

Comments

@lxc7923
Copy link

lxc7923 commented Nov 20, 2024

Description

Hi Team!
I have a project using
toggl.komposable, but met some performance issue.
After debugging I found that it's because it takes too long for a
Reducer to call reduce function when starting the App, think it's because
Ul thread is full occupied when the App is starting. And I found that MutableStateFlowStore force the reduce process run in
dispatcherProvider.main
Is there a reason why? And if I just change the dispatcherProvider like below, to make it run in 10 thread, the problem solved.

internal val dispatcherProvider =
DispatcherProvider(
io = Dispatchers.io,
computation =
Dispatchers.Default,
main = Dispatchers.io,
)

But I don't know if it's risky, can you help please? Many thanks.

@sveltema
Copy link

The state updates need to be handled non-concurrently. The easy way to do this is to update all states on main (at the risk of UI hitches) but this is not required if your store dispatcher uses limitedParallelism(1). if you use Dispatchers.io for the store dispatch, you can introduce race conditions in your state updates due to parallelism and have hard to track down bugs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants