Skip to content

perf: parse rar and 7z listings faster - #548

Open
liuwenhuan wants to merge 1 commit into
linuxdeepin:masterfrom
liuwenhuan:perf-list-parsing
Open

liuwenhuan wants to merge 1 commit into
linuxdeepin:masterfrom
liuwenhuan:perf-list-parsing

Conversation

@liuwenhuan

@liuwenhuan liuwenhuan commented Nov 9, 2026 •

Copy link
Copy Markdown

Opening a 5-volume RAR archive with 3542 entries (38387 lines of unrar vt -v output) took about 16 s of CPU in the GUI thread. unrar itself writes the listing in 0.2 s. Almost all of the time goes to two things:

  • CliRarPlugin::readListLine() built and JIT-compiled the version-line QRegularExpression for every line. It is now static and only matched until the version line is found.
  • Both CLI plugins parsed every entry time with QDateTime::fromString(text, "yyyy-MM-dd hh:mm:ss"), whose format parser costs tens of microseconds per call. The time is now split into QDate/QTime when it has exactly that form, which gives the same local time. Anything else still goes through fromString. The 7z fractional-seconds handling on master is unchanged and runs before this.

Measured with a small program that replays the plugin's per-line work on that real listing (Qt 6.8.2):

UTC TZ=Asia/Shanghai
before 2.79 s 5.22 s
static regex only 1.35 s 3.77 s
static regex + QDate/QTime 0.19 s 0.58 s

Every entry gets the same time in all variants.

In the application, a 3542-entry RAR (the same paths, empty files) loads in 0.9 s instead of 5.5 s, and the file list shows the same modification times. That was measured in a VM on deepin-compressor 6.5.32.3 with this change backported. This PR compiles on master (6.5.40).


打开一个 3542 个条目的 RAR 包时,界面线程大部分时间花在每行重新编译正则和每个条目调用 QDateTime::fromString 上。本 PR 把正则改为静态对象,时间严格是 yyyy-MM-dd hh:mm:ss 格式时直接拆成 QDate/QTime,结果不变。列表解析在上海时区从 5.2 秒降到 0.58 秒。

Summary by Sourcery

Enhancements:

  • Speed up RAR and 7z listing parsing by reusing version-line regular expressions and optimizing common timestamp parsing while preserving existing modification times and fallback behavior.

1. Opening a 5-volume RAR archive with 3542 entries (38387 listing lines)
   took about 16 s of CPU in the GUI thread.
2. CliRarPlugin::readListLine() built and JIT-compiled the version-line
   regular expression for every line; it is now static and only matched
   until the version line is found.
3. Both plugins parsed every entry time with
   QDateTime::fromString(text, "yyyy-MM-dd hh:mm:ss"), whose format parser
   costs tens of microseconds per call. The time is now split into
   QDate/QTime when it has exactly that form (same local-time result);
   anything else still goes through fromString.

Log: Open large RAR and 7z archives several times faster.

Influence:
1. Parsing that listing (Qt 6.8.2): 5.2 s -> 0.58 s with
   TZ=Asia/Shanghai, 2.8 s -> 0.19 s in UTC; the same time for every entry.
2. A 3542-entry RAR archive loads in 0.9 s instead of 5.5 s; the file list
   shows the same modification times.

perf: 加快 rar 和 7z 列表解析

1. 打开一个 5 卷、3542 个条目(38387 行列表输出)的 RAR 包,界面线程
   要花约 16 秒 CPU。
2. CliRarPlugin::readListLine() 每读一行都重新创建并 JIT 编译版本行的正则,
   改为静态对象,且只在找到版本行之前匹配。
3. 两个插件都用 QDateTime::fromString(text, "yyyy-MM-dd hh:mm:ss") 解析每个
   条目的时间,格式解析每次要几十微秒。时间严格是这个格式时改为拆成
   QDate/QTime(本地时间结果相同),其他情况仍走 fromString。

Log: 打开大型 RAR、7z 包快数倍。

Influence:
1. 解析上述列表(Qt 6.8.2):上海时区 5.2 秒 -> 0.58 秒,UTC 2.8 秒 -> 0.19 秒,
   每个条目的时间一致。
2. 3542 个条目的 RAR 包加载从 5.5 秒降到 0.9 秒,文件列表显示的修改时间不变。
@sourcery-ai

sourcery-ai Bot commented Nov 9, 2026

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Add a fast path for strictly formatted listing timestamps while retaining the existing parser as a fallback in both plugins.

  • 3rdparty/cli7zplugin/cli7zplugin.cpp L181-197, L291-295
  • 3rdparty/clirarplugin/clirarplugin.cpp L29, L179-195, L268

Make the RAR version-line regular expression static and match it only while parsing the header states.

  • 3rdparty/clirarplugin/clirarplugin.cpp L200-202, L207

Make the 7z version-line regular expression static to avoid reconstructing it for every listing line.

  • 3rdparty/cli7zplugin/cli7zplugin.cpp L213

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

CLA Assistant Lite bot:

如果你是以企业贡献者的身份进行提交,请联系我们签署企业贡献者许可协议
If you submit as corporate contributor, please contact us to sign our Corporate Contributor License Agreement

感谢您的提交,我们非常感谢。 像许多开源项目一样,在接受您的贡献之前,我们要求您签署我们的个人贡献者许可协议。 您只需发布与以下格式相同的评论即可签署个人贡献者许可协议。
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Individual Contributor License Agreement before we can accept your contribution. You can sign the Individual Contributor License Agreement by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA.

You can retrigger this bot by commenting recheck in this Pull Request

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T01:27:18.959500Z ddc8712 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

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