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

VideoClient.GetAsync is extremely slow #459

Closed
MichalPetryka opened this issue Oct 20, 2020 · 4 comments
Closed

VideoClient.GetAsync is extremely slow #459

MichalPetryka opened this issue Oct 20, 2020 · 4 comments

Comments

@MichalPetryka
Copy link

MichalPetryka commented Oct 20, 2020

While profiling our youtube playback code i've noticed that VideoClient.GetAsync takes about 2.3 seconds to complete (as you can see on this screenshot in the last column).
image

Playback dely resulting from this is quite noticeable and really impacts user experience.
We can reproduce this behaviour on every try.

@Tyrrrz
Copy link
Owner

Tyrrrz commented Oct 20, 2020

Performance improvements are always welcome.

@Tyrrrz
Copy link
Owner

Tyrrrz commented Mar 22, 2021

Can someone profile this with clear separation between CPU-bound operations and IO-bound operations? I want to know how much of the time is actually taken by tasks we can optimize vs just network requests to YouTube which are likely unavoidable.

@MichalPetryka
Copy link
Author

Doing time youtube-dl https://www.youtube.com/watch?v=dQw4w9WgXcQ --get-title --skip-download takes 1.55s, this includes whole python interpreter startup, just time youtube-dl takes it 0.7s to print a no url error, so the request itself seems to take about 0.8.
Meanwhile this code:

private static async Task Main(string[] args)
{
    YoutubeClient client = new();
    Stopwatch sw = Stopwatch.StartNew();
    Video video = await client.Videos.GetAsync(args[0]);
    Console.WriteLine(sw.Elapsed.ToString());
    Console.WriteLine(video.Title);
}

with the same video provided takes 4.7s just to do the GetAsync (time from the stopwatch, so it doesn't include whole runtime startup), so I'd say there must be a lot of room for improvements.

@Tyrrrz
Copy link
Owner

Tyrrrz commented Dec 10, 2021

Try the new version, I removed a lot of code from this flow. It should be faster now.

@Tyrrrz Tyrrrz closed this as completed Dec 10, 2021
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

2 participants