Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: optimize IO read/write usage #8243

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

j2rong4cn
Copy link
Contributor

开发笔记

使用bytes.Buffer作为io.CopyBuffer的写入对象,CopyBuffer会调用Buffer.ReadFrom
即使被写入的数据量与Buffer.Cap一致,Buffer也会扩大

@j2rong4cn j2rong4cn marked this pull request as ready for review March 27, 2025 16:21
Copy link

Could you please provide the PR number or a link to the PR you would like me to review?

Copy link

It seems like you want me to review a pull request with the number #8243. However, I need more details about the repository name or any specific files or lines you want me to focus on. Could you please provide that information?

Copy link

It seems that I'm unable to directly access the content of the pull request #8243 from the repository AlistGo/alist. If you have specific files or lines within the PR that you would like me to review, please provide more details, and I'll do my best to assist you.

@xhofe xhofe requested a review from Copilot March 28, 2025 07:42
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR optimizes IO read/write usage and improves file caching and hashing operations for various drivers by switching to stream‐based methods and the new utility functions.

  • Replaces several instances of io.Copy with utils.CopyWithBuffer to improve buffering and performance.
  • Updates file caching and hash computation calls by introducing stream.CacheFullInTempFileAndHash and related functions.
  • Adjusts temporary file handling in multiple drivers to support streaming uploads and rapid transfers.

Reviewed Changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 2 comments.

File Description
internal/model/obj.go Refactored FileStreamer interface by removing CacheFullInTempFileAndUpdateProgress and adding new methods.
internal/fs/archive.go, iso9660/utils.go, archives/utils.go Replaced io.Copy calls with utils.CopyWithBuffer to optimize IO operations.
drivers/* Multiple drivers now use updated caching and hashing methods for improved performance and resource management.
Comments suppressed due to low confidence (1)

drivers/mopan/driver.go:269

  • The removal of the file.Close() defer might lead to unclosed file handles; please ensure the temporary file is closed properly to avoid resource leaks.
defer func() { _ = file.Close() }

@j2rong4cn
Copy link
Contributor Author

好了,现在这个PR就只修改了缓存相关的。 @Mmx233

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.

降低IO占用
1 participant