comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Performance of many concurrent delay() calls
Date: Mon, 7 Nov 2016 21:57:18 +0100
Date: 2016-11-07T21:57:18+01:00	[thread overview]
Message-ID: <nvqpre$1npm$1@gioia.aioe.org> (raw)
In-Reply-To: 1a375eea-b087-4080-a492-62bc26a8123c@googlegroups.com

On 2016-11-07 19:52, Olivier Henley wrote:

> Does calling [loop and delay(1.0)] for each of many thousand
> connected  clients (gnoga/simple components) is a huge performance hit or not?

I am not sure what you mean. Simple Component's server is specifically 
designed to handle multiple/all connections from one task. A delay on 
the context of that task is not a performance hit it is a catastrophe.

> If so, what is the recommended way to implement a periodic, every
> sec,  procedure that has to run for every clients; instantiate a single main
> task looping, delay(1.0), over all connections data and call the wanted
> procedure... probably?

That depends on what the periodic procedure is supposed to do. You 
cannot read any data from an external task, but you can queue data to 
send if the client's output buffer is not full. You can also allocate 
secondary buffers, there is a primitive operation called when a portion 
of data is sent. It is called on the server's task context and can be 
used to push data from the secondary buffer(s) into the freed portion of 
the primary buffer.

As for creating an external task for each client, that would defeat the 
purpose of the design (an OS can have a large number of sockets and only 
a limited number of tasks). So if any external tasks created they should 
loop over multiple clients.

How many external tasks and how many server tasks is a question of 
balance between CPU / Ethernet controller / network load. As J-P said, 
there is no way to foresee it. You have to measure.

Finally, there is a simple method of having non real-time *short* 
periodic activity per client. You override receive or send callback and 
check if the period is expired since latest periodic call. If yes you 
note the time (in the client) do that call again. If there is steady 
socket I/O that would work.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


  parent reply	other threads:[~2016-11-07 20:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-07 18:52 Performance of many concurrent delay() calls Olivier Henley
2016-11-07 19:04 ` J-P. Rosen
2016-11-07 19:13 ` Olivier Henley
2016-11-07 20:57 ` Dmitry A. Kazakov [this message]
2016-11-07 21:30 ` Florian Weimer
2016-11-07 22:42 ` Jeffrey R. Carter
2016-11-09 15:50 ` Olivier Henley
2016-11-09 23:15   ` Jeffrey R. Carter
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox