feat: compare history indexes on uneven chats in bench

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-02 04:24:59 +03:00
co-authored by Claude Opus 5.5
parent 3f3acc95b8
commit d2656ab986
12 changed files with 1597 additions and 162 deletions
+13 -21
View File
@@ -1,14 +1,15 @@
// Этап плана: три страницы истории читаемого чата подряд, пока в Postgres
// стенда включён auto_explain. Первая — без курсора, средняя и последняя
// полная — курсоры из пула (середина и конец). Порядок запросов = порядок
// планов в журнале: оркестратор сопоставляет их по нему.
// Этап плана: страницы истории из plan_pages.json подряд, пока в Postgres
// стенда включён auto_explain. Для читаемого чата и первого чата каждого
// фонового уровня — первая, средняя и последняя полная страница (у
// короткого чата — первая). Порядок запросов = порядок планов в журнале:
// оркестратор сопоставляет их по нему.
import http from "k6/http";
import { check, fail } from "k6";
import { API, PAGE_LIMIT, WORK_DIR, authHeaders } from "./lib.js";
const fixture = JSON.parse(open(`${WORK_DIR}/fixture.json`));
const pool = JSON.parse(open(`${WORK_DIR}/cursors.json`));
const pages = JSON.parse(open(`${WORK_DIR}/plan_pages.json`));
export const options = {
vus: 1,
@@ -16,26 +17,17 @@ export const options = {
};
export default function () {
const cursors = pool.cursors;
if (cursors.length === 0) {
fail("cursor pool is empty: history is shorter than a walk page");
}
const pages = [
["first", null],
["middle", cursors[Math.floor(cursors.length / 2)]],
["last", cursors[cursors.length - 1]],
];
const url = `${API}/chats/${fixture.readChatId}/messages`;
const params = { headers: authHeaders(fixture.tokens[fixture.readerId]) };
for (const [name, cursor] of pages) {
const query = cursor === null
for (const page of pages) {
const name = `${page.chat} ${page.page}`;
const query = page.cursor === null
? `?limit=${PAGE_LIMIT}`
: `?limit=${PAGE_LIMIT}&cursor=${encodeURIComponent(cursor)}`;
const res = http.get(url + query, params);
: `?limit=${PAGE_LIMIT}&cursor=${encodeURIComponent(page.cursor)}`;
const res = http.get(`${API}/chats/${page.chat_id}/messages${query}`, params);
const ok = check(res, {
[`${name} 200`]: (r) => r.status === 200,
[`${name} full page`]: (r) =>
r.status === 200 && r.json("items.#") === PAGE_LIMIT,
[`${name} ${page.items} items`]: (r) =>
r.status === 200 && r.json("items.#") === page.items,
});
if (!ok) {
fail(`explain page ${name}: ${res.status}`);