Skip to content

Skip inactive inline transforms on borrowed HTML - #278

Merged
dereuromark merged 1 commit into
masterfrom
perf/borrowed-inline-scans
Aug 21, 2026
Merged

Skip inactive inline transforms on borrowed HTML#278
dereuromark merged 1 commit into
masterfrom
perf/borrowed-inline-scans

Conversation

@dereuromark

Copy link
Copy Markdown
Contributor

Outcome

Finish the post-#277 hot-loop audit by avoiding inline scans and regex calls when the corresponding Djot syntax is absent.

On the 49,540-byte carve-bench publication document, repeated isolated PHP 8.5 tracing-JIT runs land at 2.60–2.87 ms minimum (16.48–18.19 MB/s), versus 3.25 ms / 14.52 MB/s before this final pass. The fastest stable run is now effectively level with the current 18.41 MB/s carve-php reference.

How

  • Return escaped plain text immediately when no inline or smart-typography marker is present.
  • Skip the flat-inline parser when only smart punctuation needs rendering.
  • Only run contraction, quote, and dash transforms when their trigger byte exists.
  • Preserve the fail-closed path for ambiguous or unsupported syntax.

These mirror the recent carve-php architecture work: syntax-family gates, C-level bulk scans, and zero inactive extension/transform work. Djot PHP already carries the other applicable improvements: bulk inline runs, block-marker short-circuiting, renderer dispatch tables, and listener allocation avoidance.

Correctness

  • Full suite: 2,819 tests, 18,472 assertions.
  • Added borrowed-vs-owned parity coverage for smart punctuation.
  • PHPStan and PHPCS pass.
  • Publication output remains byte-identical at 98,922 bytes.

@dereuromark
dereuromark merged commit fab953f into master Aug 21, 2026
4 checks passed
@dereuromark
dereuromark deleted the perf/borrowed-inline-scans branch August 21, 2026 02:16
@codecov

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.32258% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.19%. Comparing base (408e93c) to head (26c5255).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/Performance/BorrowedHtmlLayout.php 90.32% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master     #278   +/-   ##
=========================================
  Coverage     92.18%   92.19%           
- Complexity     3955     3967   +12     
=========================================
  Files           111      111           
  Lines         11052    11066   +14     
=========================================
+ Hits          10188    10202   +14     
  Misses          864      864           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant