Skip to content

chore(knowledge-pgvector): per-search segment timing and a load bench for search_knowledge - #38729

Merged
objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/project-thread-7ze7yf
Nov 30, 2026
Merged

objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/project-thread-7ze7yf

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Warren · project thread

Refs #38719 (part 1) — the committed segment timing and the load bench. Part 2, the baseline on the A4 environment, stays on the card, which this PR does not close.

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户无感:只新增一个提交进仓库的测速脚本,产品行为不变。
  • 属于「私有部署企业版知识检索 10 人同时提问不超时」专题的基线一项,给第三期每项做不做提供数据。
  • 出错只会让测速读数不准,不影响任何客户;脚本不随软件包发布,可直接撤回。
  • 无。

What changes

A new, unpublished directory packages/plugins/knowledge-pgvector/bench/ (the package's files is dist, README.md, CHANGELOG.md, so nothing here ships):

  • instrument.mjs — per-search segment timing read through seams the code already takes. Nothing under src/ of this package or of service-knowledge is changed:

    • embed — the adapter's embedder option;
    • pool_wait + ranking + other_sql — the adapter's pool option, a PgPoolLike whose one-shot query is split into checkout, statement and release, the same steps pg.Pool#query runs;
    • visible_ids + permission_recheck + system_read — the service's dataEngine option, each read classified by the arguments the service passes;
    • adapter rounds (a refill round = backfill) — the adapter as registered with the service.

    Concurrent searches are kept apart by an AsyncLocalStorage store per search.

  • run.mjs — the load bench, runnable against any PostgreSQL URL with pgvector. It seeds a synthetic dataset into two throwaway schemas, builds the index through the real KnowledgeService, then makes real search_knowledge calls (the tool executor, as a non-system caller) over record-scope fraction × concurrency. Default grid: 1/10/30/100 % and unscoped × 1/5/10/20 clients, closed loop.

    • Per cell: p50/p95/max/mean of the total and of every segment, each with its sample count; hit count; searches per question; backfill share (scoped and unscoped cells are separate rows); embedding-call failures; failed and refused searches with their codes; empty answers; the service's search failed log lines; block reads of the store's tables.
    • It also records the machine shape (client CPUs and memory; server version, pgvector version and memory settings) and whether the cell ran cold or warm.
  • instrument.test.mjs — pins statement shape and call counts over the real adapter and service from source, with no database. It never pins a duration.

  • README.md — the manual.

Segment status

segment (card) status seam
embed measured adapter embedder option
vector statement measured as ranking adapter pool option; the statement also carries the keyword leg for any query with keyword terms (counted per cell) and the scope predicate
scope predicate NOT MEASURED in situ it is a conjunct of the ranking statement's one WHERE. --isolate-scope adds a DERIVED out-of-situ number: the same WHERE as a bare count minus the source-and-generation WHERE as a bare count, run serially and timed by the server. An in-situ number needs the store to time its statement parts itself, a change under knowledge-pgvector/src (held by #38692)
permission re-check measured service dataEngine option (permission_recheck after ranking, visible_ids before it)
pool wait measured (not on the card) adapter pool option

Tests

  • pnpm --filter @objectstack/knowledge-pgvector test at 8e3e522f: 6 files passed, 8 skipped (the live-PostgreSQL files: no OS_TEST_POSTGRES_URL); 29 tests passed, 93 skipped.
  • pnpm --filter @objectstack/knowledge-pgvector typecheck: exit 0. The bench files are .mjs and outside the package's TS programs.
  • Ablation: with permission_recheck reclassified on disk, bench/instrument.test.mjs went red (1 failed / 4 passed); restored with git restore.
Local smoke run — 5,000 passages, 1024 dims, 40 searches a cell (NOT a baseline, not quotable)

Machine: 4 vCPU, 15.7 GiB, shared container. PostgreSQL 16.15 with pgvector 0.6.0 (Ubuntu package; the kit ships 0.8.7), shared_buffers 512MB, pool 4, fake in-process embedder, warm. Its job is to show the script runs the whole grid; it is not the A4 baseline. Columns: scope · concurrency · n · total p50/p95 ms · pool wait p50 · ranking p50 · re-check p50 · backfill · search failed lines · rows in scope.

1%   | 1  | 40 | 53.73 / 73.57     | 0.1     | 50.46  | 1.95 | 0 | 0 | 50
1%   | 20 | 40 | 434.59 / 625.09   | 350.72  | 71.83  | 2.21 | 0 | 0 | 50
10%  | 1  | 40 | 73.35 / 106.8     | 0.09    | 70.21  | 1.87 | 0 | 0 | 500
30%  | 1  | 40 | 114.04 / 205.01   | 0.08    | 111.08 | 1.73 | 0 | 0 | 1500
100% | 1  | 40 | 263.53 / 453.83   | 0.07    | 260.75 | 1.69 | 0 | 0 | 5000
100% | 20 | 40 | 1776.19 / 2117.96 | 1451.12 | 323.8  | 5.45 | 0 | 0 | 5000
none | 1  | 40 | 250.89 / 491.17   | 0.07    | 245.3  | 1.82 | 0 | 0 | -
none | 20 | 40 | 1295.42 / 1570.26 | 1046.31 | 241.46 | 1.56 | 0 | 0 | -

All 20 cells completed with 0 failed searches; the full table is in the run's JSON.

Acceptance notes

  • First files to read:
    1. bench/instrument.mjs — classifyEngineRead, which decides what counts as the permission re-check, and timedPool, which reproduces pg.Pool#query's checkout, statement and release.
    2. bench/run.mjs — isolateScope, the derived scope-predicate pass, and its stated method.
    3. bench/instrument.test.mjs — the pins over the real adapter and service.
  • The bench composes its own service over synthetic data (ObjectQL + SqlDriver, no security plugin), so the re-check reads every row it asks for. It cannot yet point at an already-indexed source in a kit deployment (the BrightRule source on A4); part 2 has to decide that.
  • At concurrency 10–20, the smoke run's time goes mostly to waiting for one of the pool's 4 connections. That is the topic's B2 (pool size from settings), not new scope.
  • No changeset: no published file moves (skip-changeset).
  • Seat routing (2026-11-30T08:16Z), part 2 composition: B — on A4 the bench composes the source itself at 60k×1024; an existing-source option (A) may follow after refactor(service-knowledge): split KnowledgeService into five concern modules behind a delegating facade #38700 only if needed.
  • Seat routing (2026-11-30T08:16Z), scope predicate: keep the labelled DERIVED number (--isolate-scope); no store seam under 知识源加「检索方式」和混合比例:只用向量 / 只用关键词 / 混合(可设比例),由应用元数据指定,单次检索可覆盖 #38692's files.

Verification

Two-minute check, against any PostgreSQL where the role can CREATE and the vector extension is available:

pnpm --filter '@objectstack/knowledge-pgvector...' build
node packages/plugins/knowledge-pgvector/bench/run.mjs --pg-url postgres://USER@HOST:5432/DB --passages 500 --scopes 10,none --concurrency 1,5 --searches 20 --isolate-scope

Expected: a markdown table with four rows, every ok equal to n, the 10% rows showing … (derived) in the last column and the unscoped rows NOT MEASURED; the JSON path printed on stderr. Both schemas are dropped at the end.


🤖 Generated with Claude Code

https://claude.ai/code/session_01JQwxbXQcnpisuAAJRr8yNr

@objectstack-fleet objectstack-fleet Bot added the skip-changeset PR has no user-facing published change; bypasses the changeset gate label Nov 30, 2026
@github-actions github-actions Bot added size/xl documentation Improvements or additions to documentation labels Nov 30, 2026
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/knowledge-pgvector, touching 67 documentable anchor(s). ⚠️ 1 changed file(s) yielded no anchor (packages/plugins/knowledge-pgvector/bench/README.md), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

2 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/data-modeling/drivers.mdx (via USAGE (symbol, a top-level const object))
  • content/docs/deployment/environment-variables.mdx (via max_connections (literal, a string literal in machineShape))

⛔ 1 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v14.mdx (via OUT (symbol, a top-level const object))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/plugins/knowledge-pgvector/bench/README.md) — pages documenting those are invisible to this run
  • 13 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 2 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 80ddfb50508c99e8b8ba17e3f42c10131fa02e85 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 19b03cf9eafa2d26108883142e529daff0862a22 — the merge of head 6bbfd16b23be02f44286952e7ba81eec97125f4d into base 80ddfb50508c99e8b8ba17e3f42c10131fa02e85, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 19b03cf9eafa2d26108883142e529daff0862a22 && git checkout 19b03cf9eafa2d26108883142e529daff0862a22
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 80ddfb50508c99e8b8ba17e3f42c10131fa02e85 6bbfd16b23be02f44286952e7ba81eec97125f4d && git checkout -B drift-repro 80ddfb50508c99e8b8ba17e3f42c10131fa02e85 && git merge --no-ff 6bbfd16b23be02f44286952e7ba81eec97125f4d

