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

Buffer for writable blocks #8

Open
atomashpolskiy opened this issue Apr 19, 2017 · 1 comment
Open

Buffer for writable blocks #8

atomashpolskiy opened this issue Apr 19, 2017 · 1 comment

Comments

@atomashpolskiy
Copy link
Owner

Currently blocks are written to disk immediately in the same order that they arrive from peers (which in most cases is random). Quite obviously, this behaves poorly on storage devices with non-random access. We should implement an intermediate in-memory buffer of configurable size to hold the arriving blocks until a piece (or a number of pieces) is complete. When the piece(-s) is complete, it can be verified and written to disk. This will eliminate a big number of disk seeks, esp. if adjacent pieces are flushed to disk in one batch, and also the reads that are made during piece verification.

@atomashpolskiy
Copy link
Owner Author

Additionally (and in fact most importantly from the overall correctness of the program point of view), this will prevent writing invalid data to the end storage. While it is not significant in case of standard mode of operation, when the torrent data is fully downloaded and verified before being used, it is critical for streaming (e.g. media player will most probably crash when encountering invalid data).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant