From e8091f9da107d72c1fd59eba1d2c7ba1bc9baae9 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Tue, 18 May 2021 12:33:43 +1000 Subject: [PATCH 1/3] graph-reducer: ignore superfluous updates Reduces RAM usage drastically, especially in long-lived sessions --- pkg/interface/src/logic/api/graph.ts | 3 ++- pkg/interface/src/logic/reducers/graph-update.ts | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/interface/src/logic/api/graph.ts b/pkg/interface/src/logic/api/graph.ts index 12fffce3a..15aecdc61 100644 --- a/pkg/interface/src/logic/api/graph.ts +++ b/pkg/interface/src/logic/api/graph.ts @@ -328,6 +328,7 @@ export default class GraphApi extends BaseApi { async getNewest(ship: string, resource: string, count: number, index = '') { const data = await this.scry('graph-store', `/newest/${ship}/${resource}/${count}${index}`); + data['graph-update'].fetch = true; this.store.handleEvent({ data }); } @@ -335,7 +336,7 @@ export default class GraphApi extends BaseApi { const idx = index.split('/').map(decToUd).join('/'); const data = await this.scry('graph-store', `/node-siblings/older/${ship}/${resource}/${count}${idx}` - ); + ); this.store.handleEvent({ data }); } diff --git a/pkg/interface/src/logic/reducers/graph-update.ts b/pkg/interface/src/logic/reducers/graph-update.ts index 3b15bc56f..b9e8f85ba 100644 --- a/pkg/interface/src/logic/reducers/graph-update.ts +++ b/pkg/interface/src/logic/reducers/graph-update.ts @@ -180,9 +180,15 @@ const addNodes = (json, state) => { const resource = data.resource.ship + '/' + data.resource.name; if (!(resource in state.graphs)) { - state.graphs[resource] = new BigIntOrderedMap(); + if(json.fetch) { + state.graphs[resource] = new BigIntOrderedMap(); + } else { + // ignore updates until we load backlog deliberately, to avoid + // unnecessary memory usage + return state; + } } - + if (!(resource in state.graphTimesentMap)) { state.graphTimesentMap[resource] = {}; } From 22214112205127eef9cdc2265f9730b59c601625 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Tue, 18 May 2021 12:36:46 +1000 Subject: [PATCH 2/3] GroupSwitcher: update recent groups on unmount Fixes an unfiled bug where switching to a non-group workspace would not add the most recent group to the group switcher --- .../src/views/landscape/components/GroupSwitcher.tsx | 2 +- pkg/interface/src/views/landscape/components/GroupsPane.tsx | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/interface/src/views/landscape/components/GroupSwitcher.tsx b/pkg/interface/src/views/landscape/components/GroupSwitcher.tsx index 3d7750eda..e36647915 100644 --- a/pkg/interface/src/views/landscape/components/GroupSwitcher.tsx +++ b/pkg/interface/src/views/landscape/components/GroupSwitcher.tsx @@ -43,7 +43,7 @@ function RecentGroups(props: { recent: string[] }) { {props.recent.filter((e) => { return (e in associations?.groups); - }).slice(1, 5).map((g) => { + }).slice(0, 4).map((g) => { const assoc = associations.groups[g]; const color = uxToHex(assoc?.metadata?.color || '0x0'); return ( diff --git a/pkg/interface/src/views/landscape/components/GroupsPane.tsx b/pkg/interface/src/views/landscape/components/GroupsPane.tsx index e33579da3..b47c83bc6 100644 --- a/pkg/interface/src/views/landscape/components/GroupsPane.tsx +++ b/pkg/interface/src/views/landscape/components/GroupsPane.tsx @@ -53,7 +53,9 @@ export function GroupsPane(props: GroupsPaneProps) { if (workspace.type !== 'group') { return; } - setRecentGroups(gs => _.uniq([workspace.group, ...gs])); + return () => { + setRecentGroups(gs => _.uniq([workspace.group, ...gs])); + } }, [workspace]); if (!(associations && (groupPath ? groupPath in groups : true))) { From 0e9a8590d8701ca6dbe5f735f9a11a8b6da99088 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Tue, 18 May 2021 12:38:21 +1000 Subject: [PATCH 3/3] Groups: fix keying --- pkg/interface/src/views/apps/launch/components/Groups.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/interface/src/views/apps/launch/components/Groups.tsx b/pkg/interface/src/views/apps/launch/components/Groups.tsx index 269a6544a..209a540dc 100644 --- a/pkg/interface/src/views/apps/launch/components/Groups.tsx +++ b/pkg/interface/src/views/apps/launch/components/Groups.tsx @@ -58,7 +58,7 @@ export default function Groups(props: GroupsProps & Parameters[0]) { const notCount = graphNotifications(path); return (