mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-07 02:07:43 +02:00
UBERF-4319: Performance changes (#4474)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
+32
-10
@@ -23,6 +23,7 @@ import core, {
|
||||
Doc,
|
||||
DocumentUpdate,
|
||||
MeasureMetricsContext,
|
||||
Metrics,
|
||||
Ref,
|
||||
TxOperations,
|
||||
WorkspaceId,
|
||||
@@ -170,13 +171,32 @@ export async function benchmark (
|
||||
|
||||
let running = false
|
||||
|
||||
function extract (metrics: Metrics, ...path: string[]): Metrics | null {
|
||||
let m = metrics
|
||||
for (const p of path) {
|
||||
let found = false
|
||||
for (const [k, v] of Object.entries(m.measurements)) {
|
||||
if (k.includes(p)) {
|
||||
m = v
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
let timer: any
|
||||
if (isMainThread) {
|
||||
timer = setInterval(() => {
|
||||
const st = Date.now()
|
||||
|
||||
try {
|
||||
void fetch(transactorUrl.replace('ws:/', 'http:/') + '/' + token)
|
||||
const fetchUrl = transactorUrl.replace('ws:/', 'http:/') + '/api/v1/statistics?token=' + token
|
||||
void fetch(fetchUrl)
|
||||
.then((res) => {
|
||||
void res
|
||||
.json()
|
||||
@@ -184,15 +204,17 @@ export async function benchmark (
|
||||
memUsed = json.statistics.memoryUsed
|
||||
memTotal = json.statistics.memoryTotal
|
||||
cpu = json.statistics.cpuUsage
|
||||
const r =
|
||||
json.metrics?.measurements?.client?.measurements?.handleRequest?.measurements?.call?.measurements?.[
|
||||
'find-all'
|
||||
]
|
||||
operations = r?.operations ?? 0
|
||||
requestTime = (r?.value ?? 0) / (((r?.operations as number) ?? 0) + 1)
|
||||
transfer =
|
||||
json.metrics?.measurements?.client?.measurements?.handleRequest?.measurements?.['#send-data']
|
||||
?.value ?? 0
|
||||
operations = 0
|
||||
requestTime = 0
|
||||
transfer = 0
|
||||
for (const w of workspaceId) {
|
||||
const r = extract(json.metrics as Metrics, w.name, 'client', 'handleRequest', 'process', 'find-all')
|
||||
operations += r?.operations ?? 0
|
||||
requestTime += (r?.value ?? 0) / (((r?.operations as number) ?? 0) + 1)
|
||||
|
||||
const tr = extract(json.metrics as Metrics, w.name, 'client', 'handleRequest', '#send-data')
|
||||
transfer += tr?.value ?? 0
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
|
||||
@@ -562,7 +562,7 @@ export function devTool (
|
||||
|
||||
program
|
||||
.command('benchmark')
|
||||
.description('clean archived spaces')
|
||||
.description('benchmark')
|
||||
.option('--from <from>', 'Min client count', '10')
|
||||
.option('--steps <steps>', 'Step with client count', '10')
|
||||
.option('--sleep <sleep>', 'Random Delay max between operations', '0')
|
||||
|
||||
Reference in New Issue
Block a user