Subject: | Balloon performance problem in 804.0275 |
Date: | Fri, 23 Nov 2007 10:38:54 +0100 |
To: | bug-Tk [...] rt.cpan.org |
From: | "Mattias Andersson" <mattias.j.andersson [...] gmail.com> |
Hi Bug-Tk,
We experience Tk version 804.0275 very slow, has bad responsiveness.
The problem is that a simple application containing a Tk::Balloon
performs many stat system calls trying to find a module
(MasterMenu.al) to auto-load.
Running this program and sweeping the mouse two times over the main
window result in:
use strict;
use warnings;
use Tk;
use Tk::Balloon;
my $mw = MainWindow->new;
my $balloon = $mw->Balloon();
my $btn = $mw->Button(-text => "Exit",
-command => sub { exit });
$btn->pack();
$balloon->attach($btn, -balloonmsg => 'Balloon help message');
MainLoop;
Tk Version 804.0275
==============================
; truss -tfstat64,stat64 perl balloontest.pl | & grep MasterMenu.al | wc -l
496
; perl -MTk -e 'print "$Tk::VERSION\n"'
804.0275
; perl -v
This is perl, v5.8.8 built for sun4-solaris-thread-multi
Copyright 1987-2006, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
;
; uname -a
SunOS uws146 5.8 Generic_117350-46 sun4u sparc SUNW,Sun-Fire-V210
Tk Version 804.027
==============================
; truss -tfstat64,stat64 perl balloontest.pl | & grep MasterMenu.al | wc -l
0
; perl -MTk -e 'print "$Tk::VERSION\n"'
804.027
The problem is that in Tk::Balloon::Motion a check is performed if
$client->can("MasterMenu"), because AutoLoader cant find the method
(other than in Tk::Menu, I think) it try to load the module
MasterMenu.al before it fails. This is performed every time the mouse
is moved and one stat call is performed for each path in @INC.
We have a quite big Tk application where this problem makes the
application considerable slower.
One workaround is to implement the Widget::MasterMenu method and
simply return a false value.
package Tk::Widget;
sub MasterMenu
{
return 0;
}
Regards Mattias