CURLSMultiMBS super slow

I’m trying to figure out why downloading a couple of urls now takes 60 seconds (!!!) with CURLSMultiMBS. As far as I can see the project does nothing for a long time and then downloads the files quickly.

mime curl test.xojo_xml_project.zip (10.3 KB)

Any ideas? Xojo 2024r1, MBS 24.5 and Sequoia.

Could it be related to the delay in network availability at launch Sequoia users are seeing? Related thread: Sequoia URLConnection errors for first few requests

This delay drives me nuts because it screws up my KVM when I reboot. It makes Lifeboat fail to connect at launch for debug builds. It does nothing good as far as I’m concerned.

1 Like

Very good question. But when I run curl a second time it also takes that long. A test on Big Sur shows the same lack of speed.

1 Like

Is it running HTTP 3.0 (quick), HTTP 2.0 or HTTP 1.1 ?

dim Timeout as integer = System.Ticks + 60 * 60
while not isFinished and System.Ticks < Timeout
  Thread.SleepCurrent(10)
wend

What is this supposed to do?
Please consider using events and not block the main thread.

No can do. This is a very small part of a large algorithm. When a transfer is finished a notification is sent back to MimeCurlQueue which sets the isFinished property to true.

I’m quite sure that when I implemented this there was no 60 second delay with the same code. This hasn’t changed in years and years.

Xojo may have changed alot in the background for threads. Maybe Thread.SleepCurrent is slower?

As far as I can see it’s http2 by default.

1 Like

This would apply to Xojo2024r2 and newer. I’m still using Xojo 2024r1 which is before the preemptive threads. But it’s a good idea to test with r4. Nope, exact the same result.

And the example doesn’t even use a thread so this should sleep the main thread.

The problem is that CURLSMultiMBS class uses a timer which doesn’t run inside this loop, so downloads may pause.

You could just call Perform method inside the loop to keep the transfers running.

Otherwise if it works in an older/newer version with different curl version and it works better there, it may be a regression in curl itself.

Where should I try calling perform? There is no loop. The test app literally waits 60 seconds before even starting the download.

And yes, an older version worked much better. I will check tomorrow if I can find an older and faster version.

Sorry, I saw the loop and through it would slow it down.

Current plugin runs a timer to call Perform automatically.
But you need to prevent the application from sleeping.

The example application literally has no other code. The main app - of course - has code to prevent sleeping.

I didn’t have to test much since I always log the MBS version. This version of MBS works fine:

2025-01-08 17:40:52 MBS: MBS Xojo Plugin 24.3 (build 21114) Mon Jul 8 05:21:56 2024 (GMT)

So somewhere between 24.3 and 5 you got the problem.

1 Like

@Christian_Schmitz : Anything new on the bug?

Maybe you can try to use the profiler or mac instruments to check where the most slowdown is?

The slowdown is between starting CURL and actually doing something. I did a Console log and there is nothing in between the 2 actions. Even in Little Snitch I can see that between starting and actually trying to reach the websites there is a minute of meditation.

So this is in a debugrun or build or both?

Both. As user has reported the problem. But the example shows the problem also in debug.

Yeah something is going on in the sample.

Time taken is always exactly (timeout) 60 seconds…
Duration in seconds: 60.01667
Duration in seconds: 60
Duration in seconds: 60

@Beatrix_Willius try this one:

mime_curl_test_improved.xojo_binary_project.zip (12.6 KB)

It seems to run normally

I guess your thread was indeed blocking, moved to timer did seem to work.

My debug output:

09:57:42 : mime curl test Launched
09:57:44 : MimeCurlQueue.Constructor
: Calling download on [URL REMOVED FOR PUBLIC FORUM]
09:57:49 : Calling download on [URL REMOVED FOR PUBLIC FORUM]
: Calling download on [URL REMOVED FOR PUBLIC FORUM]
: Calling download on [URL REMOVED FOR PUBLIC FORUM]
: Calling download on [URL REMOVED FOR PUBLIC FORUM]
: Calling download on [URL REMOVED FOR PUBLIC FORUM]
: Calling download on [URL REMOVED FOR PUBLIC FORUM]
: Calling download on [URL REMOVED FOR PUBLIC FORUM]
: Calling download on [URL REMOVED FOR PUBLIC FORUM]
: Calling download on [URL REMOVED FOR PUBLIC FORUM]
: Calling download on [URL REMOVED FOR PUBLIC FORUM]
: Calling download on [URL REMOVED FOR PUBLIC FORUM]
: Calling download on [URL REMOVED FOR PUBLIC FORUM]
: Calling download on [URL REMOVED FOR PUBLIC FORUM]
: Calling download on [URL REMOVED FOR PUBLIC FORUM]
: No transfers
09:57:57 : mime curl test Ended

I don’t see any content being downloaded just yet.

I tried my test projects. Seems to run fine.

Could you query times

  • GetInfoTotalTime
  • GetInfoAppConnectTime
  • GetInfoConnectTime
  • GetInfoNameLookupTime
  • GetInfoPreTransferTime
  • GetInfoRedirectTime
  • GetInfoStartTransferTime

so you can see what time is needed for what. Maybe DNS takes longer?