perf: add optional Rust kernels for native PDF pipelines - #13
Merged
Merged
Conversation
myhloli
marked this pull request as ready for review
September 25, 2026 18:51
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem and behavior
Native PDF parsing and shared text/table evidence repeatedly compute character geometry, line relationships, script roles and dense-table candidates in Python. This PR adds optional private Rust kernels and a PDFium batch bridge while retaining public Python interfaces, complete Python fallback and output semantics.
DOCVORTEX_COMPUTE_BACKEND=auto|python|rustselects the backend.Round five, completed at
81c86f4596422e15623f2609616631ef6f1119bd, uses private protocol 6 and adds:Final performance
Frozen round-four
a281218with its matching extension versus the final implementation. macOS arm64, CPython 3.14.4, pypdfium2 5.13.0. Four variants use independent processes, one warmup and five samples, alternating order by document; process-tree RSS is sampled separately. Formal timing never overlaps local tests, builds or profiling.Dense shared text: 6.4204 → 0.6670 s (89.6% lower). Both core targets pass: public parsing ≥20% lower and shared text ≥60% lower. These shared measurements use frozen layout inputs and do not represent complete model inference.
Absolute-reference gap retained: caibao1 is 0.0071 s above the prior 2.566 s reference; it is approximately 0.7% slower than the concurrent frozen Rust baseline and passes the 5% regression gate. demo1/demo2 retain their original absolute references. This does not claim every absolute-time reference was met.
All 32 public and 32 shared document checks pass complete output equality and the unchanged >5% sustained time/RSS regression gates. Shared coverage was expanded beyond the four headline PDFs. Seven shared documents triggered prescribed reverse-order checks; all pass final adjudication. Maximum current/reference Rust tree-RSS ratio: public 1.0134, shared 1.0039.
Validation
dev@cabe6e34: 137 tests per backend, plus four-document medium/high four-way replay equality and normal process exits. The existing opt-in adapter connects six legacy raster mocks to the encoded-crop boundary without changing business code or original assertions; real rendering is independently tested.Evidence and remaining hotspots
Independent profiling reduces Python overlap-connection calls 21,480,737 → 242,048, baseline decisions 872,946 → 15,282, and dense-parser bbox unions 1,613,658 → 136,968. Candidate materialization remains 7,216 calls and expansion 7,217: no candidate truncation. Remaining work is candidate expansion, rule-interval partition/compatibility checks and annotation/marker processing. Profiler totals are separate from formal timing.
Local detailed report:
output/pdf/rust-round5-20260925/REPORT.md; final evidence is under itsaccepted-*, validation, installation and visual files. Rejected batching and earlier GC/empty-page measurements remain separately identified. The external PDF is not uploaded; SHA2561bbd28a4f0733ab3dbd7e651afed11338e8baf535ad92413d96b108eab5a76ed.PR remains draft; no merge or release performed.