Author Topic: [FIXED] DynamicPSF Performance Degradation (was: PJSR performance loss?)  (Read 5731 times)

Offline mschuster

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1087
As my scripts have been getting more complex, I have started to notice a performance loss. Running the script immediately after launching PI is fast, but successive runs are slower. For example, executing a DynamicPSF instance from my script might take 0.5 seconds on an early run, and 2.0 seconds on a later run. In this case the instance is running with the same parameters on the same image so it should take the same time. Has anyone else noticed a similar performance loss across multiple script runs? I am wondering if this is my bug or a more general PI problem.
Thanks,
Mike

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
I have seen this as well, although some time ago. It was with PI 1.5 (when I programmed the CanonBandingReduction script). I dont know if this is still the same effect, since much of the PJSR interpreter changed since then. Resetting the Runtime (in the editor menus) or calling gc() might help somewhat. Ultimate solution was to reboot Windows.

Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Memory fragmentation may slow down the application after a *very* long sequence of running processes. The JavaScript runtime may be somewhat more sensitive to fragmentation, but processes implemented in modules don't depend on the PJSR. From my experience, memory management is comparatively poor on Windows.

Anyway, a 400% difference seems way excessive for a process like DynamicPSF. There's no reason at all for such a severe performance degradation, other than some running processes on the host machine that may be stealing resources from PI.

What operating system are you running? How much RAM have you installed? Other applications running?
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline mschuster

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1087
Win7, 01.07.06.0793 Starbuck (eng x86_64), 4GB ram, only other process running is Resource Monitor. Idle CPU usage is 2%.

I noticed that PI's commit and working set memory increases from around 250k/350k at launch after one script run to 780k/830k after multiple script runs. Performance loss happens with StarAlignment as well as DynamicPSF. I don't notice my custom script code running slower, or if so, not by much.

The problem seems to get worse with more and more script runs. Here is more data:

Crop, Resample and PixelMath instances don't seem to loose performance.

StarAlignment goes from about 5 sec at launch to about 20 sec after multiple runs.

DynamicPSF goes from about 1.2 sec at launch to about 13 sec after multiple runs.

Thanks,
Mike
« Last Edit: 2012 May 02 19:59:01 by mschuster »

Offline vicent_peris

  • PTeam Member
  • PixInsight Padawan
  • ****
  • Posts: 988
    • http://www.astrofoto.es/
Hi,

I'm running a photometry script in my laptop which is very intensive. It does a lot of calculations and uses SA as well. I have applied the script the script to an image container with 39 images and I don't see any performance loss... Always between 11 - 6 seconds per image. I have only 4.3 of 15.6 free GB of RAM memory and a lot of opn applications (4 PixInsight instances, a lot of Firefox instances, OpenOffice spreadsheet and Thunderbird).

I'm running Fedora 14... Perhaps is a Windows related issue?


Regards,
Vicent.

Offline mschuster

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1087
Hi Juan and Vincent,

I have isolated the problem to DynamicPSF and have a simple script that will let you reproduce the problem on Win7.

Files are in Forum Shared Files mschuster/performance.

1) Launch PI.
2) Open the image integration.fit.
3) Run the script performance.js, choose the file barycenters.dat.
4) Make a note of DynamicPSF performance.
5) Repeat steps 3) and 4), note the performance on each run.

Here is an example of the performance results I saw for 5 successive runs of the script:

3.9s, 6.2s, 8.6s, 11.1s and 13.7s.

The file barycenters.dat is a binary formatted file containing the coordinates of a large set of star barycenters in the image. These barycenters were detected by StarAlignment and written to the file by different script.

The script reads the barycenters, initializes the DynamicPSF instance appropriately, and then runs the instance.

Note: there is a possibility that the script is not initializing the instance properly. If not, please let me know!

Thanks,
Mike

Offline Nocturnal

  • PixInsight Jedi Council Member
  • *******
  • Posts: 2727
    • http://www.carpephoton.com
Nice work Mike!
Best,

    Sander
---
Edge HD 1100
QHY-8 for imaging, IMG0H mono for guiding, video cameras for occulations
ASI224, QHY5L-IIc
HyperStar3
WO-M110ED+FR-III/TRF-2008
Takahashi EM-400
PIxInsight, DeepSkyStacker, PHD, Nebulosity

Offline cs_pixinsight

  • PixInsight Addict
  • ***
  • Posts: 156
Mike, just a wild shot in the dark here.  Do you happen to save a lot of lines in your console?  Say 5-10K?  If so, try clearing the console window after each test and see if that is causing the slowdown.

Craig

Offline mschuster

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1087
A short log doesn't seem to help.

The problem occurs on the Mac also, but not quite as bad: 3.5s, 4.9s, 6.8s, 8.7s and 8.6s.

FYI: The script's open file dialog doesn't work on the Mac - the dialog closes with Cancel immediately with no user input. I don't know why. So I hard coded the file name to get the script to work.

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Hi Mike,

Thank you so much for detecting this problem. It was a thread synchronization bug in DynamicPSF's star detection routine. This bug is now fixed in the latest version of the Image module, which I have just released as an update for all platforms. This kind of performance degradations are incompatible with PixInsight, so I have stopped everything else to fix this problem today. It has been relatively hard to find and solve. Your script has been really useful.

Along with this bug fix, I have improved the star detection routine significantly. It runs now about twice faster than previous versions. On my i7 990X Linux workstation your script runs now in 1.15 seconds. The previous version required 2.45 seconds (only in the first execution, of course).

Thanks again!
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Nocturnal

  • PixInsight Jedi Council Member
  • *******
  • Posts: 2727
    • http://www.carpephoton.com
Nice work Juan and good job Mike sticking to your guns!
Best,

    Sander
---
Edge HD 1100
QHY-8 for imaging, IMG0H mono for guiding, video cameras for occulations
ASI224, QHY5L-IIc
HyperStar3
WO-M110ED+FR-III/TRF-2008
Takahashi EM-400
PIxInsight, DeepSkyStacker, PHD, Nebulosity

Offline cs_pixinsight

  • PixInsight Addict
  • ***
  • Posts: 156
I agreed about the great collaboration on tracking this down - it's always nice to see problems resolved in a quick manner and making them 100% faster is a terrfic bonus.   ;D

Craig

Offline mschuster

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1087
Thank you Juan for your fix. It solves the problem on both Mac and Win for both large and small data sets.

FYI: Overall I am finding performance on MacOS better with your fix, but on Win7 it appears a bit slower. Both OS's running on my MacBook Air i7 1.8Ghz 4Gb. Here are some results for performance.js:

MacOS: 2.5s (all 4 cores active), 2.9s (3 cores active).
Win7: 4.9s (all 4 cores active), 6.0s (3 cores active).

I don't think this is a problem, I just wanted to make a note of it.

Update: More MacOS/Win7 performance comparisons: On a very large data set (28000 stars) performance on both platforms with same number of cores active is the roughly the same (within 5% of 90 seconds on both platforms).

Also, FYI a minor issue DynamicPSF seems to ignore the console's Pause/Abort button on large data sets.

Thanks,
Mike
« Last Edit: 2012 May 07 11:01:32 by mschuster »