cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Setting priority for an easy handle in a multihandle

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 30 Apr 2012 10:35:08 +0200 (CEST)

On Mon, 30 Apr 2012, Lijo Antony wrote:

>> The trick is to query max timeout values from active multi interfaces and
>> calculate the minimum of them, then select with this timeout. After return
>> from select, you have to run your own priority scheduler to decide the most
>> prior multi interface to process, then process it if it has something to
>> process.
>
> I am also thinking on something similar. But I am a little skeptic about the
> effectiveness. Since I am watching the sockets, I can choose the socket to
> be processed(multi_socket_action) next, based on my priority.

> However, this will only make sense, if there can be multiple sockets ready
> to be processed at the same time. As Daniel mentioned in another mail, since
> these sockets are just tcp streams, two sockets becoming ready at the same
> time might be unrealistic. If that is the case any extra effort spent on
> managing the sockets would be useless. Could any experts comment on this?

I have similar doubts about the effectiveness of said method.

The multi interface already does such sorting of timeouts per easy handle and
that's the timeout value that is provided to the application. In a typical
case, you will find that hardly any easy handle will have the same expiry time
since we keep track of them internally with a millisecond resolution. But
that's just a timeout value, in the end you will end up waiting for action on
Y connections and at any given points N of them will have activity that
require action.

If you get N number of transfers that need attention after select() returns
you can of course opt to handle to act on them in your own custom order but in
order to make the order get any real significance you would have to NOT handle
some low-prio handles in case there are high-prio handles having activity.

You can probably achieve almost exactly that by just limiting the bandwidth
use for the low-priority transfes so they will be slowed down (and not
handled) if they run too fast.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2012-04-30