mirror of
https://github.com/urbit/shrub.git
synced 2024-12-19 08:32:39 +03:00
graph-reducer: ignore superfluous updates
Reduces RAM usage drastically, especially in long-lived sessions
This commit is contained in:
parent
e5514b1386
commit
e8091f9da1
@ -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 });
|
||||
}
|
||||
|
||||
|
@ -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] = {};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user