Skip to content

perf: optimize IO read/write usage#8243

Merged
xhofe merged 4 commits intoAlistGo:mainfrom
j2rong4cn:perf
Apr 12, 2025
Merged

perf: optimize IO read/write usage#8243
xhofe merged 4 commits intoAlistGo:mainfrom
j2rong4cn:perf

Conversation

@j2rong4cn
Copy link
Copy Markdown
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
@petercat-assistant
Copy link
Copy Markdown

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

@petercat-assistant
Copy link
Copy Markdown

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?

@petercat-assistant
Copy link
Copy Markdown

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
Copy Markdown
Contributor

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() }

Comment thread drivers/139/driver.go Outdated
Comment thread drivers/189pc/utils.go
@j2rong4cn
Copy link
Copy Markdown
Contributor Author

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

Comment thread drivers/139/driver.go
Comment thread drivers/139/driver.go
Comment thread drivers/139/driver.go
Co-authored-by: MadDogOwner <xiaoran@xrgzs.top>
@xhofe xhofe merged commit ddffacf into AlistGo:main Apr 12, 2025
12 checks passed
@j2rong4cn j2rong4cn deleted the perf branch April 12, 2025 09:26
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占用

4 participants