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

perf: Cache deciphered n-params by info response #505

Merged
merged 1 commit into from
Sep 17, 2023

Conversation

absidue
Copy link
Collaborator

@absidue absidue commented Sep 15, 2023

Currently for web responses at least, the adaptiveFormats and the formats each share one n-param value (two in total), per /player call (Innertube#getInfo and Innertube#getBasicInfo in YouTube.js). This pull request introduces a response level cache, meaning that calling .decipher on Format objects from the same response multiple times, will now use the already deciphered n-param, as long as it is the same as one of the ones in the cache. The way it is designed, it doesn't make any assumptions on the number of n-param values, so if YouTube starts using a unique one for every URL, this code will continue to work, it will just make the cache useless.

In my testing this resulted in the toDash function being on average more than 50% faster.

@LuanRT LuanRT merged commit d2959b3 into LuanRT:main Sep 17, 2023
@absidue absidue deleted the decipher-perf branch September 18, 2023 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants