Skip to content

perf(function): discard evaluation-owned regexp runners without extra searches - #29585

Merged
XuPeng-SH merged 7 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/quality-29249-20261003
Oct 3, 2026
Merged

XuPeng-SH merged 7 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/quality-29249-20261003

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • Improvement
  • Test and CI

Which issue(s) this PR fixes:

Refs #29249. The broader audit and external regexp2 deadline work remain open.

What this PR does / why we need it:

Regexp cache entries own metadata, while each evaluation owns its executable regexp and runner storage. Drop that executable and release its budget lease instead of performing additional nil-input searches during matching and cleanup. Extend the existing resource/offset test to verify repeated scans, retained captures, cache isolation and idempotent budget release. Existing deadline, callback-error and admission-exhaustion tests cover failure cleanup.

Move fatal assertions out of lock-test mutex sections so failed assertions cannot deadlock fixture teardown. Replace a wall-delay-based backlog test with observation of the real full-capacity admission branch, then verify exactly one request transfers after freeing a slot. Cancel and join its actor before fixture reset; reuse the existing context probe for both sequence consumers.

The previous CI UT, coverage and SCA jobs failed because the declared base still referenced a deleted frontend test helper. This PR did not change frontend at that revision; clean-base and original-head compilation reproduce the same failure. Merge main's existing helper migration rather than restore an obsolete shim. Remove this PR's 140 appended checkpoint-history lines from the design document; preserve the already merged document.

Validation

At final tree 328a932f89, Go 1.26.4 / macOS arm64, supported native build and CGo test wrapper, matrixone_test tag:

  • Full function package normal: PASS (12.451s).
  • Full function package race: PASS (17.995s).
  • Full frontend and plan packages normal: PASS (26.644s / 13.118s), including main's prepared-binding and DATETIME integration.
  • Six focused regexp cleanup/admission, backlog transfer and sequence-publication tests: PASS, 10 repetitions each.
  • Repository-configured incremental golangci-lint across function/frontend/plan: PASS. Custom molint exits successfully; its existing unsafe-import/recover reports are confined to unchanged sources.
  • Formatting/diff checks: PASS.

Existing regexp benchmarks, run serially against the clean base and final tree (3 samples, 500ms/sample), show stable RE2 controls and no slowdown in affected compatibility paths. The grapheme case drops from 221 to 217 allocations and from 15,880 to 15,608 bytes/op; other measured allocation counts are unchanged. Timing samples are local descriptive evidence, not a statistically established throughput claim.

All checks used the final source tree; committing the documentation cleanup did not change tested executable or test inputs. CI at the updated head is pending, not claimed green. The old size-label TLS failure is infrastructure, not addressed with product changes.

Scope and limits

No regexp dependency, SQL result/error, data format, runtime lock path, native build or workflow change. regexp2 remains v1.10.0. This cleanup removes extra searches but does not promise immediate garbage collection, production-query throughput gains, or resolution of the separate dependency clock defect. Existing broader fixture teardown limitations remain outside this bounded change. Keep this PR's existing draft status.

Additional Linux verification and independent review

At 328a932f89, Go 1.26.4 / Linux amd64, with worktree-owned native artifacts and the supported CGo wrapper: complete frontend/function packages pass (24.867s / 8.945s, -count=1). These are current-head local results. Earlier focused authorization tests pass all ten subcases; changing only the mock object type to view rejects all six granted-execution cases, demonstrating that the fixture checks the real authorization query boundary. Those focused/mutation results precede the merge; their relevant helper and production authorization sources are unchanged.

Actual gpt-6.1-sol / xhigh design, full review, and final-head reconciliation completed. Final decision at 328a932f89: APPROVE; no material blockers. Final review covers all four PR files, document cleanup, and interactions with merged prepared-DML/DATETIME dependencies. Final-head review session: 01a101b1-a680-79b2-b1a7-dda59f3e1da8. Independent review is read-only source/evidence review; it does not claim independent reruns of the author-reported macOS checks.

Final net change versus merged main: tests +59 lines, production -10 lines, total +49. No duplicate frontend repair commit is needed: main's helper migration already covers it. Remote CI remains unverified; no explicit rerun was requested.

XuPeng-SH and others added 2 commits October 3, 2026 04:50
… searches

Remove two ignored nil-input regexp executions from matcher cleanup. Keep
metadata-only cached roots, evaluation ownership, mutex and budget release.
Extend the existing offset/resource fixture with exact scan/capture and
baseline-restoration oracles; preserve all original assertions.

Actual gpt-6.1-sol/xhigh review approves this non-final checkpoint. Formal
v1.10 function normal/race, 21 public SQL statements and incremental checks
pass. Private dependency clock gates and continuous quality audit remain
open; no dependency pin or universal performance claim is included.

Refs matrixorigin#29249
Preserve exact state oracles while allowing fixture cleanup after FailNow. Refs matrixorigin#29249.
Reuse the existing admission probe and one-shot unlock error; cancel and join before fixture reset. Preserve exact transfer and capacity oracles. Refs matrixorigin#29249.
@XuPeng-SH
XuPeng-SH requested a review from aptend as a code owner October 3, 2026 12:09
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Deep review of 328a932f8997a1a217d733e2435308c458a277d0 against verified main/merge-base 8daed14755ff13a81356085455cd14facb61049f.

