Repository navigation
Drop float records the layout has already buried (v6) - #819
Merged
Merged
Conversation
$floatDivs is a document-global list of every float the document has closed. It was emptied only in the constructor, yet GetFloatDivInfo() reads all of it every time a float is placed, so a long document of floated rows degrades to O(n^2) — 1000 rows of a 9-column float grid took 34s, against 2.6s once the list stays bounded. Route both float records through addFloatDiv(), which first drops the records that ended at or above where the incoming float starts. Those can no longer satisfy GetFloatDivInfo()'s `$currpos < $f['endpos']` test, because layout only moves forward from there. Pruning is scoped to the incoming float's own block formatting context, since ClearFloats matches on blockContext alone and ignores position. The comparison is against the incoming float's start rather than the current cursor because the cursor rewinds to the top of the float just written; a backwards jump then prunes nothing rather than pruning wrongly. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
gravitypdf-bot
added a commit
to GravityPDF/gravity-pdf
that referenced
this pull request
Oct 26, 2026
…hing it GravityPDF/mpdf's gravitypdf-v6 branch is upstream mPDF's development HEAD (a981bb7b) plus the float pruning (GravityPDF/mpdf#819, from #9) and the Cache fix for writable directories is_writable() calls read-only (GravityPDF/mpdf#820, #708). Composer installs it from there, so the php-scoper patchers that applied both fixes while prefixing are gone, and a future mPDF update brings them along instead of failing the build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 tasks
gravitypdf-bot
added a commit
to GravityPDF/gravity-pdf
that referenced
this pull request
Oct 26, 2026
… floats mPDF keeps every float it has closed in a document-wide list and rescans all of it each time it places a float, so a long layout of floated rows slows down quadratically. PDF for GravityView 2.0.0 stops pruning that list itself on Gravity PDF 6.18, because it expects 6.18 to bundle the fork's fix (GravityPDF/mpdf#9), but 6.18 bundled upstream mPDF. A 1,000-row directory PDF took 7.8 s instead of 1.9 s. GravityPDF/mpdf's gravitypdf-v6 branch is upstream mPDF's development HEAD (a981bb7b) plus the float pruning (GravityPDF/mpdf#819, from #9) and the Cache fix for writable directories is_writable() calls read-only (GravityPDF/mpdf#820, #708). Composer installs it from there, so the php-scoper patcher for the Cache fix is gone, and a future mPDF update brings both fixes along instead of failing the build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gravitypdf-bot
added a commit
to GravityPDF/gravity-pdf
that referenced
this pull request
Oct 26, 2026
… floats mPDF keeps every float it has closed in a document-wide list and rescans all of it each time it places a float, so a long layout of floated rows slows down quadratically. PDF for GravityView 2.0.0 stops pruning that list itself on Gravity PDF 6.18, because it expects 6.18 to bundle the fork's fix (GravityPDF/mpdf#9), but 6.18 bundled upstream mPDF. A 1,000-row directory PDF took 7.8 s instead of 1.9 s. GravityPDF/mpdf's gravitypdf-v6 branch is upstream mPDF's development HEAD (a981bb7b) plus the float pruning (GravityPDF/mpdf#819, from #9) and the Cache fix for writable directories is_writable() calls read-only (GravityPDF/mpdf#820, #708). Composer installs it from there, so the php-scoper patcher for the Cache fix is gone, and a future mPDF update brings both fixes along instead of failing the build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gravitypdf-bot
added a commit
to GravityPDF/gravity-pdf
that referenced
this pull request
Oct 26, 2026
… floats (#1951) mPDF keeps every float it has closed in a document-wide list and rescans all of it each time it places a float, so a long layout of floated rows slows down quadratically. PDF for GravityView 2.0.0 stops pruning that list itself on Gravity PDF 6.18, because it expects 6.18 to bundle the fork's fix (GravityPDF/mpdf#9), but 6.18 bundled upstream mPDF. A 1,000-row directory PDF took 7.8 s instead of 1.9 s. GravityPDF/mpdf's gravitypdf-v6 branch is upstream mPDF's development HEAD (a981bb7b) plus the float pruning (GravityPDF/mpdf#819, from #9) and the Cache fix for writable directories is_writable() calls read-only (GravityPDF/mpdf#820, #708). Composer installs it from there, so the php-scoper patcher for the Cache fix is gone, and a future mPDF update brings both fixes along instead of failing the build. Co-authored-by: gravitypdf-bot <support@gravitypdf.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
Brings the float pruning from #9 to
gravitypdf-v6, the branch Gravity PDF 6.x bundles. It's upstreammpdf/mpdfdevelopment(a981bb7) with Gravity PDF's fixes on top. Without it, PDF for GravityView 2.0.0 directory PDFs slow down quadratically on Gravity PDF 6.18, because PDF for GravityView stops pruning floats itself there (GravityPDF/gravity-pdf#1951).Mpdf::addFloatDiv()drops the float records a new float has buried in its block formatting context, andTag\BlockTagrecords both of its floats through it.FloatDivTestandUnprunedFloatsMpdfwith it.Try it
Write a few hundred cleared rows of three floated
<div>s, oneWriteHTML()call per row, and check$mpdf->floatDivsstays at 3 records instead of growing with every row.Test plan
vendor/bin/phpunit tests/Mpdf/FloatDivTest.phppasses (13 tests) on PHP 8.5More info
🤖 Generated with AI