From af3258dc79488b73435819e7799eb1515f15a6aa Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 2 Jul 2023 16:02:32 +0900 Subject: [PATCH] perf(backend): make some features optionable Resolve #11064 Resolve #11065 --- CHANGELOG.md | 4 ++++ locales/index.d.ts | 2 ++ locales/ja-JP.yml | 2 ++ packages/backend/assets/avatar.png | Bin 0 -> 13477 bytes .../1688280713783-add-meta-options.js | 13 ++++++++++++ .../backend/src/daemons/ServerStatsService.ts | 12 ++++++++--- packages/backend/src/models/entities/Meta.ts | 10 +++++++++ packages/backend/src/server/ServerService.ts | 15 ++++++++++---- .../src/server/api/endpoints/admin/meta.ts | 10 +++++++++ .../server/api/endpoints/admin/update-meta.ts | 10 +++++++++ .../src/server/api/endpoints/server-info.ts | 19 ++++++++++++++++++ .../src/pages/admin/other-settings.vue | 14 +++++++++++++ .../src/widgets/server-metric/index.vue | 2 +- 13 files changed, 105 insertions(+), 8 deletions(-) create mode 100644 packages/backend/assets/avatar.png create mode 100644 packages/backend/migration/1688280713783-add-meta-options.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 681105fb7..72c4f53d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ ## 13.x.x (unreleased) +### General +- identicon生成を無効にしてパフォーマンスを向上させることができるようになりました +- サーバーのマシン情報の公開を無効にしてパフォーマンスを向上させることができるようになりました + ### Client - Fix: サーバーメトリクスが90度傾いている diff --git a/locales/index.d.ts b/locales/index.d.ts index eed29f408..af6b80327 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -1066,6 +1066,8 @@ export interface Locale { "additionalEmojiDictionary": string; "installed": string; "branding": string; + "enableServerMachineStats": string; + "enableIdenticonGeneration": string; "_initialAccountSetting": { "accountCreated": string; "letsStartAccountSetup": string; diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 8004e5357..e7202bfbb 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1063,6 +1063,8 @@ goToMisskey: "Misskeyへ" additionalEmojiDictionary: "絵文字の追加辞書" installed: "インストール済み" branding: "ブランディング" +enableServerMachineStats: "サーバーのマシン情報を公開する" +enableIdenticonGeneration: "ユーザーごとのIdenticon生成を有効にする" _initialAccountSetting: accountCreated: "アカウントの作成が完了しました!" diff --git a/packages/backend/assets/avatar.png b/packages/backend/assets/avatar.png new file mode 100644 index 0000000000000000000000000000000000000000..1b95a0c560c32cf2a0060d9e911b1cc3171dfaba GIT binary patch literal 13477 zcmajGbzGdyvMr2TaM$1j9bj;Gcb7oW0S0#q?iSqLB@o=*CAbH7C%6asc;CJ6-sgP# zoO}Nm>1S1~s$SJy^Lu7`!j%=JP>=|bARr)6WTeGa-(UUydLTf(Kg;XgWkNu}G=bH% zowXI@c}?tW07j;E#vp*Zjr}_g0l_ciZf|5_1#%`c2AP9x1t`wjx+uuNrUDdN911K7 z_F^Clu(YQmNX=7G-Ne(%gvXRZNDztNo%fx<2IOo+=5Awc>%{9WK=C&(@B90|E;Cb* z{cYlGB|xFApiCxa=LjO>0B`_UCefcDCnbW_ELP1GupP z>>SORS$TMPm|1|#Kp@k*1(TD9t+SCkldTiwUljk~5C=J#ID+k+!FIM}e{mWa+qpOk zP*A+%Wd9@wxr6`BZtL{V>AwrX{1?K^3SeRWujbBRv;W2XFXTVW?Jew_?VK#^?Ef`^ z{}$q3@P9bI%lALKxEtC3PsR!g|95j6oBuWqCua%QcOm{M>VM1W{{(PS_pk>stAd>D zTpUe660RUyXUe~o_)8aFWw1NQT3Z}!1G05`S66_770CVnLv{W)RLsuW&Qa}sS%Kc& z{&xCHJ6;(ZBXf`z*woqL-)#Q|9U7A__hpgJoDFFO}62PXpy4=)SL-^_nozwZZABWI)km;GO> znvDP5LqUO88tmk3=jieGrGG4SHITzUM*kREga2ORWMqF=n%BtWFOdW&>>ce)T}(ix ze+Pf3`v>Y|XXfl?-O0@Y^iKG{ zPmlSZ$ua-6@%~SC{LKH6KmXqb|7EAX`~BnEdk1)LCCvZo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zFD1rnMDvA~yW4w|$s{q=RBH*x4Abql>a{7%E5$dRdI6(+{g48IrUkvHL4M}N_(93=);I-ud z>a1sOEOLZ6ut1R?9!50XeDRvRHkDo)FX?uCY=r*mfRjCwM@(K=h(rXve{uXlxI!_a zi5Bt{Oc83EDw%v$4W+U*kt#_q&{D_zGO*+u&F*NbvStv zvf2yHMpLviP-(1pYRGBbqRgr{|}U&QN#cM literal 0 HcmV?d00001 diff --git a/packages/backend/migration/1688280713783-add-meta-options.js b/packages/backend/migration/1688280713783-add-meta-options.js new file mode 100644 index 000000000..12406fe08 --- /dev/null +++ b/packages/backend/migration/1688280713783-add-meta-options.js @@ -0,0 +1,13 @@ +export class AddMetaOptions1688280713783 { + name = 'AddMetaOptions1688280713783' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "meta" ADD "enableServerMachineStats" boolean NOT NULL DEFAULT false`); + await queryRunner.query(`ALTER TABLE "meta" ADD "enableIdenticonGeneration" boolean NOT NULL DEFAULT true`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "enableIdenticonGeneration"`); + await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "enableServerMachineStats"`); + } +} diff --git a/packages/backend/src/daemons/ServerStatsService.ts b/packages/backend/src/daemons/ServerStatsService.ts index 6cd71c0e2..375fd5e51 100644 --- a/packages/backend/src/daemons/ServerStatsService.ts +++ b/packages/backend/src/daemons/ServerStatsService.ts @@ -3,6 +3,7 @@ import si from 'systeminformation'; import Xev from 'xev'; import * as osUtils from 'os-utils'; import { bindThis } from '@/decorators.js'; +import { MetaService } from '@/core/MetaService.js'; import type { OnApplicationShutdown } from '@nestjs/common'; const ev = new Xev(); @@ -14,9 +15,10 @@ const round = (num: number) => Math.round(num * 10) / 10; @Injectable() export class ServerStatsService implements OnApplicationShutdown { - private intervalId: NodeJS.Timer; + private intervalId: NodeJS.Timer | null = null; constructor( + private metaService: MetaService, ) { } @@ -24,7 +26,9 @@ export class ServerStatsService implements OnApplicationShutdown { * Report server stats regularly */ @bindThis - public start(): void { + public async start(): Promise { + if (!(await this.metaService.fetch(true)).enableServerMachineStats) return; + const log = [] as any[]; ev.on('requestServerStatsLog', x => { @@ -64,7 +68,9 @@ export class ServerStatsService implements OnApplicationShutdown { @bindThis public dispose(): void { - clearInterval(this.intervalId); + if (this.intervalId) { + clearInterval(this.intervalId); + } } @bindThis diff --git a/packages/backend/src/models/entities/Meta.ts b/packages/backend/src/models/entities/Meta.ts index f799551f3..a251c0b31 100644 --- a/packages/backend/src/models/entities/Meta.ts +++ b/packages/backend/src/models/entities/Meta.ts @@ -413,6 +413,16 @@ export class Meta { }) public enableChartsForFederatedInstances: boolean; + @Column('boolean', { + default: false, + }) + public enableServerMachineStats: boolean; + + @Column('boolean', { + default: true, + }) + public enableIdenticonGeneration: boolean; + @Column('jsonb', { default: { }, }) diff --git a/packages/backend/src/server/ServerService.ts b/packages/backend/src/server/ServerService.ts index c3d45e4ad..1bae71617 100644 --- a/packages/backend/src/server/ServerService.ts +++ b/packages/backend/src/server/ServerService.ts @@ -16,6 +16,7 @@ import { createTemp } from '@/misc/create-temp.js'; import { UserEntityService } from '@/core/entities/UserEntityService.js'; import { LoggerService } from '@/core/LoggerService.js'; import { bindThis } from '@/decorators.js'; +import { MetaService } from '@/core/MetaService.js'; import { ActivityPubServerService } from './ActivityPubServerService.js'; import { NodeinfoServerService } from './NodeinfoServerService.js'; import { ApiServerService } from './api/ApiServerService.js'; @@ -45,6 +46,7 @@ export class ServerService implements OnApplicationShutdown { @Inject(DI.emojisRepository) private emojisRepository: EmojisRepository, + private metaService: MetaService, private userEntityService: UserEntityService, private apiServerService: ApiServerService, private openApiServerService: OpenApiServerService, @@ -161,11 +163,16 @@ export class ServerService implements OnApplicationShutdown { }); fastify.get<{ Params: { x: string } }>('/identicon/:x', async (request, reply) => { - const [temp, cleanup] = await createTemp(); - await genIdenticon(request.params.x, fs.createWriteStream(temp)); reply.header('Content-Type', 'image/png'); reply.header('Cache-Control', 'public, max-age=86400'); - return fs.createReadStream(temp).on('close', () => cleanup()); + + if ((await this.metaService.fetch()).enableIdenticonGeneration) { + const [temp, cleanup] = await createTemp(); + await genIdenticon(request.params.x, fs.createWriteStream(temp)); + return fs.createReadStream(temp).on('close', () => cleanup()); + } else { + return reply.redirect('/static-assets/avatar.png'); + } }); fastify.get<{ Params: { code: string } }>('/verify-email/:code', async (request, reply) => { @@ -224,7 +231,7 @@ export class ServerService implements OnApplicationShutdown { @bindThis public async dispose(): Promise { - await this.streamingApiServerService.detach(); + await this.streamingApiServerService.detach(); await this.#fastify.close(); } diff --git a/packages/backend/src/server/api/endpoints/admin/meta.ts b/packages/backend/src/server/api/endpoints/admin/meta.ts index 4cc1b6011..28aec7a09 100644 --- a/packages/backend/src/server/api/endpoints/admin/meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/meta.ts @@ -262,6 +262,14 @@ export const meta = { type: 'boolean', optional: false, nullable: false, }, + enableServerMachineStats: { + type: 'boolean', + optional: false, nullable: false, + }, + enableIdenticonGeneration: { + type: 'boolean', + optional: false, nullable: false, + }, policies: { type: 'object', optional: false, nullable: false, @@ -364,6 +372,8 @@ export default class extends Endpoint { enableActiveEmailValidation: instance.enableActiveEmailValidation, enableChartsForRemoteUser: instance.enableChartsForRemoteUser, enableChartsForFederatedInstances: instance.enableChartsForFederatedInstances, + enableServerMachineStats: instance.enableServerMachineStats, + enableIdenticonGeneration: instance.enableIdenticonGeneration, policies: { ...DEFAULT_POLICIES, ...instance.policies }, }; }); diff --git a/packages/backend/src/server/api/endpoints/admin/update-meta.ts b/packages/backend/src/server/api/endpoints/admin/update-meta.ts index 1de5e9efd..5c9d8e3fa 100644 --- a/packages/backend/src/server/api/endpoints/admin/update-meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/update-meta.ts @@ -96,6 +96,8 @@ export const paramDef = { enableActiveEmailValidation: { type: 'boolean' }, enableChartsForRemoteUser: { type: 'boolean' }, enableChartsForFederatedInstances: { type: 'boolean' }, + enableServerMachineStats: { type: 'boolean' }, + enableIdenticonGeneration: { type: 'boolean' }, serverRules: { type: 'array', items: { type: 'string' } }, preservedUsernames: { type: 'array', items: { type: 'string' } }, }, @@ -399,6 +401,14 @@ export default class extends Endpoint { set.enableChartsForFederatedInstances = ps.enableChartsForFederatedInstances; } + if (ps.enableServerMachineStats !== undefined) { + set.enableServerMachineStats = ps.enableServerMachineStats; + } + + if (ps.enableIdenticonGeneration !== undefined) { + set.enableIdenticonGeneration = ps.enableIdenticonGeneration; + } + if (ps.serverRules !== undefined) { set.serverRules = ps.serverRules; } diff --git a/packages/backend/src/server/api/endpoints/server-info.ts b/packages/backend/src/server/api/endpoints/server-info.ts index 1620e8ae5..552441e43 100644 --- a/packages/backend/src/server/api/endpoints/server-info.ts +++ b/packages/backend/src/server/api/endpoints/server-info.ts @@ -2,9 +2,12 @@ import * as os from 'node:os'; import si from 'systeminformation'; import { Injectable } from '@nestjs/common'; import { Endpoint } from '@/server/api/endpoint-base.js'; +import { MetaService } from '@/core/MetaService.js'; export const meta = { requireCredential: false, + allowGet: true, + cacheSec: 60 * 1, tags: ['meta'], } as const; @@ -19,8 +22,24 @@ export const paramDef = { @Injectable() export default class extends Endpoint { constructor( + private metaService: MetaService, ) { super(meta, paramDef, async () => { + if (!(await this.metaService.fetch()).enableServerMachineStats) return { + machine: '?', + cpu: { + model: '?', + cores: 0, + }, + mem: { + total: 0, + }, + fs: { + total: 0, + used: 0, + }, + }; + const memStats = await si.mem(); const fsStats = await si.fsSize(); diff --git a/packages/frontend/src/pages/admin/other-settings.vue b/packages/frontend/src/pages/admin/other-settings.vue index 15d720a07..d3e1d9efc 100644 --- a/packages/frontend/src/pages/admin/other-settings.vue +++ b/packages/frontend/src/pages/admin/other-settings.vue @@ -4,6 +4,14 @@
+ + + + + + + + @@ -27,17 +35,23 @@ import { i18n } from '@/i18n'; import { definePageMetadata } from '@/scripts/page-metadata'; import MkSwitch from '@/components/MkSwitch.vue'; +let enableServerMachineStats: boolean = $ref(false); +let enableIdenticonGeneration: boolean = $ref(false); let enableChartsForRemoteUser: boolean = $ref(false); let enableChartsForFederatedInstances: boolean = $ref(false); async function init() { const meta = await os.api('admin/meta'); + enableServerMachineStats = meta.enableServerMachineStats; + enableIdenticonGeneration = meta.enableIdenticonGeneration; enableChartsForRemoteUser = meta.enableChartsForRemoteUser; enableChartsForFederatedInstances = meta.enableChartsForFederatedInstances; } function save() { os.apiWithDialog('admin/update-meta', { + enableServerMachineStats, + enableIdenticonGeneration, enableChartsForRemoteUser, enableChartsForFederatedInstances, }).then(() => { diff --git a/packages/frontend/src/widgets/server-metric/index.vue b/packages/frontend/src/widgets/server-metric/index.vue index e019ff540..1a78f4bcd 100644 --- a/packages/frontend/src/widgets/server-metric/index.vue +++ b/packages/frontend/src/widgets/server-metric/index.vue @@ -62,7 +62,7 @@ const { widgetProps, configure, save } = useWidgetPropsManager(name, const meta = ref(null); -os.api('server-info', {}).then(res => { +os.apiGet('server-info', {}).then(res => { meta.value = res; });