-
Notifications
You must be signed in to change notification settings - Fork 310
perf: optimize memory usage in denoised-rows query by conditionally including processedRows #1177
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@hyperdx/app": patch | ||
--- | ||
|
||
Improve memory efficiency in high row cound envs |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ import cx from 'classnames'; | |
import { format, formatDistance } from 'date-fns'; | ||
import { isString } from 'lodash'; | ||
import curry from 'lodash/curry'; | ||
import ms from 'ms'; | ||
import { useHotkeys } from 'react-hotkeys-hook'; | ||
import { | ||
Bar, | ||
|
@@ -1267,11 +1268,18 @@ function DBSqlRowTableComponent({ | |
queryKey: [ | ||
'denoised-rows', | ||
config, | ||
processedRows, | ||
denoiseResults, | ||
// Only include processed rows if denoising is enabled | ||
// This helps prevent the queryKey from getting extremely large | ||
// and causing memory issues, when it's not used. | ||
...(denoiseResults ? [processedRows] : []), | ||
Comment on lines
+1271
to
+1275
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perf nit: Instead of passing all the rows, one idea is to generate an ID for processedRows. For example, we can take a fixed step to sample the rows and then compute a hash from those samples There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah good idea, I spent a large portion of time messing around with their Let me take a look at this next week when I get back from vacation! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we don't need to go too deep down optimizing this path - my preference is if scaling issues continue to come up for this feature, we re-evaluate pushing down denoising into the clickhouse query itself as opposed to incremental improvements to the current implementation. |
||
noisyPatternIds, | ||
patternColumn, | ||
], | ||
queryFn: async () => { | ||
if (!denoiseResults) { | ||
return []; | ||
} | ||
// No noisy patterns, so no need to denoise | ||
if (noisyPatternIds.length === 0) { | ||
return processedRows; | ||
|
@@ -1295,6 +1303,7 @@ function DBSqlRowTableComponent({ | |
} | ||
return undefined; | ||
}, | ||
gcTime: isLive ? ms('30s') : ms('5m'), // more aggressive gc for live data, since it can end up holding lots of data | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh this is neat. theoretically we don't need to keep the old page if live tail is enabled |
||
enabled: | ||
denoiseResults && | ||
noisyPatterns.isSuccess && | ||
|
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.
I’m scratching my head as to why this is relevant. even if denoise is disabled, react-query still tries to cache the key that blows up the memory?
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.
Yeah, exactly!
You'd think the
enabled
flag being false would turn all this off, I can file a bug in the tanstack query library when I get back from vacation (and see if one already exists) if we want to help provide feedback.