Skip to content

Commit d497750

Browse files
committed
system store - reduce load time (part of performance effort 4.20)
Signed-off-by: Amit Prinz Setter <[email protected]>
1 parent 704e34d commit d497750

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ config.ROOT_KEY_MOUNT = '/etc/noobaa-server/root_keys';
235235

236236
config.DB_TYPE = /** @type {nb.DBType} */ (process.env.DB_TYPE || 'postgres');
237237

238-
config.POSTGRES_DEFAULT_MAX_CLIENTS = 10;
239-
config.POSTGRES_MD_MAX_CLIENTS = (process.env.LOCAL_MD_SERVER === 'true') ? 70 : 10;
238+
config.POSTGRES_DEFAULT_MAX_CLIENTS = 5;
239+
config.POSTGRES_MD_MAX_CLIENTS = (process.env.LOCAL_MD_SERVER === 'true') ? 70 : 5;
240240

241241
///////////////////
242242
// SYSTEM CONFIG //

src/server/bg_services/md_aggregator.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ async function run_md_aggregator(md_store, system_store, target_now, delay) {
6868
});
6969
if (changes) {
7070
const update = _.omit(changes, 'more_updates');
71-
await system_store.make_changes({ update });
71+
await system_store.make_changes({ update }, false);
7272
update_range = !changes.more_updates;
7373
if (update_range) {
7474
await system_store.make_changes({
@@ -78,7 +78,7 @@ async function run_md_aggregator(md_store, system_store, target_now, delay) {
7878
global_last_update: range.till_time,
7979
}]
8080
}
81-
});
81+
}, false);
8282
}
8383
await P.delay(delay);
8484
} else {
@@ -206,7 +206,7 @@ function find_next_range({
206206
},
207207
}))
208208
}
209-
});
209+
}, false);
210210
}
211211

212212
// on normal operation the time_diff to close can be closed within a single MD_AGGREGATOR_INTERVAL

src/server/system_services/system_store.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,17 +394,21 @@ class SystemStore extends EventEmitter {
394394
if (this.data) {
395395
load_time = this.data.time;
396396
}
397+
let res;
397398
const since_load = Date.now() - load_time;
398399
if (since_load < this.START_REFRESH_THRESHOLD) {
399-
return this.data;
400+
res = this.data;
400401
} else if (since_load < this.FORCE_REFRESH_THRESHOLD) {
401402
dbg.warn(`system_store.refresh: system_store.data.time > START_REFRESH_THRESHOLD, since_load = ${since_load}, START_REFRESH_THRESHOLD = ${this.START_REFRESH_THRESHOLD}`);
402403
this.load().catch(_.noop);
403-
return this.data;
404+
res = this.data;
404405
} else {
405406
dbg.warn(`system_store.refresh: system_store.data.time > FORCE_REFRESH_THRESHOLD, since_load = ${since_load}, FORCE_REFRESH_THRESHOLD = ${this.FORCE_REFRESH_THRESHOLD}`);
406-
return this.load();
407+
res = this.load();
407408
}
409+
//call refresh periodically
410+
P.delay_unblocking(this.START_REFRESH_THRESHOLD).then(this.refresh);
411+
return res;
408412
}
409413

410414
async load(since) {

0 commit comments

Comments
 (0)