-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[ML] AIOps: Reduces rerenders when streaming analysis results #182793
[ML] AIOps: Reduces rerenders when streaming analysis results #182793
Conversation
Pinging @elastic/ml-ui (:ml) |
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
History
To update your PR or re-run it, just comment with: cc @walterra |
Code LGTM 🎉 |
if (effectState.isActive) { | ||
updateData(); | ||
} | ||
}, DATA_THROTTLE_MS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the consumer of this useFetchStream
hook also have the ability to pass in the duration they want to throttle? Not necessary for this PR but would be nice to have in a follow up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the improvement!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ⚡
Summary
Part of #181111.
Improves the
@kbn/ml-response-stream
package to trigger less rerendering.streamFactory()
. Instead of an function overload to handle the different stream types (plain string or NDJSON based), a conditional type is now used to handle both types within the same function.useFetchStream()
was improved. PreviouslyuseReducer
could cause a lot of rerenders, even with theuseThrottle
we had in place. We now use aref
instead that holds intermediate state without causing rerenders and update the "real" state periodically while the the stream is running. For the Kibana Sample Logs dataset this bring down rerenders from ~16 to ~7. Thepgbench
dataset comes down from ~20 to ~11.useThrottle
and a special way to accept arrays of actions within reducers. This is a bit non-standard compared to redux reducers. Allowing arrays of actions is now no longer necessary with the improved rerendering so its support was removed.StreamResponseWithHeaders
to simplify the types a bit.Checklist