anki-connect
anki-connect copied to clipboard
Response taking SECONDS in MacOS :O
Dear all,
First of all, this is an awesome plugin, thanks for making it. The only issue I have is that it's slow for me. But is it normal? As I didn't see related issues.
Actions I've attempted that are slow: deckNames, findCards
Pretty much all my requests takes 5 seconds to get a response. Sometimes they take less than one second, but I still don't the reason for this. I used different clients to confirm this issue.
Using AnkiConnect v.6, latest Anki for mac and latest mac OS.
Any ideas ?
Best regards, Anderson
Just a few suggestions that you can try: What clients did you use to test this? Can you be absolutely certain that the problem is on the server side? Have you tried using it on a small collections/decks? (have you tried creating a new user with only one deck and testing it there?) If the problem is really on server side (AnkiConnect) try adding some debug messages (for example. on places where server receives request and on places where it sends response ...) and log how long it takes to performs each step.
Those are the things I would try first and then go from there.
Hi @bertoncelj1,
Thanks for your reply.
Basically I used cURL and a ruby client.
I didn't compute the time, but I added some messages to trap the requests / response and those took seconds. It's definitely Anki Connect.
But I wonder whether the anti-virus is doing some black magic that slows things down as well. I saw some requests for the same operation, e.g., store media, being slow and being super fast.
As I don't have anything concrete for now, I will close this issue. I wanted first to validated it was expected or not. Next time I come with more details, ways to reproduce or maybe the PR itself.
Thanks.
Anderson
I'm running macOS 10.15.3 and have invoked defaults write
as per the README
. I've just observed the following.
bash-3.2$ for i in `seq 10`; do time curl localhost:8765; done
AnkiConnect v.6
real 0m9.242s
user 0m0.005s
sys 0m0.010s
AnkiConnect v.6
real 0m3.991s
user 0m0.005s
sys 0m0.010s
AnkiConnect v.6
real 0m10.025s
user 0m0.005s
sys 0m0.011s
AnkiConnect v.6
real 0m0.841s
user 0m0.006s
sys 0m0.009s
AnkiConnect v.6
real 0m10.026s
user 0m0.005s
sys 0m0.009s
AnkiConnect v.6
real 0m2.675s
user 0m0.005s
sys 0m0.010s
AnkiConnect v.6
real 0m0.067s
user 0m0.008s
sys 0m0.019s
AnkiConnect v.6
real 0m0.057s
user 0m0.010s
sys 0m0.020s
AnkiConnect v.6
real 0m10.026s
user 0m0.005s
sys 0m0.010s
AnkiConnect v.6
real 0m5.439s
user 0m0.005s
sys 0m0.010s
So, response time varies by about two orders of magnitude (0.057s to 10.026s).
I've attached dtruss
and run curl
a few times.
When curl
returns immediately, I can see select
invocations scrolling by quickly in the dtruss
output i.e. something like the following every few seconds.
select(0x32, 0x7FFEE9A77AC0, 0x7FFEE9A77A40, 0x7FFEE9A779C0, 0x7FFEE9A779B0) = 0 0
select(0x32, 0x7FFEE9A77AC0, 0x7FFEE9A77A40, 0x7FFEE9A779C0, 0x7FFEE9A779B0) = 0 0
select(0x32, 0x7FFEE9A77AC0, 0x7FFEE9A77A40, 0x7FFEE9A779C0, 0x7FFEE9A779B0) = 0 0
select(0x32, 0x7FFEE9A77AC0, 0x7FFEE9A77A40, 0x7FFEE9A779C0, 0x7FFEE9A779B0) = 0 0
select(0x32, 0x7FFEE9A77AC0, 0x7FFEE9A77A40, 0x7FFEE9A779C0, 0x7FFEE9A779B0) = 0 0
select(0x32, 0x7FFEE9A77AC0, 0x7FFEE9A77A40, 0x7FFEE9A779C0, 0x7FFEE9A779B0) = 0 0
select(0x14, 0x7000081273F0, 0x700008127370, 0x7000081272F0, 0x7000081272E0) = 0 0
I can tell when an invocation of curl
will hang as prior to invoking it, nothing appears in the dtruss
output. I often see something like the following before output stops for a few seconds
dtrace: error on enabled probe ID 2381 (ID 903: syscall::thread_selfid:return): invalid user access in action #5 at DIF offset 0
poll(0x114830810, 0x1, 0x1F4) = 0 �y���0
select(0x14, 0x7000081273F0, 0x700008127370, 0x7000081272F0, 0x7000081272E0) = 0 �y���0
gettimeofday(0x7000081271A8, 0x0, 0x0) = 0 @z���0
psynch_cvsignal(0x106781308, 0x5D5000005D600, 0x5D500) = 257 �0
psynch_cvwait(0x60000296CD88, 0x100000100, 0x0) = -1 2316
gettimeofday(0x700009135878, 0x0, 0x0) = 0 0
select(0x32, 0x7FFEE9A77AC0, 0x7FFEE9A77A40, 0x7FFEE9A779C0, 0x7FFEE9A779B0) = 0 0
sysctlbyname(kern.memorystatus_vm_pressure_level, 0x23, 0x7FFEE9A8573C, 0x7FFEE9A85730, 0x0) = 0 0
psynch_cvwait(0x106781308, 0x5D5010005D600, 0x5D500) = 0 �y���0
poll(0x114830810, 0x1, 0x1F4) = 0 �y���0
select(0x32, 0x7FFEE9A77AC0, 0x7FFEE9A77A40, 0x7FFEE9A779C0, 0x7FFEE9A779B0) = 0 i2/addons21/2055492159/meta.json0
psynch_cvwait(0x60000298AE88, 0x100000100, 0x0) = -1 �y���316
gettimeofday(0x700009135878, 0x0, 0x0) = 0 0
Can this ticket please be reopened?
That's interesting. Just for sanity sake, trying it on Linux here:
[alex@flatline ~]$ for i in `seq 10`; do time curl localhost:8765; done
AnkiConnect v.6
real 0m0.039s
user 0m0.012s
sys 0m0.009s
AnkiConnect v.6
real 0m0.023s
user 0m0.013s
sys 0m0.005s
AnkiConnect v.6
real 0m0.025s
user 0m0.005s
sys 0m0.005s
AnkiConnect v.6
real 0m0.025s
user 0m0.006s
sys 0m0.004s
AnkiConnect v.6
real 0m0.025s
user 0m0.006s
sys 0m0.004s
AnkiConnect v.6
real 0m0.025s
user 0m0.006s
sys 0m0.004s
AnkiConnect v.6
real 0m0.025s
user 0m0.007s
sys 0m0.003s
AnkiConnect v.6
real 0m0.025s
user 0m0.009s
sys 0m0.001s
AnkiConnect v.6
real 0m0.025s
user 0m0.008s
sys 0m0.002s
AnkiConnect v.6
real 0m0.025s
user 0m0.006s
sys 0m0.004s
I wonder if this is still somehow related to AppNap. Can you try this test immediately after switching from Anki (and keeping it in view, if possible)? Would be interesting to see if that makes a difference.
That's interesting. Just for sanity sake, trying it on Linux here:
[alex@flatline ~]$ for i in `seq 10`; do time curl localhost:8765; done AnkiConnect v.6 real 0m0.039s user 0m0.012s sys 0m0.009s AnkiConnect v.6 real 0m0.023s user 0m0.013s sys 0m0.005s AnkiConnect v.6 real 0m0.025s user 0m0.005s sys 0m0.005s AnkiConnect v.6 real 0m0.025s user 0m0.006s sys 0m0.004s AnkiConnect v.6 real 0m0.025s user 0m0.006s sys 0m0.004s AnkiConnect v.6 real 0m0.025s user 0m0.006s sys 0m0.004s AnkiConnect v.6 real 0m0.025s user 0m0.007s sys 0m0.003s AnkiConnect v.6 real 0m0.025s user 0m0.009s sys 0m0.001s AnkiConnect v.6 real 0m0.025s user 0m0.008s sys 0m0.002s AnkiConnect v.6 real 0m0.025s user 0m0.006s sys 0m0.004s
I wonder if this is still somehow related to AppNap. Can you try this test immediately after switching from Anki (and keeping it in view, if possible)? Would be interesting to see if that makes a difference.
I can confirm that when ANKI kept in view it's significantly fast.
Has there been any movement on this issue? Using the work around in the README to disable AppNap is okay for a developer but I don't think its the most elegant solution from a user perspective.