Code Monkey home page Code Monkey logo

Comments (10)

cenkalti avatar cenkalti commented on May 17, 2024

Yes, that would be great. I think the interface is simple enough to be implemented in memory.

from rain.

cenkalti avatar cenkalti commented on May 17, 2024

This may also include some overlapping work for #19 .

from rain.

cenkalti avatar cenkalti commented on May 17, 2024

This project might worth checking out: https://github.com/spf13/afero

from rain.

cenkalti avatar cenkalti commented on May 17, 2024

Another resource: https://benjamincongdon.me/blog/2021/01/21/A-Tour-of-Go-116s-iofs-package/

from rain.

bsergean avatar bsergean commented on May 17, 2024

from rain.

cenkalti avatar cenkalti commented on May 17, 2024

I would like to help on debugging the issue. Can you elaborate how it is being abused? Is it read or write cache that is being abused? What is the access pattern?

I'd like to give some information about the current state of the read cache.

rain/torrent/config.go

Lines 146 to 153 in 4bda7a0

// Number of bytes to read when a piece is requested by a peer.
ReadCacheBlockSize int64
// Number of cached bytes for piece read requests.
ReadCacheSize int64
// Read bytes for a piece part expires after duration.
ReadCacheTTL time.Duration
// Number of read operations to do in parallel.
ParallelReads uint

When a piece is requested from Rain, it assumes that the peer will request blocks from the same piece again. For that reason, Rain reads more than the actual requested block size. It divides the piece in larger blocks of size ReadCacheBlockSize and read all at once.

Example:
Let's assume that torrent piece size is 256K peer will request blocks in size of 16K.

0123456789ABCDEF

If ReadCacheBlockSize is 128K (default value), from the perspective of read cache, torrent piece is divided to 128K blocks.

01234567  89ABCDEF

In ideal scenario, the peer starts requesting peers from the start in order. When the first block (0) is requested, Rain reads the range between 0 and 7 into memory and caches it. The following requests from 1 to 7 are served directly from cache without going to disk. For the next range between 8 and F, a second read is made from the disk.

from rain.

cenkalti avatar cenkalti commented on May 17, 2024

If peer requests pieces and blocks completely random, then the read cache will not be useful. If that is the case, you can try increasing ReadCacheSize.

from rain.

bsergean avatar bsergean commented on May 17, 2024

I might give this a try, but I noticed that my disk problem was completely unrelated to this library, so feel free to close this ticket, or use it for reference.

from rain.

github-actions avatar github-actions commented on May 17, 2024

This issue is stale because it has been open for 30 days with no activity.

from rain.

github-actions avatar github-actions commented on May 17, 2024

This issue was closed because it has been inactive for 14 days since being marked as stale.

from rain.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.