mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-11-29 23:37:41 +00:00
* fix(lbug): bump @ladybugdb/core to 0.21.2 to stop doubled rows after delete and re-copy LadybugDB 0.21.0 and 0.21.1 return every row of a table that spans more than one native vector twice once the incremental writeback has DETACH DELETEd it and a COPY into an earlier table has run. NodeGroup::scan let a morsel that ended before the group's first live row wrap an unsigned subtraction and rescan to the end of the group (LadybugDB #1085, fixed in 0.21.2). No primary key error fires. The identity guard from #3442 stops the run with "unexpected or duplicate ID", so a Swift edit that pulls every importer into the write set failed on repos with more than 2048 structs. Only unreleased main was affected: 1.6.12 ships 0.18.3. Pin 0.21.2 in package.json, update the six @ladybugdb/core entries in the lockfile, and move coreVersion in the vendored FTS manifest. The FTS extension stays at 0.21.0 because no v0.21.1 or v0.21.2 artifact is published; the pairing assertion and its unit tests pass. Add a regression to the delete-nodes-for-files suite: 2049 structs with CONTAINS edges are loaded, every file is deleted, the graph is loaded again, and each id and edge must appear exactly once. Verification (Linux, Node 22.18): - lbug-delete-nodes-for-files: 11/11 on 0.21.2. With the 0.21.1 native packages swapped in, the new test fails with 4098 rows instead of 2049. - Reporter recipe end to end on the built CLI: incremental analyze exits 0 with no duplicate ids on a Swift-heavy fixture and on a 70-file Python fixture, with and without FTS. On 0.21.1 the Swift fixture exits 1. - A 0.21.1-written database opens and reads under 0.21.2. - prettier, eslint and typecheck:tests are clean on the changed files. - The full lbug-db project had not finished when this was committed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(lbug): pair core and extensions at 0.22.0 Include the duplicate-row scan and relationship page-padding fixes. Use matching official FTS and VECTOR artifacts on all five platforms. Add a page-padding regression and document the storage 47 to 49 upgrade, including rollback and cached-embedding recovery limits. * fix(lbug): recognize pending checkpoint recovery * fix(bench): isolate indexes by runtime * fix(query): reject mixed symbol paths Printable paths could disagree with canonical symbol UIDs and pass NUL-only validation. Reject those tuples at response boundaries. Add Python/Swift MCP fault cases and a linked-worktree reproducer. Refs #3527 * fix(query): preserve provider semantic IDs * fix(lbug): clear analysis memory budget Restore the normal reader budget after indexing. The leaked adaptive hint exhausted the 0.22.0 pool during query and rename operations. Assert the budget is restored after real analyses, and give integrity cases unique CI audit identities. --------- Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com> Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
193 lines
6.4 KiB
JavaScript
193 lines
6.4 KiB
JavaScript
import assert from 'node:assert/strict';
|
||
|
||
export function quantile(values, fraction) {
|
||
const sorted = [...values].sort((a, b) => a - b);
|
||
const position = (sorted.length - 1) * fraction;
|
||
const lo = Math.floor(position);
|
||
return sorted[lo] + (sorted[Math.ceil(position)] - sorted[lo]) * (position - lo);
|
||
}
|
||
|
||
/** Resample whole process pairs: requests in one process are not independent. */
|
||
export function compare(samples, { relative = 0.05, absolute = 5 } = {}) {
|
||
assert(samples.length > 0, 'Missing measurements');
|
||
const groups = new Map();
|
||
for (const row of samples) {
|
||
assert(Number.isInteger(row.session) && row.session >= 0, 'Invalid session');
|
||
assert(
|
||
[row.baseline, row.candidate].every((n) => Number.isFinite(n) && n > 0),
|
||
'Invalid measurement',
|
||
);
|
||
if (!groups.has(row.session)) groups.set(row.session, []);
|
||
groups.get(row.session).push(row);
|
||
}
|
||
const clusters = [...groups.values()];
|
||
const estimate = (rows) => ({
|
||
ratio: Math.exp(
|
||
rows.reduce((sum, r) => sum + Math.log(r.candidate / r.baseline), 0) / rows.length,
|
||
),
|
||
delta: rows.reduce((sum, r) => sum + r.candidate - r.baseline, 0) / rows.length,
|
||
});
|
||
let seed = 3728;
|
||
const random = () => (seed = (1664525 * seed + 1013904223) >>> 0) / 2 ** 32;
|
||
const resampled = Array.from({ length: 10000 }, () =>
|
||
estimate(clusters.flatMap(() => clusters[Math.floor(random() * clusters.length)])),
|
||
);
|
||
const ratioCi95 = [0.025, 0.975].map((p) =>
|
||
quantile(
|
||
resampled.map((r) => r.ratio),
|
||
p,
|
||
),
|
||
);
|
||
const deltaCi95 = [0.025, 0.975].map((p) =>
|
||
quantile(
|
||
resampled.map((r) => r.delta),
|
||
p,
|
||
),
|
||
);
|
||
return {
|
||
...estimate(samples),
|
||
pairs: samples.length,
|
||
sessions: clusters.length,
|
||
baselineMedian: quantile(
|
||
samples.map((r) => r.baseline),
|
||
0.5,
|
||
),
|
||
candidateMedian: quantile(
|
||
samples.map((r) => r.candidate),
|
||
0.5,
|
||
),
|
||
baselineP95: quantile(
|
||
samples.map((r) => r.baseline),
|
||
0.95,
|
||
),
|
||
candidateP95: quantile(
|
||
samples.map((r) => r.candidate),
|
||
0.95,
|
||
),
|
||
ratioCi95,
|
||
deltaCi95,
|
||
verdict:
|
||
clusters.length < 8
|
||
? 'insufficient-sessions'
|
||
: ratioCi95[0] > 1 + relative && deltaCi95[0] > absolute
|
||
? 'regression'
|
||
: ratioCi95[1] <= 1 + relative || deltaCi95[1] <= absolute
|
||
? 'within-threshold'
|
||
: 'inconclusive',
|
||
};
|
||
}
|
||
|
||
export function summarize(records, sessions, rounds, names) {
|
||
assert(
|
||
[sessions, rounds].every((n) => Number.isInteger(n) && n > 0),
|
||
'Invalid experiment size',
|
||
);
|
||
assert(names.length > 0 && new Set(names).size === names.length, 'Invalid workload list');
|
||
assert.equal(records.length, sessions * rounds, 'Incomplete measurement set');
|
||
const identities = new Set();
|
||
for (const record of records) {
|
||
assert(
|
||
Number.isInteger(record.session) &&
|
||
Number.isInteger(record.round) &&
|
||
record.session >= 0 &&
|
||
record.session < sessions &&
|
||
record.round >= 0 &&
|
||
record.round < rounds,
|
||
'Invalid sample identity',
|
||
);
|
||
const key = `${record.session}/${record.round}`;
|
||
assert(!identities.has(key), 'Duplicate sample');
|
||
identities.add(key);
|
||
for (const variant of ['baseline', 'candidate']) {
|
||
for (const name of names) assert(record[variant][name], `Missing ${variant}/${name}`);
|
||
}
|
||
}
|
||
const metrics = names.map((name) => ({
|
||
name,
|
||
...compare(
|
||
records.map((r) => ({
|
||
session: r.session,
|
||
baseline: r.baseline[name].ms,
|
||
candidate: r.candidate[name].ms,
|
||
})),
|
||
),
|
||
}));
|
||
for (const name of ['startup', 'first_query']) {
|
||
metrics.push({
|
||
name,
|
||
...compare(
|
||
records
|
||
.filter((r) => r.round === 0)
|
||
.map((r) => ({
|
||
session: r.session,
|
||
baseline: r.baseline[name].ms,
|
||
candidate: r.candidate[name].ms,
|
||
})),
|
||
),
|
||
});
|
||
}
|
||
return metrics;
|
||
}
|
||
|
||
export function formatReport(report) {
|
||
const percent = (r) => `${r >= 1 ? '+' : ''}${((r - 1) * 100).toFixed(1)}%`;
|
||
const table = report.metrics
|
||
.map(
|
||
(r) =>
|
||
`| ${r.name} | ${r.baselineMedian.toFixed(1)} → ${r.candidateMedian.toFixed(1)} | ${r.baselineP95.toFixed(1)} → ${r.candidateP95.toFixed(1)} | ${percent(r.ratio)} (${r.ratioCi95.map(percent).join(' to ')}) | ${r.verdict} |`,
|
||
)
|
||
.join('\n');
|
||
const resources = [
|
||
['cpuMs', 'Server CPU seconds', 1000],
|
||
['peakRssKiB', 'Server peak RSS MiB', 1024],
|
||
]
|
||
.map(
|
||
([key, label, divisor]) =>
|
||
`| ${label} | ${['baseline', 'candidate']
|
||
.map((variant) =>
|
||
(
|
||
quantile(
|
||
report.finalResources.map((r) => r[variant][key]),
|
||
0.5,
|
||
) / divisor
|
||
).toFixed(2),
|
||
)
|
||
.join(' → ')} |`,
|
||
)
|
||
.join('\n');
|
||
const payloads = ['small_source', 'large_source', 'context', 'tools_list']
|
||
.map(
|
||
(name) =>
|
||
`| ${name} | ${['baseline', 'candidate']
|
||
.map((variant) =>
|
||
quantile(
|
||
report.records.map((r) => r[variant][name].bytes),
|
||
0.5,
|
||
).toFixed(0),
|
||
)
|
||
.join(' → ')} |`,
|
||
)
|
||
.join('\n');
|
||
return `## MCP query performance
|
||
|
||
Base \`${report.runtimes.baseline.sha}\`; candidate \`${report.runtimes.candidate.sha}\`.
|
||
|
||
${report.sessions} fresh process pairs × ${report.rounds} rounds. Real MCP stdio, the same source fixture indexed by each runtime, alternating requests. No model calls.
|
||
|
||
| Workload | Median ms, base → candidate | p95 ms, base → candidate | Paired change (95% interval) | Assessment |
|
||
| --- | ---: | ---: | --- | --- |
|
||
${table}
|
||
|
||
| Resource | Median, base → candidate |
|
||
| --- | ---: |
|
||
${resources}
|
||
|
||
| Response | Median UTF-8 bytes, base → candidate |
|
||
| --- | ---: |
|
||
${payloads}
|
||
|
||
Intervals resample whole process pairs (10,000 draws). The regression threshold is >5% AND >5 ms; only a confirmed regression fails timing. Inconclusive is not proof of no slowdown. p95, CPU and RSS are descriptive. Startup uses fresh processes with warm filesystem caches.
|
||
|
||
Correctness, source budget, incomplete samples, and request errors always fail. JSON contains every response size, source-character count, backend phase timing, final server CPU/peak RSS, environment and fixture fingerprint; raw.jsonl retains every completed pair. These generated fixtures do not measure agent dollar savings or all repository workloads.
|
||
`;
|
||
}
|