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

Defer Store Verification #1350

Open
wants to merge 5 commits into
base: master
from
Open

Defer Store Verification #1350

wants to merge 5 commits into from

Conversation

@KayleePop
Copy link
Contributor

KayleePop commented Apr 12, 2018

This PR is to fix the problem demonstrated here: https://jsfiddle.net/1g80d0aj/18/
The entire store needs to be verified before any files in the torrent can be accessed or streamed. This leads to a massive delay in appending the video when using a store with a significant read time instead of the default in-memory store. (this is the indexeddb chunk store used in the demo).

To fix this, I made the 'ready' event fire before store verification finishes, and any calls to _request() are cancelled if that piece hasn't yet been checked for in the store.

Critical pieces are verified immediately instead of being waited for in the parallelLimit() queue, and requests for critical pieces aren't cancelled before verification like normal pieces. This allows file streams to work as quickly as possible.

(EDIT: Critical pieces are now also cancelled before verification)

Here's the same demo but using a minified build from this PR instead of the latest webtorrent build. https://jsfiddle.net/6r2hgxf5/11/

 

Viewing this one commit at a time might make the changes clearer.

@KayleePop KayleePop force-pushed the KayleePop:master branch 3 times, most recently from 431d26f to fc59d19 Apr 20, 2018
KayleePop added 4 commits Apr 11, 2018
Allow file access before the entire store has been validated.

Critical pieces are validated immediately instead of waiting in the
parallelLimit() queue.
This avoids confusion with setting an index in _verified[] to true.
This function isn't useful anymore because store verification happens
after the 'ready' event.
Specify whether the verification was on a piece in the store, or on a piece from a wire.
This makes metadata always available before every request, and race
conditions between verification and downloading aren't possible.

Critical pieces are still prioritized for verification.
@stale

This comment has been minimized.

Copy link

stale bot commented Sep 16, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale label Sep 16, 2018
@stale stale bot closed this Sep 23, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jan 1, 2019
@webtorrent webtorrent unlocked this conversation Sep 5, 2019
@feross feross added the enhancement label Sep 5, 2019
@feross feross reopened this Sep 5, 2019
@stale stale bot removed the stale label Sep 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.