Skip to content

Commit

Permalink
data-lake-monitor: Only listen to variables being displayed in the table
Browse files Browse the repository at this point in the history
Otherwise we are setting listeners to all variables in the lake, which will usually be 300+, and this will trigger a lot of unnecessary screen updates and resource usage, which can slow down the application while this menu is open.
  • Loading branch information
rafaellehmkuhl committed Feb 4, 2025
1 parent 89dd5e5 commit b005c86
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/views/ToolsDataLakeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
{ title: 'Current Value', align: 'start', key: 'value', width: '220px', fixed: true },
]"
:header-props="{ style: { backgroundColor: 'rgba(0, 0, 0, 0.1)' } }"
@update:current-items="(currentItems) => updateListOfActiveVariables(currentItems)"
>
<template #item="{ item }">
<tr>
Expand Down Expand Up @@ -139,17 +140,19 @@ const currentValues = ref<Record<string, string | number | boolean | undefined>>
const listeners = ref<Record<string, string>>({})
let dataLakeVariableInfoListenerId: string | undefined
const setupVariableListeners = (): void => {
const setupVariableListeners = (idsVariablesToListen?: string[]): void => {
cleanupVariableListeners()
availableDataLakeVariables.value.forEach((variable) => {
currentValues.value[variable.id] = getDataLakeVariableData(variable.id)
idsVariablesToListen = idsVariablesToListen ?? availableDataLakeVariables.value.map((v) => v.id)
const listenerId = listenDataLakeVariable(variable.id, (value) => {
currentValues.value[variable.id] = value
idsVariablesToListen.forEach((variableId) => {
currentValues.value[variableId] = getDataLakeVariableData(variableId)
const listenerId = listenDataLakeVariable(variableId, (value) => {
currentValues.value[variableId] = value
})
listeners.value[variable.id] = listenerId
listeners.value[variableId] = listenerId
})
}
Expand Down Expand Up @@ -206,6 +209,12 @@ const filteredVariables = computed(() => {
})
return fuse.search(searchQuery.value).map((result) => result.item)
})
// Do not listen to variables that are not in the list, so we don't use unnecessary CPU/Memory resources
const updateListOfActiveVariables = (currentItems: DataLakeVariable[]): void => {
const currentItemsIds = currentItems.map((v) => v.key)
setupVariableListeners(currentItemsIds)
}
</script>

<style scoped>
Expand Down

0 comments on commit b005c86

Please sign in to comment.