-
Notifications
You must be signed in to change notification settings - Fork 95
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
Daemon is very slow to start on Windows #12
Comments
So I went over commits and the whole python codebase, to finally just checking enabled Services and Program add-ons, disabling a few, notably "TvTunes" that was causing this warning while Quasar was launching:
And what do you know, Quasar now launches in under 10 seconds consistently instead of 30-40s. When reinstalling Quasar, and Kodi isn't launching other stuff, it easily starts in under 5 seconds, and pretty much instantly on Intel CPUs. So folks, please check your currently installed add-ons if you have this issue. Since Quasar launches as a service, the time it takes to do so can be greatly affected by other badly behaving add-ons. |
So I've tried to do some digging in my specific situation, but haven't been able to pinpoint badly behaving addons. I'm currently running Quasar v0.9.33 on a Windows 8.1 machine, and it takes about 50 seconds for the daemon to start. Do you see any obvious culprits? |
same here, 50 seconds. it used to be about 30 but after the trakt lists integration it became about 50. |
This seems to affect Windows a lot more than other platforms, as it starts almost instantly on the few rpi3 I tried. |
yeah, it's just windows. on my crappy galaxy s2 the daemon starts in 5 seconds. |
For me it starts around 40-50 sec. but honestly I don't see where the problem is xDD Quasar working damn good for me, it's my number 1 multimedia addon and I hope it will stays like that for years to come so a couple of seconds to wait for deamon to start is nothing as Quasar worth every second. The only thing I prays to finally get work is utilization of private trackers, that's all. |
I don't know why but I have something telling me this might be caused by anti-virus software, but I'll try to test it when I have some time and am at home, which might not be for a couple of days since it's Easter... If anyone want's to test it before then, it would be helpful. I'm not just saying this out of nowhere btw. I've seen people on windows that had a ton of delay between choosing the source and actually starting the buffering that was resolved by whitelisting quasar.exe and/or kodi.exe (don't remember which one it was that worked at the time). It literally went from choosing the movie, waiting 2+ minutes (some times it was way more) and starting buffering, to choosing the movie, waiting 2 seconds and starting buffering. At first I tested it by actually disabling the anti-virus because I saw it was using the HDD a lot which makes sense, it want's to check the file you're downloading. Disabling it fixed the problem, so I tried whitelisting and it was enough. At the time I didn't test for startup time because I didn't know there was a problem with it. When I used the system it would already be on for a few minutes. |
Last I checked in a VM there was no anti-virus software, and the daemon still took 40-50 seconds to start. |
Maybe quasar should throw an error other than 10061 instead indicating the daemon has not yet started. I wait for the onscreen notification that the daemon has started before clicking the quasar shortcut. |
From the log it seems like one of these calls is causing the delay (in main.go):
EDIT: using fiddler it seems like that wasn't the case and config.Reload() is causing the delay. Each call takes a second:
|
Thanks, that's a good start and useful debugging info. I don't have a lot of time lately so it will be while until I can look into this but this should help narrowing it down. |
I've found the issue. it's basically this line: |
Looking into the issue more (why isn't there an ipv6 server), the bug is in the bjsonrpc package being used, it's hardcoded to use ipv4, so I assume this bug is in all OS, just that on windows, connect has a longer delay. I guess long-term a PR should be submitted to @deavid : But if someone wants a temporary fix on the python side, here it is: def createserver(host="localhost", port=10123, handler_factory=bjsonrpc.handlers.NullHandler):
for res in socket.getaddrinfo(host, port, socket.AF_UNSPEC, socket.SOCK_STREAM, 0, socket.AI_PASSIVE):
af, socktype, proto, canonname, sa = res
try:
sck = socket.socket(af, socktype, proto)
except socket.error as msg:
sck = None
continue
try:
sck.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sck.bind(sa)
sck.listen(3)
except socket.error as msg:
sck.close()
sck = None
continue
break
return bjsonrpc.server.Server(sck, handler_factory=handler_factory) |
@tzickel 5-6 seconds till daemon starts, cache cleared instantly after settings changes, great work. |
Toda, you can still skim 2-3 more seconds (maybe, haven't checked) from startup if the go json-rpc code would re-use the same socket, instead of opening 50 sockets, to read 50 configuration items :) but maybe @scakemyer had a reason for doing it like this ? |
@tzickel thanks for the mention. I'm glad to see you're using bjsonrpc. First of all, feel free to submit any PR to bjsonrpc. I accept almost everything that enhances anything and doesn't have any fallback for old code. There are things that I don't understand here. "createserver" is a helper function, and is perfect to create your own in your project fullfilling your needs. "bjsonrpc.server.Server" constructor should remain compatible. The problem to me, appears to your client and server doesn't agree on which interface to use. And createserver doesn't have IPv4 hardcoded, it has as a default a listen address, which may fit your needs or not, but that doesn't mean the function isn't capable of IPv6, right? Your personalization of createserver is doing a local dns resolution and is relying on what the OS says for localhost. Then you bind to the first socket available in the list. Isee this approach better than the old one in my library, but I would like to comment several things on that:
The correct solution would be to bind on localhost on IPv4 and IPv6 at the same time. But that isn't possible in bjsonrpc as it has only a single listen socket, and a listen socket seems to be tied to IPv4 or IPV6, not both. I don't use IPv6 anywhere so this isn't useful for me, but I think we will need that sooner or later. @tzickel notes the client is using 50 sockets (depending config) to read the configuration. Bjsonrpc was meant to use a single connection for all. Maximum say 2 or 3 for redundancy or other reasons. Each time you open a connection, you need to transmit the SYN and ACK packets, and it takes time. If TCP connections weren't expensive, probably I would ended using other of json-rpc libraries instead of doing my own. Probably on localhost doesn't add time, I never checked. Most important on using lots of connections is to reduce parallel connections to bjsonrpc at a minimum. Close them if you're done with them. I had a serious issue because a C# application on a handheld keep reconnecting to the server and let the sockets open. When the list reaches to 1024 sockets, in Linux you hit the maximum open FD's. And then the server stops serving to new connections. Hope this is helpful for you. |
Hi @deavid , This is the first time I've seen this project (quasar) and bjsonrpc, so I would hardly call myself a direct user of bjsonrpc. I have just seen a bad use-case of quasar on Windows which caused me annoyance and decided to look into it. I admit that the code I've written here is just a quick patch to fix the annoyance, it is not PR quality, and this is why it's not a PR, but a quick band-aid for anybody who wants to use it. (It's also much easier to change python code, instead of recompiling go code). While I don't agree with all your comments regarding the code, it doesn't matter, I too think that @scakemyer should just nix (or make it a fallback) the ipv6 code, as I've stated in the previous comment here. Also, there is something called dual-stack, which mean you can auto listen with one single socket to both ipv6 and ipv4: Reading the go code, it does seem to take care of at least closing the socket when the RPC call is finished. |
Hi @scakemyer, Instead of removing ipv6, just change places and you will have the same result. From: To: |
I've been going over our commits multiple times, mistakenly thought it was the new translation support (my apologies @i96751414), and still can't pinpoint what caused the slow loading times. It might be from the libtorrent-go stack, but from the logs it just looks like it takes a lot of time for Kodi to even trigger starting the daemon, after which it starts in a very decent amount of time. So I suspect the issue really lies on the Python side.
The text was updated successfully, but these errors were encountered: