GitNexus/gitnexus/bench/method-declaration-facts/scaling.mjs
Gergő Magyar c417ccfc81
Some checks are pending
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
Gitleaks / gitleaks (push) Waiting to run
Publish / Classify release event (push) Waiting to run
Publish / RC guard (marker + release-PR skip) (push) Blocked by required conditions
Publish / ci (push) Blocked by required conditions
Publish / Publish to npm (push) Blocked by required conditions
Publish / Build & Push RC Docker images (push) Blocked by required conditions
Scorecard / Scorecard analysis (push) Waiting to run
Trivy Image Scan / Trivy (gitnexus-cli) (push) Waiting to run
Trivy Image Scan / Trivy (gitnexus-web) (push) Waiting to run
perf(ingestion): reduce indexing overhead and declaration memory (#3726)
* refactor(ingestion): share callable declaration facts

Reuse pure parameter and signature facts between structure and scope
extraction, with tree-owned caches and read-only parameter contracts.
Preserve provider-specific wrappers and consumer projections.

Add characterization tests, real-worker parity checks, and reproducible
performance measurements. Keep the overall indexing effect explicit.

Refs #3723

* fix(bench): create result files exclusively

Address CodeQL review feedback on #3726. Use a private default directory and an exclusive file handle so existing files and symlinks cannot be overwritten.

* perf: speed analyzer identity guard probes

* perf(ingestion): reuse callable type and overload facts

* ci: retain callable time and memory benchmarks

* chore: use established CI performance measurements

* fix(bench): check callable baseline in CI

* perf(ingestion): guard callable scaling and reuse export checks

* fix(ci): budget for callable scaling matrix

* refactor(ingestion): simplify callable handling

---------

Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com>
2026-10-26 15:13:48 +00:00

28 lines
1.1 KiB
JavaScript

import assert from 'node:assert/strict';
export function evaluateScaling(rows, metrics) {
const budget = 1.5;
assert(rows.length >= 2 && metrics.length > 0, 'Scaling needs sizes and metrics');
for (const [index, row] of rows.entries()) {
assert(Number.isFinite(row.size) && row.size > 0, 'Invalid workload size');
if (index) assert(row.size > rows[index - 1].size, 'Sizes must increase');
for (const metric of metrics)
assert(Number.isFinite(row[metric]) && row[metric] > 0, `Invalid ${metric}`);
}
const pairs = rows.slice(1).map((row, index) => [rows[index], row]);
if (rows.length > 2) pairs.push([rows[0], rows.at(-1)]);
const comparisons = pairs.map(([small, large]) => {
const inputRatio = large.size / small.size;
const ratios = Object.fromEntries(
metrics.map((metric) => [metric, large[metric] / small[metric] / inputRatio]),
);
return {
from: small.size,
to: large.size,
inputRatio,
ratios,
passed: Object.values(ratios).every((ratio) => ratio <= budget),
};
});
return { budget, comparisons, passed: comparisons.every((row) => row.passed) };
}