From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,92a027c293f03acb,start X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!newshub.sdsu.edu!news.nask.pl!news.nask.org.pl!newsfeed.tpinternet.pl!atlantis.news.tpi.pl!news.tpi.pl!not-for-mail From: Wiktor Moskwa Newsgroups: comp.lang.ada Subject: Workqueues in Ada Date: Sat, 28 Jul 2007 17:00:57 +0000 (UTC) Organization: tp.internet - http://www.tpi.pl/ Message-ID: NNTP-Posting-Host: aaeo146.neoplus.adsl.tpnet.pl X-Trace: nemesis.news.tpi.pl 1185642057 15216 83.4.118.146 (28 Jul 2007 17:00:57 GMT) X-Complaints-To: usenet@tpi.pl NNTP-Posting-Date: Sat, 28 Jul 2007 17:00:57 +0000 (UTC) User-Agent: slrn/0.9.8.1 (Linux) Xref: g2news2.google.com comp.lang.ada:1236 Date: 2007-07-28T17:00:57+00:00 List-Id: Hello, Few months ago I wrote about a distributed protocol simulator that I was writing in Ada. I followed an advice to stop using a thread per node and to implement a worker thread pool. With the new architecture things improved a lot, all the overhead of context switching has gone. I defined a unit of work as one iteration of one node (checking if new messages have come, processing messages, sending responses, checking if it's time to run a periodic job, updating statistic). I have a workqueue of above units and a pool of tasks that service nodes. The problem is that my poor implementation of workqueue is a bottleneck. A task takes a unit of work from a queue, processes it and puts it back at the and of the queue. Because the queue is Ada.Containers.Doubly_Linked_Lists there are lots of memory allocations and deallocations - that's a performance problem. I consider making a circular list of nodes with "Next_To_Service" pointer going around as nodes are processed. I'll have to make sure that one node can be served by only one task at the time (probably by marking nodes as being served at the moment). New nodes joining and old leaving the system will be more difficult to implement correctly, I suppose. What can you suggest? I'm probably missing something obvious. Thanks in advance! -- Wiktor Moskwa