Skip to content

perf(persistence): avoid formatting missing SQL attribute errors - #2776

Merged
huanghuoguoguo merged 1 commit into
masterfrom
perf/sql-guard-attribute-reads
Oct 27, 2026
Merged

huanghuoguoguo merged 1 commit into
masterfrom
perf/sql-guard-attribute-reads

Conversation

@huanghuoguoguo

@huanghuoguoguo huanghuoguoguo commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Overview

SQL admission repeatedly reads optional AST attributes. SQLAlchemy's standard ColumnElement fallback formats AttributeErrors that getattr immediately discards. Avoid that formatting for the exact known fallback while retaining live instance, descriptor and comparator reads; unknown or changed fallbacks use normal getattr.

Every statement is still checked. No statement-validity cache, SQL admission rule, tenant fence or rollback-only protection is removed. Session event guards are unchanged.

Related: #2709 (follow-up profiling of the shared validation cost). This is independent of the pipeline read-count and event batching PRs.

Validation and limits

On this independently split branch: pytest tests/unit_tests/persistence/test_tenant_uow.py -q: 125 passed. Added regressions cover mutable instances, comparator properties and a replaced fallback.

Seven alternating same-process CPU measurements over real ORM SELECT/UPDATE/aggregate statements observed roughly 15–25% lower validation CPU, not whole-request latency. The combined SQL+UTF-8 candidate completed all 384 requests in a bounded ABBA comparison and observed +1.81%/+3.74% throughput, but one pair's overall P95 worsened by about 10%. Those combined results cannot isolate this patch's contribution or establish no regression. GC and high-load tail latency remain unresolved.

Keep the SQLAlchemy attribute-equivalence tests when upgrading that dependency. Draft for focused security/performance review.

Related review pieces

Author checklist

  • Read CONTRIBUTING.md.
  • Ran the focused checks listed above on this independent branch.
  • CLA status to be verified by the repository bot.

@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.66667% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/langbot/pkg/persistence/tenant_uow.py 86.66% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@huanghuoguoguo
huanghuoguoguo marked this pull request as ready for review October 27, 2026 03:19
@huanghuoguoguo
huanghuoguoguo merged commit 62c0f46 into master Oct 27, 2026
22 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-27T03:19:48.782657Z 0d5f324 Draft marked ready
🔒 Security Review 🔄 Running since 2026-10-27T03:19:48.682754Z 0d5f324 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot locked and limited conversation to collaborators Oct 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant