Very low performance in a "for" loop

Bug #1046081 reported by Ross
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Stellarium
Fix Released
High
Unassigned

Bug Description

The 0.11.4 version 64bit of Stellarium on a 64bit Windows 7 system (core i5, 12 GB RAM) seems to degrade performance in a "for" loop if used on conjunction with the "core.wait()" function inside the loop.

This is the code:
for (i=0; i<20; i++)
{
   core.setDate("+1 days");
   core.wait(0.2);
}

Even if the whole frame rate is high (60 fps), the rate of the loop is extremely low (every ~1 second instead of 0.2 second). During the "for" loop the whole frame rate is lowered to 14 fps and when it ends, goes back to 60 fps. Only the first cycle of the loop is at the correct speed, not the others.

Reinstalling the old 0.11.3, the loop works at the correct speed. Has something changed in the wait() function?

I don't know if the bug affects also the 0.11.4 32-bit systems.

Revision history for this message
Ross (rosario-ing) wrote :

I prepared a VM with Win7 32bit and it seems that this bug does affect also this architecture. In order to find if the bug is in the "core.wait()" function rather than elsewhere, I changed the code to the following:
for (i=0; i<20; i++)
{
   core.wait(0.1);
}

(I deleted any other functions in the loop).

It takes 20 seconds to complete, instead of 2 seconds, 10 times higher!

Revision history for this message
Alexander Wolf (alexwolf) wrote :

Confirmed! Reproduced only for Stellarium x86_64 on Windows x86_64. For Stellarium x86_32 on Windows x86_64 this issue not reproduced.

Changed in stellarium:
status: New → Triaged
importance: Undecided → High
Revision history for this message
Sibi Antony (sibi-antony) wrote :

Looks like a problem with the QScript Date() object implementation. The milliseconds precision is lost in the Win7 versions. The following snippet should confirm that.

function mywait(secs) {
    var date = new Date();
    do {
        curdate = new Date();
    } while(curdate - date < 1000*secs);
    core.debug(curdate.getTime());
    core.debug(curdate - date);
}

var date = new Date();
mywait(0.1)
mywait(0.1)
mywait(0.1)
var curdate = new Date();

In Linux and WinXP I get milliseconds precision, but for Win7 it gives only seconds. As below

1346873417000
134
1346873418000
999
1346873419000
999
Script finished at Mi 5. Sep 21:30:19 2012

Since the core.wait() depends on the good working of Date() object, this fails. Also if someone is aware, was there any windows Qt library updates for this release ?

We may have to raise a bug with Qt to proceed.

Revision history for this message
Alexander Wolf (alexwolf) wrote :

Please test 0.12.2RC1 - I think Qt has improvements scripting engine for 64-bit Windows.

Revision history for this message
henrysky (henry-leung-2010) wrote :

I think this bug is solved

The code:
for (i=0; i<20; i++)
{
   core.setDate("+1 days");
   core.wait(0.2);
}

It takes 4.57second (using the timer apps on my phone and the expected value should be 4s) to complete on Windows 7 64bit with Stellarium 0.12.4 64bit on a i3 HP notebook

tags: added: performance
tags: added: scripting
Changed in stellarium:
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.