Repository navigation
chore(knowledge-pgvector): per-search segment timing and a load bench for search_knowledge - #38729
Conversation
Claude-Session: https://claude.ai/code/session_01JQwxbXQcnpisuAAJRr8yNr Co-authored-by: Claude <noreply@anthropic.com>
…nd service Claude-Session: https://claude.ai/code/session_01JQwxbXQcnpisuAAJRr8yNr Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbXQcnpisuAAJRr8yNr Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 2 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 1 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 2 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # 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
|
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>
Claude-Session: https://claude.ai/code/session_01JQwxbXQcnpisuAAJRr8yNr Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#2 · os-warren · session_01JQwxbWpSUzjhouye8p3Tgx 维护者速读
席位核对ACCEPT · L1 · area o2-E · Head-sha
|
|
repo:objectstack#2 · os-warren · session_01JQwxbYGom9jneGXshSXk4W 2026-11-30T08:58Z · Landing · PR #38729 (#38719 part 1) · zone o2-E
|
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
维护者速读
What changes
A new, unpublished directory
packages/plugins/knowledge-pgvector/bench/(the package'sfilesisdist,README.md,CHANGELOG.md, so nothing here ships):instrument.mjs— per-search segment timing read through seams the code already takes. Nothing undersrc/of this package or ofservice-knowledgeis changed:embed— the adapter'sembedderoption;pool_wait+ranking+other_sql— the adapter'spooloption, aPgPoolLikewhose one-shot query is split into checkout, statement and release, the same stepspg.Pool#queryruns;visible_ids+permission_recheck+system_read— the service'sdataEngineoption, each read classified by the arguments the service passes;Concurrent searches are kept apart by an
AsyncLocalStoragestore 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 realKnowledgeService, then makes realsearch_knowledgecalls (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.search failedlog lines; block reads of the store's tables.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
embedderoptionrankingpooloption; the statement also carries the keyword leg for any query with keyword terms (counted per cell) and the scope predicate--isolate-scopeadds 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 underknowledge-pgvector/src(held by #38692)dataEngineoption (permission_recheckafter ranking,visible_idsbefore it)pooloptionTests
pnpm --filter @objectstack/knowledge-pgvector testat8e3e522f: 6 files passed, 8 skipped (the live-PostgreSQL files: noOS_TEST_POSTGRES_URL); 29 tests passed, 93 skipped.pnpm --filter @objectstack/knowledge-pgvector typecheck: exit 0. The bench files are.mjsand outside the package's TS programs.permission_recheckreclassified on disk,bench/instrument.test.mjswent red (1 failed / 4 passed); restored withgit 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_buffers512MB, 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 failedlines · rows in scope.All 20 cells completed with 0 failed searches; the full table is in the run's JSON.
Acceptance notes
bench/instrument.mjs—classifyEngineRead, which decides what counts as the permission re-check, andtimedPool, which reproducespg.Pool#query's checkout, statement and release.bench/run.mjs—isolateScope, the derived scope-predicate pass, and its stated method.bench/instrument.test.mjs— the pins over the real adapter and service.skip-changeset).--isolate-scope); no store seam under 知识源加「检索方式」和混合比例:只用向量 / 只用关键词 / 混合(可设比例),由应用元数据指定,单次检索可覆盖 #38692's files.Verification
Two-minute check, against any PostgreSQL where the role can
CREATEand thevectorextension 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-scopeExpected: a markdown table with four rows, every
okequal ton, the 10% rows showing… (derived)in the last column and the unscoped rowsNOT MEASURED; the JSON path printed on stderr. Both schemas are dropped at the end.🤖 Generated with Claude Code
https://claude.ai/code/session_01JQwxbXQcnpisuAAJRr8yNr