Code-review conclusion: no verified material blocker. This is a no-blocker recommendation, not a statement that required CI has passed. The authenticated account is also the PR author, so this is submitted as COMMENT, not an independent GitHub APPROVE. No subagents were used.

Design and engineering quality

  • The first owner is the evaluation, not the regexp cache: cache roots hold metadata; forSubject creates the executable. Removing two nil-input searches uses that existing ownership instead of adding another cleanup mechanism. All three production consumers release the executable and input on normal return, admission failure, engine/deadline error and visitor error. Results escaping those consumers are booleans or copied spans, not engine matches. Engine Match objects still reference their input/regexp; the claim is bounded evaluation-local reachability, not immediate garbage collection.
  • Protected mutable flags/counts are captured while locked, then asserted after unlock. Pointer snapshots are used only for presence/identity. The backlog test replaces a timed absence assertion with capacity-rejection observation and an exact terminal payload/service oracle. Observing Done() is not proof of physical parking; the subsequent full-capacity and exact-transfer assertions are essential and remain present.
  • Implementation net −10 lines, test net +59 lines, document delta 0. No runtime lock-path change, new worker/state machine/storage/validation path, dependency pin, native/workflow change or SQL/data-format contract change. The test-only probe is reused by the existing sequence consumers. The appended 140-line checkpoint chronology was removed without changing the previously merged document.

Unhappy-path / adversarial QA

Invariant Adjacent counterexample and control Evidence / result
Q1: one effective cleanup owner Repeated scans/retained Unicode captures; deadline or visitor rejection vs successful match; admission exhaustion vs recovery Existing literal-result, exact-accounting and repeated-release tests retained; no execution escapes to cached roots. Exact-head normal/race evidence reused.
Q2: waits terminate before reset Fatal assertion while backlog is still full, before the test releases capacity, vs successful ownership transfer Private FailNow injection under race, twice in one process: exactly the injected failures occurred, and both teardown assertions confirmed actor join plus cleared retained/map/queue state. No timeout/race. The probe was removed and clean head restored.
Q3: bounded state and safe reuse Saturated backlog and competing sequence operations across repeated fixture/session reuse Each of the three exact concurrency/probe tests measured separately, then -race -count=100 separately: 100 named passes each, terminal exit 0. Existing capacities, payload bounds and generation-reset ownership remain unchanged.

Validation and comments

Reused semantically unchanged final-tree evidence: full function normal 12.451s, full function race 17.995s, frontend/plan normal 26.644s / 13.118s, six focused scenarios ×10, and configured incremental lint with no new finding. Existing molint reports are in unchanged sources. New exact-test race stresses and the expected-failure teardown experiment close the additional review gaps; no redundant full-package rerun or new cluster fixture was needed.

Serial local benchmark controls remain stable; the grapheme case saves 4 allocations / 272 bytes per operation, with other allocation counts unchanged. The limited timing samples support no observed regression, not a statistical or production-throughput guarantee.

At inspection there are no technical inline/review threads to resolve; the only issue comment is Qodo's subscription-pause notice. This does not mean the broader #29249 audit or the separate regexp2 deadline defect is fixed; both remain outside this bounded PR.

The earlier missing frontend helper is fixed by consuming main's existing migration, not restoring an obsolete shim. At inspection, exact-head run 37121904548 was cancelled and CI Required failed on matrixone-ci: cancelled; replacement CI was queued/running. Cancelled/skipped/pending jobs are not passing evidence, and this review does not waive required CI or authorize merging.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Deep review: no material blockers

Reviewed head 328a932f8997a1a217d733e2435308c458a277d0 against base/merge-base 8daed14755ff13a81356085455cd14facb61049f. Code-review recommendation: APPROVE. No subagents or model CLI were used in this review. The authenticated account is the PR author, so this is submitted as a COMMENT review, not a GitHub self-approval.

Design and engineering quality

  • Existing evaluation ownership is the correct cleanup boundary. Cache roots retain metadata; executable regexps and runner storage remain evaluation-owned. Removing the two nil-input search sites removes redundant work without adding state, validation or execution paths.
  • All three production consumers release resources on success, admission failure, engine/deadline error and visitor error. Returned production results are booleans or copied spans. Engine Match objects retain references, so this is bounded evaluation ownership, not an immediate GC/RSS guarantee.
  • Mutable counts and flags are captured while locked, then asserted after unlocking. Backlog observation proves capacity rejection, not physical parking; exact terminal capacity, one payload transfer and service identity remain the decisive assertions. Cancel and actor join precede fixture reset.
  • Increment reviewed separately: production -10 lines, tests +59 lines, documentation 0. Added test lines preserve meaningful oracles and failure cleanup; no duplicate fixture or production state machine is introduced.

Additional adversarial QA

