Repository navigation
[6022] 优化极限超长文档排版性能:边框盒增量装配与调度吞吐加速 - #4727
Merged
Merged
Conversation
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.
任务背景与问题剖析
在任务 [6021] 中,渐进排版针对中等规模长文档实现了秒级排版;但在面对极限规模文档(如
vol05.stem,17,176 页,8.9 万段落,26 万行)时,完整排版全书仍需 130 秒左右。瓶颈主要在于:
page_border_box,并在scatter_box中重复计算全量矩形差集;doc_l伴随文档推进不断向后堆叠至 26 万项,内存深浅拷贝与切片带宽开销大。优化方案
typesetter_rep与pager_rep中引入已成熟页面的边框盒缓存数组frozen_border_boxes;pager_rep::make_pages()中对成熟冻结页面直接复用已有边框盒,仅对本轮新切片生成的页面构建边框盒,消除每轮上万次的边框盒重复构造与堆内存开销;scatter_box,在常规分页带边框模式下(边框盒已完整覆盖视口并自绘制衬边)避免多余的全局矩形差集裁剪。progressive_batch_size上限从 150 放宽至 500 段,并配合切片耗时阶梯式加速,将全书调度批次减少约 4 倍。验证结果
vol05.stem(17,176 页):全生命周期排版耗时从优化前 130 秒 / 83 秒大幅缩短至 37~38 秒(下降超 70%),首屏即时秒开呈现,后台平滑推进无卡顿;xiyouji.stem(433 页):排版耗时稳定在 3 秒左右(净排版 ~2.4 秒),零回归;