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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3e3949298ed3b36,start X-Google-Attributes: gid103376,public Path: g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!t-online.de!news-lei1.dfn.de!news-mue1.dfn.de!news-FFM2.ecrc.net!news.iks-jena.de!not-for-mail From: Lutz Donnerhacke Newsgroups: comp.lang.ada Subject: High CPU in tasking Date: Thu, 24 Jun 2004 15:43:46 +0000 (UTC) Organization: IKS GmbH Jena Message-ID: NNTP-Posting-Host: taranis.iks-jena.de X-Trace: branwen.iks-jena.de 1088091826 24724 217.17.192.37 (24 Jun 2004 15:43:46 GMT) X-Complaints-To: usenet@iks-jena.de NNTP-Posting-Date: Thu, 24 Jun 2004 15:43:46 +0000 (UTC) User-Agent: slrn/0.9.8.0 (Linux) Xref: g2news1.google.com comp.lang.ada:1857 Date: 2004-06-24T15:43:46+00:00 List-Id: In order to stop others falling into the same mistake, I debugged several days. I wrote an data stream decoder and output (via TCP) manifolder using Ada tasking and a protected ringbuffer. The whole application word fine, but the CPU load increased linear on input load and dramatically over the number of output queues. Debugging turned out: - Every writing to the ringbuffer wakes up all reader tasks. - That's why the reader buffers were filled with only the little data amount just written. - Tasking overhead caused the CPU load. Two solutions (used both): - The ringbuffer got a minimum reading length => Fewer wakeups. - The writer task collect a lot of data before writing => Fewer checks for wakeup. The ratio of tasking events before and after the change is about 30:1. Conclusion: When implementing tasking synchonisation with protected objects, keep in mind, that the standard Ada tasking model generates a near real time experience, which is mostly not required. HTH