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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,92a027c293f03acb X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Workqueues in Ada Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: Date: Sat, 28 Jul 2007 19:28:18 +0200 Message-ID: <4rvzewqs9ba3$.pluy1xzoi5lr$.dlg@40tude.net> NNTP-Posting-Date: 28 Jul 2007 19:28:06 CEST NNTP-Posting-Host: 1a7f5920.newsspool2.arcor-online.net X-Trace: DXC=QQ;ff`@;j9TPU8j_I0DN6_A9EHlD;3YcR4Fo<]lROoRQgUcjd<3m<;R`]Z\F@Wc0DS[6LHn;2LCV^[ On Sat, 28 Jul 2007 17:00:57 +0000 (UTC), Wiktor Moskwa wrote: > 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 thought Ada.Containers.Doubly_Linked_Lists can move elements between lists without copying. Have you checked that? You could also try an alternative implementation of doubly-linked lists and webs: http://www.dmitry-kazakov.de/ada/components.htm#Generic_Doubly_Linked_Web > 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. Make it a protected object. A worker task calls to an entry of, requesting an item of work. The entry removes the first item from the list and returns it to the task via pointer. When the worker task finishes dealing with the item it calls to a protected object's procedure to queue the item back. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de