Skip Menu |

This queue is for tickets about the POE CPAN distribution.

Report information
The Basics
Id: 27359
Status: resolved
Priority: 0/
Queue: POE

People
Owner: Nobody in particular
Requestors: craig [...] lucent.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: POE & Tk: Excessive CPU Usage
Using POE and Tk to setup a window that doesn't do much uses lots of CPU. Some folks on the POE mailing list have verified this problem with the attached example program. This seems to happen on many (all?) platforms. I've verified it on Apple MAC, solaris, and various windows boxes. I emailed to Rocco Caputo, and he took a look at it, but says the problem will take some time to crack. He asked me to submit this report. -Craig
Subject: cputest.pl
#!/usr/bin/perl use warnings; use strict; use Tk; use POE; POE::Session->create ( inline_states => { _start => \&ui_start, ev_count => sub { $_[HEAP]->{counter}++; }, ev_clear => sub { $_[HEAP]->{counter} = 0; }, } ); $poe_kernel->run(); exit 0; sub ui_start { my ( $kernel, $session, $heap ) = @_[ KERNEL, SESSION, HEAP ]; $poe_main_window->Label( -text => "Counter" )->pack; $heap->{counter} = 0; $heap->{counter_widget} = $poe_main_window->Label( -textvariable => \$heap->{counter} )->pack; $poe_main_window->Button ( -text => "Count", -command => $session->postback("ev_count") )->pack; $poe_main_window->Button ( -text => "Clear", -command => $session->postback("ev_clear") )->pack; }
Hi, Craig. It's a known, verifiable issue. Unfortunately I'm apparently not skilled enough yet to work my way out of a trade-off: Either it can use excessive CPU, or it can miss I/O events. I haven't found the sweet spot between them where everything works correctly AND efficiently yet. I'll keep at it, though. -- Rocco On Thu May 31 16:43:09 2007, craig@lucent.com wrote: Show quoted text
> Using POE and Tk to setup a window that doesn't do much uses lots of > CPU. Some folks on the > POE mailing list have verified this problem with the attached example > program. This seems to > happen on many (all?) platforms. I've verified it on Apple MAC, > solaris, and various windows > boxes. I emailed to Rocco Caputo, and he took a look at it, but says > the problem will take some > time to crack. He asked me to submit this report. > > -Craig
Woot! At long last I think I have this one beaten. Revision 2201 passes all existing tests, and your test case uses 0% CPU when idle.
From: craig [...] alcatel-lucent.com
On Mon Jul 23 03:23:44 2007, RCAPUTO wrote: Show quoted text
> Woot! At long last I think I have this one beaten. Revision 2201 > passes all existing tests, and your test case uses 0% CPU when idle.
Rocco- Great job! Many thanks for nailing this down and inventing a good fix! Code authors like you are really fun to work with, and it encourages me to use POE (and friends) even more. Thanks again for all your effort! -Craig