Skip to content

Keep rich core Djot on the fast HTML path - #277

Merged
dereuromark merged 1 commit into
masterfrom
perf/complete-html-fast-path
Aug 21, 2026
Merged

Keep rich core Djot on the fast HTML path#277
dereuromark merged 1 commit into
masterfrom
perf/complete-html-fast-path

Conversation

@dereuromark

Copy link
Copy Markdown
Contributor

Outcome

Complete the allocation-light conversion work from #276 for the representative rich core workload, and reduce duplicate document scans on authoritative fallback.

The 49,540-byte carve-bench Djot document now stays on the borrowed path with byte-identical 98,922-byte HTML. It covers headings and sections, title-shaped definition prose, paragraphs, nested strong syntax, unresolved explicit references, tight lists with continuation-shaped nested markers, block quotes, fenced code, and plain-cell tables.

Performance

PHP 8.5.9 NTS, tracing JIT, 20 warmups, fastest of five trials with 50 iterations each:

route before this PR change
rich default facade, 49,540 bytes 13.63 ms / 3.47 MB/s 3.25 ms / 14.52 MB/s 4.19x faster
authoritative owned AST ~13.0 ms / ~3.6 MB/s 10.27 ms / 4.60 MB/s ~21% lower

The facade result is now in the same performance band as carve-php on the publication workload (currently documented at 18.41 MB/s), while emitting almost twice the source size as HTML.

How

  • Add conservative borrowed renderers for the exact Djot list, quote, and table shapes whose output can be proven locally.
  • Support Djot double-strong nesting, explicit unresolved references, smart quote/dash output, and title-shaped definition prose without AST allocation.
  • Retain whole-document fail-closed behavior for real table separators, nested block structure, implicit heading references, ambiguous definitions, and unsupported syntax.
  • Gate reference, footnote, abbreviation, and implicit-heading collectors by source-family predicates.
  • Skip heading reference extraction and the post-parse heading rewrite when neither implicit heading references nor warning validation can consume them.
  • Avoid statistics bookkeeping unless observation is requested.

Correctness

  • The complete rich benchmark source is byte-identical to the owned AST oracle.
  • Every newly admitted official corpus document is byte-identical; 19 admitted, zero mismatches.
  • Focused coverage includes rich list/quote/table shapes, nested strong, unresolved references, title-shaped prose, conventional-table fallback, lazy headings, Unicode, unsafe URLs, and custom renderers.
  • Full suite: 2,818 tests, 18,469 assertions.
  • PHPStan and PHPCS pass for all changed files.

Validation

vendor/bin/phpunit
vendor/bin/phpstan analyse src/Performance/BorrowedHtmlLayout.php src/Parser/BlockParser.php tests/BorrowedHtmlLayoutTest.php --no-progress
vendor/bin/phpcs src/Performance/BorrowedHtmlLayout.php src/Parser/BlockParser.php tests/BorrowedHtmlLayoutTest.php

After this merges, carve-bench will be refreshed against the new dev-main head as a separate final step.

@codecov

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.03797% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.18%. Comparing base (bb14c2a) to head (abed920).

Files with missing lines Patch % Lines
src/Performance/BorrowedHtmlLayout.php 92.19% 11 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #277      +/-   ##
============================================
- Coverage     92.26%   92.18%   -0.09%     
- Complexity     3896     3955      +59     
============================================
  Files           111      111              
  Lines         10923    11052     +129     
============================================
+ Hits          10078    10188     +110     
- Misses          845      864      +19     

☔ 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.

@dereuromark
dereuromark merged commit 408e93c into master Aug 21, 2026
5 of 6 checks passed
@dereuromark
dereuromark deleted the perf/complete-html-fast-path branch August 21, 2026 02:07
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