Skip to content

优化 ArchiveFileTree 构建性能 - #6838

Merged
Glavo merged 7 commits into
HMCL-dev:mainfrom
Glavo:build-tree
Sep 8, 2026
Merged

优化 ArchiveFileTree 构建性能#6838
Glavo merged 7 commits into
HMCL-dev:mainfrom
Glavo:build-tree

Conversation

@Glavo

@Glavo Glavo commented Sep 8, 2026

Copy link
Copy Markdown
Member

根据 JFR 结果,ArchiveFileTree 创建时的性能开销是另一个热点。本 PR 优化了构建 ArchiveFileTree 的性能,减少了内存分配。

@github-actions github-actions Bot added the 100+ label Sep 8, 2026
@Glavo

Glavo commented Sep 8, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-08T08:38:50.427868Z ebca625 Manual request
ℹ️ 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.

@Glavo
Glavo merged commit 9c031c5 into HMCL-dev:main Sep 8, 2026
3 checks passed
@Glavo
Glavo deleted the build-tree branch September 8, 2026 08:37

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ebca625d38

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +111 to +113
ZipArchiveEntry entry = reader.getEntry(entryPath);
if (entry != null)
return entry;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Apply tree filtering before returning ZIP entries

When a ZIP contains an entry that addEntry rejects—such as a/file.txt after a file named a, or a path containing a .. parent component—this fast path still returns that exact entry directly from the reader. As a result, ZipFileTree.getEntry and helpers such as readTextEntry can access entries that the new conflict/traversal policy says were skipped, unlike TarFileTree and tree traversal. Only return the direct result when it is known to be valid under the same filtering rules, or resolve the lookup through the filtered tree.

Useful? React with 👍 / 👎.

Comment on lines +53 to +54
if (root == null) {
root = new Dir<>("");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Publish the lazy root only after construction

If two threads first call getRoot() on the same tree concurrently, the first call publishes root before adding any entries, so the second call can observe and return an empty or partially populated tree. Both ZIP and TAR implementations use this pattern, regressing concurrent read access from the previously eager, fully constructed root; build into a local variable and publish it with synchronization or another safe lazy-initialization mechanism.

Useful? React with 👍 / 👎.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant