From 105b7ab76d51c3b14e9a1c31caa6f352ab0c8d04 Mon Sep 17 00:00:00 2001 From: HF Date: Wed, 7 Sep 2022 18:43:32 +0200 Subject: [PATCH] finalize sql incrememntation batching --- src/core/draw.js | 2 +- src/data/sql/RegUser.js | 14 -------------- src/routes/chunks.js | 2 +- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/core/draw.js b/src/core/draw.js index 790e2ea..51ddb17 100644 --- a/src/core/draw.js +++ b/src/core/draw.js @@ -206,7 +206,7 @@ export async function drawByOffsets( } const duration = Date.now() - startTime; - if (duration > 2000) { + if (duration > 3000) { logger.warn( // eslint-disable-next-line max-len `Long response time of ${duration}ms for placing ${pxlCnt} pixels for user ${user.id || user.ip}`, diff --git a/src/data/sql/RegUser.js b/src/data/sql/RegUser.js index e367a87..e87be0e 100644 --- a/src/data/sql/RegUser.js +++ b/src/data/sql/RegUser.js @@ -210,7 +210,6 @@ export async function getNamesToIds(ids) { */ const incrementQueue = []; let pushLoop = null; -let lastLog = 0; const incrementLoop = async () => { if (!incrementQueue.length) { pushLoop = null; @@ -248,14 +247,6 @@ const incrementLoop = async () => { }, silent: true, raw: true, - // TODO: remove this after testing - logging: (msg) => { - const now = Date.now(); - if (now - 5000 > lastLog) { - lastLog = now; - logger.warn(msg); - } - }, }); } } catch (err) { @@ -267,11 +258,6 @@ const incrementLoop = async () => { } pushLoop = setTimeout(incrementLoop, 250); }; -// TODO remove this after testing -setInterval(() => { - // eslint-disable-next-line no-console - console.log('INCREMENTATION QUEUE SIZE', incrementQueue.length, pushLoop); -}, 300000); export async function incrementPixelcount(user) { incrementQueue.push(user); if (!pushLoop) { diff --git a/src/routes/chunks.js b/src/routes/chunks.js index 10623ac..3f2ea6d 100644 --- a/src/routes/chunks.js +++ b/src/routes/chunks.js @@ -55,7 +55,7 @@ export default async (req, res, next) => { const stime = Date.now(); chunk = await RedisCanvas.getChunk(c, x, y); const dur = Date.now() - stime; - if (dur > 2000) { + if (dur > 3000) { // eslint-disable-next-line max-len logger.warn(`Long redis response times of ${dur}ms for chunk ${c}:${x},${y}`); }