Skip to content

decrease disk cache overhead#8227

Merged
arvidn merged 1 commit intomasterfrom
disk-cache-space
Mar 29, 2026
Merged

decrease disk cache overhead#8227
arvidn merged 1 commit intomasterfrom
disk-cache-space

Conversation

@arvidn
Copy link
Copy Markdown
Owner

@arvidn arvidn commented Mar 25, 2026

only keep a pointer rather than a whole disk_buffer_holder in the cached_block_entry in the cache, decreasing the overhead of the cache.

@arvidn arvidn requested a review from Copilot March 25, 2026 16:13
@arvidn arvidn marked this pull request as ready for review March 25, 2026 16:19
Copy link
Copy Markdown

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 reduces disk cache per-block memory overhead by replacing stored disk_buffer_holder ownership in cache entries with a pointer-only reference, and plumbing piece sizing to support correct block-span sizing during hashing.

Changes:

  • Introduces disk_buffer_ref and updates cache block entries to store pointer-only buffer ownership.
  • Updates disk_cache to compute correct per-block span sizes (including shorter last blocks) via a new piece_size parameter.
  • Adjusts disk I/O and unit tests to provide the new piece sizing metadata to the cache.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
include/libtorrent/disk_buffer_holder.hpp Adds disk_buffer_ref; changes bulk_free_buffer ctor/add API.
src/disk_buffer_holder.cpp Implements disk_buffer_ref moves and new bulk_free_buffer::add.
include/libtorrent/aux_/disk_cache.hpp Switches cached_block_entry to disk_buffer_ref; updates buffer access API and piece params; adds cache allocator member.
src/disk_cache.cpp Implements new buffer accessors and updates hashing/flush/free paths to use pointer-only buffer refs and batched frees.
src/pread_disk_io.cpp Supplies new piece_size field when inserting cache blocks.
test/test_disk_cache.cpp Updates test fixture piece params to include piece_size.
include/libtorrent/fwd.hpp Forward-declares disk_buffer_ref.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

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

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@arvidn arvidn force-pushed the disk-cache-space branch 3 times, most recently from c641e1b to 9f5fb81 Compare March 27, 2026 08:27
@arvidn arvidn requested a review from Copilot March 27, 2026 08:28
Copy link
Copy Markdown

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

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

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

Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

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

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@arvidn arvidn force-pushed the disk-cache-space branch from 256b3a6 to 6774d45 Compare March 28, 2026 18:54
…hed_block_entry in the cache, decreasing the overhead of the cache
Copy link
Copy Markdown

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

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@arvidn arvidn merged commit 8a43b43 into master Mar 29, 2026
54 checks passed
@arvidn arvidn deleted the disk-cache-space branch March 29, 2026 09:44
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.

2 participants