finalize sql incrememntation batching
This commit is contained in:
parent
dc01b994e7
commit
105b7ab76d
|
@ -206,7 +206,7 @@ export async function drawByOffsets(
|
||||||
}
|
}
|
||||||
|
|
||||||
const duration = Date.now() - startTime;
|
const duration = Date.now() - startTime;
|
||||||
if (duration > 2000) {
|
if (duration > 3000) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
`Long response time of ${duration}ms for placing ${pxlCnt} pixels for user ${user.id || user.ip}`,
|
`Long response time of ${duration}ms for placing ${pxlCnt} pixels for user ${user.id || user.ip}`,
|
||||||
|
|
|
@ -210,7 +210,6 @@ export async function getNamesToIds(ids) {
|
||||||
*/
|
*/
|
||||||
const incrementQueue = [];
|
const incrementQueue = [];
|
||||||
let pushLoop = null;
|
let pushLoop = null;
|
||||||
let lastLog = 0;
|
|
||||||
const incrementLoop = async () => {
|
const incrementLoop = async () => {
|
||||||
if (!incrementQueue.length) {
|
if (!incrementQueue.length) {
|
||||||
pushLoop = null;
|
pushLoop = null;
|
||||||
|
@ -248,14 +247,6 @@ const incrementLoop = async () => {
|
||||||
},
|
},
|
||||||
silent: true,
|
silent: true,
|
||||||
raw: 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) {
|
} catch (err) {
|
||||||
|
@ -267,11 +258,6 @@ const incrementLoop = async () => {
|
||||||
}
|
}
|
||||||
pushLoop = setTimeout(incrementLoop, 250);
|
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) {
|
export async function incrementPixelcount(user) {
|
||||||
incrementQueue.push(user);
|
incrementQueue.push(user);
|
||||||
if (!pushLoop) {
|
if (!pushLoop) {
|
||||||
|
|
|
@ -55,7 +55,7 @@ export default async (req, res, next) => {
|
||||||
const stime = Date.now();
|
const stime = Date.now();
|
||||||
chunk = await RedisCanvas.getChunk(c, x, y);
|
chunk = await RedisCanvas.getChunk(c, x, y);
|
||||||
const dur = Date.now() - stime;
|
const dur = Date.now() - stime;
|
||||||
if (dur > 2000) {
|
if (dur > 3000) {
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
logger.warn(`Long redis response times of ${dur}ms for chunk ${c}:${x},${y}`);
|
logger.warn(`Long redis response times of ${dur}ms for chunk ${c}:${x},${y}`);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user