node scripts/docs-audit/affected-docs.mjs --json 80ddfb50508c99e8b8ba17e3f42c10131fa02e85

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 80ddfb50508c99e8b8ba17e3f42c10131fa02e85 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

The store's ranking statement moves into a transaction of its own once it
carries a SET LOCAL time limit, sent on a connection from pool.connect().
timedPool now times every checkout into pool_wait and every statement on
a checked-out connection (ranking, or other_sql with BEGIN, SET LOCAL and
COMMIT as transaction), passing release through as the store calls it.

Claude-Session: https://claude.ai/code/session_01JQwxbXQcnpisuAAJRr8yNr
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-warren · session_01JQwxbWpSUzjhouye8p3Tgx

维护者速读

  • 结论:通过。这是一个提交进仓库的测速脚本,能把每次「在知识库中查找」的耗时拆成嵌入、等连接、检索语句、权限复查几段。B2 上线前后两种检索写法都能量(席位在本地把它和 B2 合在一起跑过,测试全过)。
  • 不影响产品:产品代码一行没动,脚本不随软件包发布。
  • 第二部分(在验收环境 A4 上跑基线)留在卡上,本 PR 合并不关卡。
  • 要你做什么:无。

席位核对

ACCEPT · L1 · area o2-E · Head-sha 6bbfd16b23be02f44286952e7ba81eec97125f4d · 2026-11-30T08:57Z

  • Face (l1-face.mjs --pr 38729): draft, base main, first line Part of #38719. That is non-closing, so part 2 (the A4 baseline) stays on the card, as the maintainer reopened it. No closing keyword on any other card, no content/docs/releases/, not governed. 4 files, all under packages/plugins/knowledge-pgvector/bench/**, which is inside the claim's surface. Clause-②: no / Metadata-protocol: none.
  • skip-changeset: both premises hold. The dev says no published file moves. The seat's own read agrees: the package's files is ["dist", "README.md", "CHANGELOG.md"], and bench/ is outside src/, so it is neither built nor shipped. The label was hung by the relay pr_create, and no classifier refused it.
  • Checks at this head: 39 success, 20 expected skip, 0 failed, 0 pending; Lint & Repo Gates and TypeScript Type Check success; mergeable_state clean.
  • Seams (bench/instrument.mjs). Nothing under src/ of either package is touched.
    • embed is read through the adapter's embedder option.
    • pool_wait, ranking and other_sql are read through its pool option.
    • visible_ids, permission_recheck and system_read are read through the service's dataEngine.
    • Concurrent searches are kept apart with AsyncLocalStorage.
    • The pins count calls and check statement shape; none pins a duration.
  • Round 1 finding, fixed (the seat's heads-up at 8e3e522). After B2 (fix(knowledge-pgvector): a failed search is a coded refusal, its statement has a time limit, and its pool size is a setting #38726), the ranking statement runs on a checkout held for a transaction, which the round-1 timedPool did not time. At 6bbfd16, timedPool times both paths. A one-shot query and a held connect() each get a timed checkout. Every statement on that client is classified, with BEGIN/SET LOCAL/COMMIT/ROLLBACK counted as transaction under other_sql. release is passed through as the store calls it. connectSession (the builder lock) stays untimed. Three new pins cover the held checkout, a one-shot query with a failing release, and concurrent attribution.
    • The seat's own readings, on a local build of the dependency closure:
      • vitest run bench/instrument.test.mjs at 6bbfd16b alone: 8 passed.
      • The same suite plus src/__tests__/search-refusals.test.ts on a local merge of 6bbfd16b + 9a39db77 (B2 head, clean merge): 22 passed.
      • Round 1 control: 8e3e522f + 9a39db77 gave 3 failed / 2 passed.
    • The one loosened pin (pool_wait >= ranking, was === ranking + other_sql) is the right shape now that a held checkout carries several statements.
  • Seat routings, checked against the head:
    • (1) Part-2 composition is option B. run.mjs --embedder openai (OS_BENCH_EMBEDDER_URL/_MODEL) with --passages/--dims gives the 60k × 1024 synthetic set with the customer's embedder. The throwaway schemas are os_kbench_<dataset> and os_kbench_<dataset>_k, with the dataset name checked against [a-z0-9_]{1,40}, so a run against the kit's database can never drop os_knowledge.
    • (2) The scope predicate is NOT MEASURED in situ. --isolate-scope prints it as (derived) in the table and as status: 'DERIVED' in the JSON, with its method stated.
  • Smoke readings in the body are marked not quotable: pgvector 0.6.0, a shared box, taken before L1. Per the topic rule, no speed number is quoted from them. The A4 baseline under part 2 is the first quotable reading.
  • Classifier refusal (building pgvector 0.8.7 from source) is recorded verbatim in deviations, with the fallback to the Ubuntu 0.6.0 package.
  • Nit, accepted as is: OS_BENCH_EMBEDDER_* is neither a runtime nor a test variable, so AGENTS.md PD 9's OS_TEST_* does not strictly apply. The README names them.
  • Landing note: this PR lands after fix(knowledge-pgvector): a failed search is a coded refusal, its statement has a time limit, and its pool size is a setting #38726 (B2), the zone's order. Its pins pass on both trees, so the order is not a correctness constraint. Part of keeps pm:dispatched on knowledge-pgvector:检索分段计时与 PostgreSQL 基线(专题 #38703 B1) #38719 until part 2 closes it.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-warren · session_01JQwxbYGom9jneGXshSXk4W

2026-11-30T08:58Z · Landing · PR #38729 (#38719 part 1) · zone o2-E

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 30, 2026 08:58
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 30, 2026
Merged via the queue into main with commit cb8d853 Nov 30, 2026
60 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-7ze7yf branch November 30, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/xl skip-changeset PR has no user-facing published change; bypasses the changeset gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants