Skip Menu |

This queue is for tickets about the SDL_perl CPAN distribution.

Report information
The Basics
Id: 16988
Status: resolved
Priority: 0/
Queue: SDL_perl

People
Owner: Nobody in particular
Requestors: TONYC [...] cpan.org
Cc:
AdminCc:

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



Subject: SDL::App loop() very slow
SDL::App's loop() method calls sync() every time around the event loop, for non-hardware based surfaces, such as an X window this noticably lags event processing if you're handling events such as mouse movements for a drag. I spent a couple of hours trying to track down performance issues in my code until I noticed the sync() in loop(). Ideally the sync would only happen when the event queue was empty, or only periodically. A note in the loop documentation would also work: --- lib/SDL/App.pm.orig 2006-01-10 15:19:43.000000000 +1100 +++ lib/SDL/App.pm 2006-01-10 15:41:17.000000000 +1100 @@ -302,6 +302,10 @@ of event handler subroutines. The keys of the hash must be SDL event types such as SDL_QUIT(), SDL_KEYDOWN(), and the like. The event method recieves as its parameter the event object used in the loop. + +loop() calls sync after processing every event. This may result in +performance issues. + Example:
--- lib/SDL/App.pm.orig 2006-01-10 15:19:43.000000000 +1100 +++ lib/SDL/App.pm 2006-01-10 15:41:17.000000000 +1100 @@ -302,6 +302,10 @@ of event handler subroutines. The keys of the hash must be SDL event types such as SDL_QUIT(), SDL_KEYDOWN(), and the like. The event method recieves as its parameter the event object used in the loop. + +loop() calls sync after processing every event. This may result in +performance issues. + Example:
I switch between your suggestion and current code and did not see a performance increase. If you can give me more information so that I can reproduce a slow loop() that would be great.
CC: TONYC [...] cpan.org
Subject: Re: [rt.cpan.org #16988] SDL::App loop() very slow
Date: Mon, 24 Aug 2009 10:47:22 +1000
To: Kartik Thakore via RT <bug-SDL_perl [...] rt.cpan.org>
From: Tony Cook <tony [...] develop-help.com>
On Sun, Aug 23, 2009 at 07:05:02PM -0400, Kartik Thakore via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=16988 > > > I switch between your suggestion and current code and did not see a > performance increase. If you can give me more information so that I can > reproduce a slow loop() that would be great.
Hi, I'll take a look at this, this week. From memory, I was running on a machine with no X acceleration, and it was a slow machine relative to current (Pentium II 400), so the performance issues were much more obvious. But the difference with the different run loops was obvious too. Tony
Subject: Re: [rt.cpan.org #16988] SDL::App loop() very slow
Date: Mon, 24 Aug 2009 20:42:13 +1000
To: Kartik Thakore via RT <bug-SDL_perl [...] rt.cpan.org>
From: Tony Cook <tonyc [...] cpan.org>
On Sun, Aug 23, 2009 at 07:05:02PM -0400, Kartik Thakore via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=16988 > > > I switch between your suggestion and current code and did not see a > performance increase. If you can give me more information so that I can > reproduce a slow loop() that would be great.
Ok, I've managed to reproduce it by cutting down my original code, eliminating any external dependencies. It only happens over a remote X connection, which is about the slowest environment an SDL app is going to run in, but it's much more responsive with my replacment no-sync loop than the SDL::App loop. I can reproduce the problem locally using ssh -Y localhost. Attached sdlslow.pl The original code was a sample for Imager::SDL, a simple mandelbrot set explorer - with all the mandelbrot rendering taken out it's just a simple filled box drawing program. Tony

Message body is not shown because sender requested not to inline it.

On Mon Aug 24 06:45:06 2009, TONYC wrote: Show quoted text
> On Sun, Aug 23, 2009 at 07:05:02PM -0400, Kartik Thakore via RT wrote:
> > <URL: https://rt.cpan.org/Ticket/Display.html?id=16988 > > > > > I switch between your suggestion and current code and did not see a > > performance increase. If you can give me more information so that I can > > reproduce a slow loop() that would be great.
> > Ok, I've managed to reproduce it by cutting down my original code, > eliminating any external dependencies. > > It only happens over a remote X connection, which is about the slowest > environment an SDL app is going to run in, but it's much more > responsive with my replacment no-sync loop than the SDL::App loop. I > can reproduce the problem locally using ssh -Y localhost. > > Attached sdlslow.pl > > The original code was a sample for Imager::SDL, a simple mandelbrot > set explorer - with all the mandelbrot rendering taken out it's just a > simple filled box drawing program. > > Tony > >
Thank you. I also couldn't find a reason sync() was needed in the loop() (after reading 300 lines of SDL.XS c code). So I patched (is patched the right word here?) it to v2.2.2. http://github.com/kthakore/SDL_perl/commit/d73cbe8a87257b34b346b2c00d97e0547ab75175 -- work in progress