Possible AsynchScheduler performance issue #7236
akaltar
started this conversation in
Report issues other than bug
Replies: 1 comment
-
I encountered with another performance issue when I was coding a script for crawling sth. |
Beta Was this translation helpful? Give feedback.
0 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.
-
Hello! I'm using
rxjs
in a big project throughredux-observable
, and in certain conditions we spend over ~5s in purerxjs
code without executing any of our own code.I believe I might have found the root cause for spending so much time "spinning wheels" in rxjs, and I might be able to come up with an optimization that could make things better, but I want to make sure this aligns with the way development is going.
First, here is a repo with a reproduction of the performance issue: https://github.com/akaltar/rxjs-perf-repro
I think the issue might be in the way the looping is done over the actions in
AsyncScheduler.ts:flush
I'm not very familiar with how rxjs works, but I think replacing the loop with a simple for-loop, and adding a fast-path to removing the action from the parent
actions
array could speed things up a lot wihtout breaking things.Maybe by not trying to remove
this
from theactions
array at all, since at that point inflush
it was already removed byshift
, in the for-loop scenario, we could maybe just clean up the actions by assigning a fresh empty array after executing. Should be a non-breaking change and gain quite a bit of performanceI think further gains could be had if actions were stored in a
Map
, but that would be a much bigger change. (A bit like #7234 just for AsyncScheduler)In either case I'm happy to put together a PR if you don't see any fundamental issues with these suggestions
Beta Was this translation helpful? Give feedback.
All reactions