perf: Remove "process" queue stat counter for performance (MisskeyIO#325)
This commit is contained in:
parent
397e056b1e
commit
9449218049
@ -9,7 +9,6 @@ import { QueueProcessorService } from '@/queue/QueueProcessorService.js';
|
|||||||
import { NestLogger } from '@/NestLogger.js';
|
import { NestLogger } from '@/NestLogger.js';
|
||||||
import { QueueProcessorModule } from '@/queue/QueueProcessorModule.js';
|
import { QueueProcessorModule } from '@/queue/QueueProcessorModule.js';
|
||||||
import { QueueStatsService } from '@/daemons/QueueStatsService.js';
|
import { QueueStatsService } from '@/daemons/QueueStatsService.js';
|
||||||
import { ServerStatsService } from '@/daemons/ServerStatsService.js';
|
|
||||||
import { ServerService } from '@/server/ServerService.js';
|
import { ServerService } from '@/server/ServerService.js';
|
||||||
import { MainModule } from '@/MainModule.js';
|
import { MainModule } from '@/MainModule.js';
|
||||||
|
|
||||||
@ -24,8 +23,7 @@ export async function server() {
|
|||||||
|
|
||||||
if (process.env.NODE_ENV !== 'test') {
|
if (process.env.NODE_ENV !== 'test') {
|
||||||
app.get(ChartManagementService).start();
|
app.get(ChartManagementService).start();
|
||||||
// app.get(QueueStatsService).start();
|
app.get(QueueStatsService).start();
|
||||||
// app.get(ServerStatsService).start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
|
@ -34,24 +34,8 @@ export class QueueStatsService implements OnApplicationShutdown {
|
|||||||
*/
|
*/
|
||||||
@bindThis
|
@bindThis
|
||||||
public start(): void {
|
public start(): void {
|
||||||
const log = [] as any[];
|
|
||||||
|
|
||||||
ev.on('requestQueueStatsLog', x => {
|
ev.on('requestQueueStatsLog', x => {
|
||||||
ev.emit(`queueStatsLog:${x.id}`, log.slice(0, x.length ?? 50));
|
ev.emit(`queueStatsLog:${x.id}`, []);
|
||||||
});
|
|
||||||
|
|
||||||
let activeDeliverJobs = 0;
|
|
||||||
let activeInboxJobs = 0;
|
|
||||||
|
|
||||||
const deliverQueueEvents = new Bull.QueueEvents(QUEUE.DELIVER, baseQueueOptions(this.config.redisForDeliverQueue, this.config.bullmqQueueOptions, QUEUE.DELIVER));
|
|
||||||
const inboxQueueEvents = new Bull.QueueEvents(QUEUE.INBOX, baseQueueOptions(this.config.redisForInboxQueue, this.config.bullmqQueueOptions, QUEUE.INBOX));
|
|
||||||
|
|
||||||
deliverQueueEvents.on('active', () => {
|
|
||||||
activeDeliverJobs++;
|
|
||||||
});
|
|
||||||
|
|
||||||
inboxQueueEvents.on('active', () => {
|
|
||||||
activeInboxJobs++;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const tick = async () => {
|
const tick = async () => {
|
||||||
@ -60,13 +44,13 @@ export class QueueStatsService implements OnApplicationShutdown {
|
|||||||
|
|
||||||
const stats = {
|
const stats = {
|
||||||
deliver: {
|
deliver: {
|
||||||
activeSincePrevTick: activeDeliverJobs,
|
activeSincePrevTick: 0, // it's removed for performance reason
|
||||||
active: deliverJobCounts.active,
|
active: deliverJobCounts.active,
|
||||||
waiting: deliverJobCounts.waiting,
|
waiting: deliverJobCounts.waiting,
|
||||||
delayed: deliverJobCounts.delayed,
|
delayed: deliverJobCounts.delayed,
|
||||||
},
|
},
|
||||||
inbox: {
|
inbox: {
|
||||||
activeSincePrevTick: activeInboxJobs,
|
activeSincePrevTick: 0, // it's removed for performance reason
|
||||||
active: inboxJobCounts.active,
|
active: inboxJobCounts.active,
|
||||||
waiting: inboxJobCounts.waiting,
|
waiting: inboxJobCounts.waiting,
|
||||||
delayed: inboxJobCounts.delayed,
|
delayed: inboxJobCounts.delayed,
|
||||||
@ -74,12 +58,6 @@ export class QueueStatsService implements OnApplicationShutdown {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ev.emit('queueStats', stats);
|
ev.emit('queueStats', stats);
|
||||||
|
|
||||||
log.unshift(stats);
|
|
||||||
if (log.length > 200) log.pop();
|
|
||||||
|
|
||||||
activeDeliverJobs = 0;
|
|
||||||
activeInboxJobs = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
tick();
|
tick();
|
||||||
|
Loading…
Reference in New Issue
Block a user