-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
perf(stream): improve file stream range reading and caching mechanism #1001
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
Conversation
There was a problem hiding this 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 improves the file stream range reading and caching mechanism by refactoring the buffer management system and enhancing the max_buffer_limitMB configuration option usage. The changes focus on streamlining caching operations, improving memory management, and providing better progress tracking for file operations.
- Refactors
CacheFullInTempFiletoCacheFullAndWriterwith enhanced functionality and progress tracking - Introduces a new
Bytesbuffer type for efficient non-reusable byte slice storage - Updates method signatures across drivers to use pointer-based progress tracking and renamed section reader methods
Reviewed Changes
Copilot reviewed 45 out of 45 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/errgroup/errgroup.go | Minor comment updates for clarity |
| pkg/buffer/bytes.go | New buffer implementation for managing multiple byte slices |
| pkg/buffer/bytes_test.go | Comprehensive tests for the new Bytes buffer functionality |
| internal/stream/stream.go | Major refactoring of FileStream with new caching logic and buffer management |
| internal/stream/util.go | Updated utility functions and renamed RecycleSectionReader to FreeSectionReader |
| internal/stream/stream_test.go | Tests for the refactored stream functionality |
| internal/model/obj.go | Updated FileStreamer interface with new method signatures |
| internal/conf/var.go | Set default MaxBufferLimit value |
| internal/bootstrap/config.go | Improved logging format for buffer limit |
| drivers/* | Updated all drivers to use new CacheFullAndWriter method and pointer-based progress tracking |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: j2rong4cn <36783515+j2rong4cn@users.noreply.github.com>
|
@j2rong4cn 大佬,有部分网盘会获取preHash,如115和阿里,但获取preHash后,再调用CacheFullAndHash返回的hash值是错的,能不能修复下,下面这个测试能重现: 去掉前面的preHash调用,才能获取到正确的hash值 |
|
@bitxeno 发现这么隐蔽的bug,真的帮大忙了,感谢 |
完善配置选项max_buffer_limitMB的使用场景
配置选项 max_buffer_limitMB
自动: -1 (默认):5%的总内存
关闭:0
自定义:大于0 单位为MB
close #787
close #1039