Skip to content

perf: reduce vector encoding and runtime verification overhead - #2621

Merged
hidb4ai merged 7 commits into
masterfrom
codex/runtime-hotspot-optimizations
Nov 15, 2026
Merged

hidb4ai merged 7 commits into
masterfrom
codex/runtime-hotspot-optimizations

Conversation

@hireview001

@hireview001 hireview001 commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Which issue or RFC does this PR close?

Related: RFC 1400, RFC 1771, and RFC 1809.

Rationale for this change

OceanBase vector requests spend CPU formatting individual Python floats, Source batches issue one evidence INSERT per accepted observation, and startup verification fetches each current projection and its full vector separately. Reduce those costs while preserving the existing persistence and admission contracts.

What changes are included in this PR?

  • Encode finite float32 arrays with orjson at the OceanBase SQL type boundary for Atomic and Topic Memory. Preserve driver dimension checks, special-value/subclass behavior and reference readback.
  • Batch immutable Source evidence bindings within the accepting transaction, preserving exact identities, idempotency and rollback behavior.
  • Read current projections by bounded pages and select vector presence on OceanBase; retain all authoritative content, state, tags, profile and evidence checks. Keep SQLite vector-length validation and its older parameter limit.
  • Declare direct NumPy/orjson dependencies, synchronize dependent lock files and update the persistence compatibility review.

Are there any user-facing changes?

No public API or database schema changes. Stored float32 values and existing Source evidence remain compatible. This PR contains only these three optimizations and their validation/dependencies on current master, which already includes PR #2567.

How was this change tested?

  • make check and uv run prek run -a passed. After incorporating master 38fb3508, make check passed again; the merged Git tree is byte-identical to the combined experiment, whose related suite passed 107 tests with 1 optional test skipped.
  • Three-change commit f78eea55: related vector, Source, projection, migration and Topic Memory tests: 113 passed, 1 skipped with real OceanBase enabled. Only the opt-in seekDB migration case was skipped. Native vector tests use deterministic fixtures, not provider calls.
  • Python 3.11, 3.12 and 3.13: 63 focused vector, Source and projection tests passed on each interpreter; the full related suite also passed on Python 3.14.
  • A 501-Memory SQLite regression validates complete verification and missing-projection detection with a 999-variable limit.
  • A separate real OceanBase probe compared 64 × 1024-dimensional vectors per encoding: persisted float32 bits and both cross-read directions matched. All acceptance databases were dropped.

Performance evidence

Chinese report, raw evidence and reproduction scripts. The measured integrated tree 706ec284 is byte-identical to this PR head 941d74fe.

  • Against merged master 38fb3508, two ordered/reversed real-OceanBase module comparisons measured SDK hybrid query throughput 117.94 → 145.10/s (+23.0%), CPU/query 8.376 → 6.755 ms (-19.4%), and complete startup verification 13.09 → 11.20 s (-14.5%). SDK queries reuse persisted vectors and do not call the provider or HTTP layer. Forty 32-Source batches reduced evidence INSERT calls 1,280 → 40 and CPU/Source by 50.2%; bindings and duplicate positions remain valid.
  • The release comparison contains 240,000 requests across 20 trials, with two API processes and independent background processing pinned to two CPUs. The final tree sustained both 100-write + 100-query/s without models and 50-write + 50-query/s with real models, with zero HTTP errors across two rounds each. At 200 + 200/s, writes reached 199.87/s with no errors, while queries reached 107.56/s with 45.5% errors. These version differences also include perf: batch Source capture and model usage writes #2567.
  • Eight mixed-load model trials generated no new Memory and each recorded a model timeout; Source acceptance is not extraction throughput. Separate one-fact real-model generation, vector search and public readback passed on all four source variants. The final two mixed-load trials reconciled all 9,000 successful query embeddings with persisted usage.
  • Shared backend/provider resources, short runs, common dependencies and the declared v1.4.1 reflection compatibility patch limit generalization. All six benchmark databases were dropped; the original .env is unchanged.

AI usage statement

Implementation, review and validation were assisted by OpenAI Codex (GPT-6).

@CLAassistant

CLAassistant commented Nov 13, 2026 •

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ hidb4ai
❌ Teingi


Teingi seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@hidb4ai hidb4ai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes for the missing dependency in the isolated native-resource build environment.

Comment thread pyproject.toml Resolved

@hidb4ai hidb4ai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed bef86938. The previous resource-build P2 is fixed: a fresh locked Python 3.12 build-host environment now runs both managed-resource entry points and the resource tests. I found no new PR-introduced correctness issue or database/public API additions.

Merge readiness is still blocked by dsh-package and cindy-package: rebuilding changes integrations/dsh/plugins/dsh-pet/lib/index.js and integrations/cindy/plugins/powercontext-hooks/node/worker.cjs, so their generated-file checks fail. The same diffs occur in base commit 38c38846's CI, and their sources, build inputs and checked-in bundles are unchanged by this PR; this is an inherited baseline failure, not another finding against the optimizations. Please synchronize the generated bundles and rerun CI before merging. Approval remains pending a green CI result.

@hidb4ai
hidb4ai merged commit d0c4691 into master Nov 15, 2026
37 of 47 checks passed
@PsiACE
PsiACE deleted the codex/runtime-hotspot-optimizations branch November 16, 2026 12:52
@hidb4ai hidb4ai added the 1.6.0 v1.6.0 release tracking label Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.6.0 v1.6.0 release tracking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants