When the set operation is executed in the 「then callback」, the 「set operation」 takes nearly a hundred times longer. #2114
Unanswered
LZY622
asked this question in
Bug report
Replies: 1 comment 3 replies
-
|
Hi, thanks for reporting. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment



Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When the set operation is executed in the 「then callback」, the「set operation」 takes nearly a hundred times longer.
In a new umi framework,Add a button to the page and add a handle to the button to test the time consumption of the 「set operation」.
Print time-consuming code(Store)
UI code
Experiment 1
Handle code:
Time consuming printing:

Experiment 2
Handle code:
Time consuming printing:

Experiment 3
Handle code:
Time consuming printing:

Experiment 4
Handle code:
Time consuming printing:

Experiment 5
Handle code:
Time consuming printing:

Conclusions and conjectures
If there is an await statement before the set operation, the set operation will take longer. And the more awaits, the more time it takes. From experiments, we can find that there seems to be a threshold for the number of awaits. In the example, if there are more than 2 awaits, the time consumption will jump directly to 30ms.In our actual project, due to factors such as store size, a simple set operation will take 200+ms. The essence of await is the syntactic sugar of 「.then callback」, so it is reasonable to speculate that it is related to the number of nesting of 「.then」.Please suggest some solutions, thank you very much
Link to reproduction
The code is relatively simple to reproduce,code repository is no longer provided
Check List
Please do not ask questions in issues.
Please include a minimal reproduction.
Please check this if you're filing an issue regarding TypeScript.
createis to be used ascreate<T>()(...)and notcreate<T>(...).Beta Was this translation helpful? Give feedback.
All reactions