I copied the exact regexp2 v1.10.0 dependency outside the repository and used a private -modfile replacement to simulate a runner retaining and overwriting a previously returned Match. TestRegexp2ResourceAndOffsetContracts rejected the mutant at line 179: the retained first match index was expected 2, actual 5 (0.036s). This verifies that the added capture-stability oracle detects real aliasing; matching the same text twice cannot silently satisfy it. The repository and original dependency cache remained unchanged. The earlier clean, exact-head full function pass supplies the positive control.

Evidence and remaining limits

Reused same-head Linux frontend/function passes 24.867s / 8.945s and semantically unchanged function race/fault/probe evidence recorded in the PR. The latter remains author-run evidence, not an independent rerun here. Reported grapheme measurements save 4 allocations / 272 B; local timings do not establish a general production-throughput or memory improvement. MO lint still reports seven diagnostics in unchanged production files; no clean whole-repository SCA claim.

No outstanding technical inline/comment requests were found. Qodo's subscription-pause notice requires no product-code correction. The broader #29249 audit, dependency-clock defect and existing wider fixture teardown limitations remain outside this bounded PR.

CI was still running at review time; cancelled, skipped or pending jobs are not passing evidence. This recommendation does not waive required CI or authorize merging. No commits, CI reruns or repository settings were changed by this review.

@XuPeng-SH
XuPeng-SH merged commit 4197c6f into matrixorigin:main Oct 3, 2026
@XuPeng-SH
XuPeng-SH deleted the codex/quality-29249-20261003 branch October 3, 2026 13:31
XuPeng-SH added a commit that referenced this pull request Oct 3, 2026
… work (#29591)

## Purpose

Refs #29249. Continuation after merged #29585, rebased onto main
`7ff3eac2e8`.

- Give the existing function fixture one rollback/release owner, migrate
terminal and borrowed consumers to their actual lifetimes, and remove
the duplicate evaluator type and test-only production declarations.
- Share 23 identical fixed-type comparison loops while retaining float64
epsilon/NaN behavior, existing vector wrappers, NULL ordering,
diagnostics and variable-length comparison paths.
- Preserve real boundary oracles while reducing Sleep wall time through
virtual time, payload admission map rebuilding, XML budget setup, and
LIKE budget/NTT test work.
- Keep literal result, metadata, raw geometry, failure, account and
cleanup assertions. Extend the existing reuse fixture rather than adding
a type-by-behavior matrix.

Go code: net **312 lines removed**, counting the fixture move as
movement rather than reduction. Design/coverage documentation: 107 added
lines, net whole change 205 lines removed.

## Evidence

- Actual Codex CLI `gpt-6.1-sol`, `xhigh`, read-only, multi-agent
disabled: design and implementation APPROVE. Rebase range-diff shows
both reviewed patches identical.
- Full owning-package normal and race tests, incremental configured lint
and go vet: rebased HEAD `9f0fb65aaf`: normal **7.024s**, race
**12.782s**, lint/vet exit 0; all 221 Go source hashes unchanged.
- Old-source real Abs/Cast probes independently establish exact float32,
tolerant float64/paired NaN, NULL polarity and first/last-row diagnostic
contracts.
- Comparator equality and premature-NULL-skip mutations fail the
selected real-entry test. Private constructor/input/result/helper
release mutations fail exact allocation baselines; Sleep units, payload
capacity, XML work spending and LIKE dispatch/budget mutations are also
rejected.
- Production-only compilation passed the ownership checkpoint; no native
sources changed. No SQL behavior is introduced, so BVT was not run for
this test-harness closure.

Matched three-pair serial package measurements before comparator
deduplication: wall **9.079s -> 6.281s**, CPU **2.397s -> 2.132s**, peak
RSS **168544 -> 170472 KiB**. Compilation excluded. These local
observations establish no CI-wide time saving or memory reduction.

## Remaining limits

This is a draft continuation, not closure of #29249 or the 342-file
audit. Formal regexp2 v1.10 has a deterministic
stopped-clock/stale-deadline failure, consistent with a previously
observed race failure; a private fix/probe exists but is unpublished and
not silently substituted here. A subsequent green run does not erase
that defect. Broader error-oracle cleanup, benchmark iteration
accounting and the memory objective remain open.

Detailed responsibility and coverage map:
`docs/design/20261003-function-test-fixture-ownership.md`.


## Clock gate follow-up

Independent dependency defect is tracked in #29592. The formal regexp2
dependency remains unchanged. Whole-package race failed again at
`regexp_icu_test.go:370`; the recorded earlier green run does not erase
it. Overall delivery remains blocked by that gate.

A benchmark-contract follow-up is locally committed as `255303da69` but
**not pushed to this PR head**. Full normal tests plus all 176
benchmarks at 1x, the four affected UTs plus all 176 benchmarks under
race at 2x, actual B.N+1 entry-count probes, post-admission Cast input
mutations, and incremental lint/vet are complete. Independent
`gpt-6.1-sol/xhigh` review accepted the local implementation/evidence
closure and explicitly withheld overall delivery approval. The
full-package race failure is preserved; it was not retried as an
acceptance check.

This branch was previously deployed

1 inactive deployment
ci — 6fcbba54 Deployed Oct 3, 2026 by XuPeng-SH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement kind/test-ci size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants