-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ui] Fix endless log loading (#26446)
## Summary & Motivation We received a bug report from an org with some very, very long log output on some of their runs. Specifically, hundreds of thousands of large logs for individual runs. I noticed two issues during testing: - When a chunk of logs loads and indicates that there are more older logs left to stream, we consider that a "loading" state and simply don't show any logs in the logs table at all. - This is unnecessary, since we're streaming logs in. Instead, just show the loading state if there are no logs available yet at all. - First, we're using the spread-to-concat antipattern in the subscription handler reducer, which means iterating over the entire existing list of nodes before adding the newly received logs. - To resolve this, I'm changing the state array to track *chunks* of logs instead of flattened logs. This means we can more efficiently push chunks into state without mutating state or taking the time to copy entire chunks, then flatten them as needed for filtering/rendering. - I used `[].concat(...chunks)` as the flattening approach, based on benchmarking. it seems to be faster than `flat()`. ## How I Tested These Changes View run with neverending log loading. Verify that logs appear and stream in. Use Chrome profiler to determine that the chunking and flattening behavior appears to be performant at scale. The `filterLogs` function remains expensive, but I think in this case it's because the logs themselves are enormous and require a ton of JSON stringification to support text searching. ## Changelog [ui] Fix run log streaming for runs with a large volume of logs.
- Loading branch information
Showing
6 changed files
with
45 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
js_modules/dagster-ui/packages/ui-core/src/util/flattenOneLevel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* Flattens a two-dimensional array into a one-dimensional array. | ||
* | ||
* @param nodeChunks - The two-dimensional array to flatten. | ||
* @returns The flattened one-dimensional array. | ||
*/ | ||
// https://jsbench.me/o8kqzo8olz/1 | ||
export function flattenOneLevel<T>(arrays: T[][]) { | ||
return ([] as T[]).concat(...arrays); | ||
} |
279d44a
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.
Deploy preview for dagit-core-storybook ready!
✅ Preview
https://dagit-core-storybook-kd2jk9p2p-elementl.vercel.app
Built with commit 279d44a.
This pull request is being automatically deployed with vercel-action