graph-reducer: ignore superfluous updates

Reduces RAM usage drastically, especially in long-lived sessions
This commit is contained in:
Liam Fitzgerald 2021-05-18 12:33:43 +10:00
parent e5514b1386
commit e8091f9da1
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB
2 changed files with 10 additions and 3 deletions

View File

@ -328,6 +328,7 @@ export default class GraphApi extends BaseApi<StoreState> {
async getNewest(ship: string, resource: string, count: number, index = '') {
const data = await this.scry<any>('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<StoreState> {
const idx = index.split('/').map(decToUd).join('/');
const data = await this.scry<any>('graph-store',
`/node-siblings/older/${ship}/${resource}/${count}${idx}`
);
);
this.store.handleEvent({ data });
}

View File

@ -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] = {};
}