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

Input: Fix high CPU use when initialising long files over HTTP #163

Merged
merged 2 commits into from
Mar 11, 2023

Conversation

FelixMcFelix
Copy link
Member

Fixes the possibility of a spinlock while reading bytes from an async->sync adapter. This case can be observed with long (e.g., 10 hours of silence) videos which seem to be served slower than we would like to parse their headers.

The fix moves most communication to blocking: read calls first parse all messages form the async context in a non-blocking way, then swap to blocking if no bytes are available.

Tested using cargo make ready and "examples/serenity/voice" against the URL https://www.youtube.com/watch?v=g4mHPeMGTJM.

Fixes the possibility of a spinlock while reading bytes from an async->sync adapter. This case can be observed with long (e.g., 10 hours of silence) videos which seem to be served slower than we would like to parse their headers.

The fix moves most communication to blocking: `read` calls first parse all messages form the async context in a non-blocking way, then swap to blocking if no bytes are available.

Tested using `cargo make ready` and "examples/serenity/voice" against the URL https://www.youtube.com/watch?v=g4mHPeMGTJM.
@FelixMcFelix FelixMcFelix added input Relates to raw audio data handling. fix Fixes a bug or error labels Mar 11, 2023
@FelixMcFelix FelixMcFelix merged commit 67e192e into serenity-rs:next Mar 11, 2023
FelixMcFelix added a commit to FelixMcFelix/songbird that referenced this pull request Nov 20, 2023
…ity-rs#163)

Fixes the possibility of a spinlock while reading bytes from an async->sync adapter. This case can be observed with long (e.g., 10 hours of silence) videos which seem to be served slower than we would like to parse their headers.

The fix moves most communication to blocking: `read` calls first parse all messages form the async context in a non-blocking way, then swap to blocking if no bytes are available.

Tested using `cargo make ready` and "examples/serenity/voice" against the URL https://www.youtube.com/watch?v=g4mHPeMGTJM.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Fixes a bug or error input Relates to raw audio data handling.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant