Skip to content

perf: avoid repeated line feature work in Flash PDF - #39

Merged
myhloli merged 1 commit into
nextfrom
codex/flash-pdf-02-hotspots
Sep 5, 2026
Merged

perf: avoid repeated line feature work in Flash PDF#39
myhloli merged 1 commit into
nextfrom
codex/flash-pdf-02-hotspots

Conversation

@myhloli

@myhloli myhloli commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Motivation

Native inline-script matching recomputes font-size medians for every candidate pair, and ordinary lines compute structural script evidence that is discarded.

Modification

Precompute font scales, upright bounds and reference-marker features within each matching pass. Compute strong script roles only when consumed. Prefilter same-baseline pairs by necessary classification conditions and delay table-obstacle checks until geometry matches, preserving pair order and merge decisions.

This is stage 2/6 of the Flash PDF equivalence refactor, based on codex/flash-pdf-01-baseline. Review and integrate stages in order.

Validation

31 documents / 298 pages retain identical complete model-list and Middle JSON output. 65 focused tests pass, including cache lifetime and linear font-statistic work. Four representative five-run medians improve by 11.8%–34.4%; peak RSS remains within 0.4% of baseline.

The original test_demo_sparse_table_confidence_manifest bbox expectation failure is documented separately and its expected data is not modified.

Compatibility

The existing PdfModel.predict(), PDFDocument methods, ModelJson/MiddleJson output and renderer contracts remain unchanged. Recognition thresholds, candidate priority and fallback behavior are preserved.

Checklist

  • Relevant Ruff checks and git diff --check pass.
  • Focused regression and complete corpus output comparisons recorded.
  • New functions have Chinese docstrings and explicit type annotations.
  • Documentation or module responsibility docstrings updated.
  • Remote CI and CLA checks completed.

@myhloli
myhloli changed the base branch from codex/flash-pdf-01-baseline to next September 5, 2026 07:36
@myhloli
myhloli marked this pull request as ready for review September 5, 2026 07:36
@myhloli
myhloli merged commit 0d0aa98 into next Sep 5, 2026
1 of 2 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 5, 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