Repository navigation
perf(tables): Speed up dense table postprocessing - #535
Conversation
There was a problem hiding this comment.
No issues found across 5 files
Shadow auto-approve: would not auto-approve. This PR does not meet the repository auto-approval settings.
Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack
View guided diff | Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 2 files (changes from recent commits).
Shadow auto-approve: would not auto-approve. This PR does not meet the repository auto-approval settings.
View guided diff | Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 2 files (changes from recent commits).
Shadow auto-approve: would not auto-approve. This PR does not meet the repository auto-approval settings.
View guided diff | Re-trigger cubic
|
Automated review, forwarded by @paulkarayan. Findings are code-verified where they name a file and line; the strong-review gpt-pro leg and cubic did not run. GO -- 0 blocker(s), 0 concern(s), 3 note(s), 1 nit(s). Vectorized table-geometry fast path matches the scalar path exactly (0 mismatches in 64k fuzz cases); no defects found. Notes (3)
Nits (1)
Full review |
What
Speed up dense table postprocessing while preserving extracted cells, text, ordering, HTML, and confidence values.
Full-job example: generated dense ledger
A two-page fictional ledger was processed through real table detection, OCR, and Table Transformer inference. Each crop contained approximately 950 inferred cells and 970 OCR tokens. These are controlled CPU test results, not production traffic measurements.
Values are means across five matched baseline/candidate pairs with fixed worker counts and resources, interleaved run order, and identical instrumentation. All five dense-job pairs improved, saving 4.92–23.18 seconds. Model inference and OCR timings remained approximately unchanged.
The 41× result applies to the geometry step, not the model or whole job. Ordinary table PDFs and a medium-density ledger did not show a reliable whole-job improvement. Unchanged-baseline and no-table controls showed substantial job-lifecycle noise, so these results establish a promising workload-specific benefit, not a universal speedup. Step spans can overlap and should not be added to reconstruct job duration.
Reproducible geometry-only benchmark
Run
python -m benchmarks.table_geometry. Medians of seven interleaved runs on a shared arm64 Mac, Python 3.12.13 / NumPy 2.4.4:This separate synthetic benchmark measures assignment and text selection; it excludes OCR, model inference, and HTML generation. Speedup is before-time divided by after-time.
Why
Dense tables require many repeated rectangle comparisons when assigning words to cells. Batching those comparisons reduces Python overhead. The benefit grows when this geometry work consumes a meaningful share of the job.
Thresholds, first-match ties, token order, and object identity are preserved. Temporary pairwise arrays are bounded; unsupported coordinates and unusual rectangles retain the scalar path. Winning scores retain scalar arithmetic to preserve exact confidence rounding. No model weights or dependencies change.
Validation
On
18754ba: 431 library tests passed, with one pre-existing skip. All 13 distinct real table inputs matched exact cells and confidence, including the previous rounding regressions; 114 file comparisons in the timing campaign matched. Additional randomized checks cover score values, scalar types, assignments, and confidence without new tolerances.CI passes on Python 3.11–3.13; independent review and Cubic found no issues. Ruff lint/format and
git diff --checkpass. Human approval is still required.