Author Topic: suggestions for computer optimization  (Read 11700 times)

Offline whwang

  • Member
  • *
  • Posts: 62
Re: suggestions for computer optimization
« Reply #15 on: 2016 September 13 08:25:52 »
Hi Mike,

Thanks for the info.  Of course I know people are trying to help.  I just want to understand why this actually works.  Why does PI attempt to write things to the disk while there is still RAM available?  It's just, weird.  Why can't PI put those data directly in the RAM in the first place?  Why do we have to trick PI to believe it is writing something into the disk, while actually it is writing something into a RAM disk?  (The existence of RAM disk implies there is lot of RAM available.)

In the old days when Photoshop was still a 32bit app, it can only address 2GB of RAM.  I had an 8GB machine.  So I created a 4GB RAM disk and let Photoshop use it as a swap.  This worked because there is a true limit for how much RAM Photoshop could directly use (2GB).  To make full usage of the 8GB RAM for Photoshop, the RAM disk was necessary.  Now 64bit apps can directly use practically whatever amount of RAM, there shouldn't be a need for RAM disk.

My computer knowledge is very limited.  This could be a very naive question.  I appreciate if anyone can educate me on this.

Cheers,
Wei-Hao

Offline pfile

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 4729
Re: suggestions for computer optimization
« Reply #16 on: 2016 September 13 08:35:44 »
the swap files are the image history undo database. holding them all in memory is pretty much impossible on machines with "normal" amounts of memory. it probably should not be called "swap" given the natural confusion with VM backing store being called the same thing.

rob

Offline whwang

  • Member
  • *
  • Posts: 62
Re: suggestions for computer optimization
« Reply #17 on: 2016 September 13 08:42:11 »
Hi Rob,

I can understand this part.  However, it should not be difficult for an app to judge how much RAM is available.  PI can simply leave this in the RAM, and write it to disk only when it starts to run out of RAM, right?

Offline pfile

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 4729
Re: suggestions for computer optimization
« Reply #18 on: 2016 September 13 08:51:29 »
i suppose so, but choosing to store the undo history this way is a design decision - one that's going to work even if the OS has an inferior VM system or no paging files, etc.

maybe PI is keeping as much as possible in ram; that would make the "swap" name make sense. i don't know. but if it's not, implementing a VM system from scratch is quite a lot of work and requires a massive QA effort to make sure it's correct, especially given the cross-platform nature of the application.

rob

Offline msmythers

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1178
    • astrobin
Re: suggestions for computer optimization
« Reply #19 on: 2016 September 13 08:58:35 »
Wei

PI runs on all the popular platforms and this might be the easiest way to maintain code across them for Juan.  If you try to code for a spefic OS it's much easier to optimize for that one OS.


Mike

Offline dzso.bacsi

  • Member
  • *
  • Posts: 67
Re: suggestions for computer optimization
« Reply #20 on: 2016 September 14 00:40:30 »
Wei,

I have no idea how PI is designed related to memory usage or organisation. However, my limited experience showed me that a normal PC with 64GByte memory and a solo - for example - WIN10 environment with PI, PS, common user applications, JAVA development, Apache, Tomcat, even PostGRE database test environment has never reached more than 12-16 Gbyte memory usage. Having an SSD as system disk and 64Gbyte memory I have even switched off the Virtual Memory (page file) only to test the improvement of performance (if you know what you use your PC for, it is working perfectly). That resulted appr. 20 GByte of memory usage. So I decided to use 24 Gbyte as system memory and 40 GByte as disk using it for several purposes. The plus speed is significant, memory usage has never reached dangerous levels.

The only way I have ever seen real usage of 64Gbyte memory by a system, when it was a VM environment with big chunk of memory dedicated to each machine.

 All the above is not related to PI. It is related to OS memory management and as I said, based on my very limited experience in MS and Linux environments.
 
 Cheers

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: suggestions for computer optimization
« Reply #21 on: 2016 September 14 08:07:39 »
As noted earlier in this thread, swap files are used to store image states, as part of the processing history infrastructure implemented in PixInsight. As you know, PixInsight supports unlimited undo/redo operations (only limited by the available storage resources).

When I first designed and implemented the current processing history model in PixInsight (back in 2005), I decided to keep image states stored as external files instead of dynamic memory blocks. Only pixel data are stored externally; all of the metadata associated with image states, including serialized processes and most image properties, as well as many auxiliary data objects (such as ICC profiles, color spaces and other image data with predictable/fixed storage requirements) are stored in memory.

The basic design principles behind this decision are rather simple: (1) favor usage of free RAM for pure image processing tasks, and (2) keep the whole processing history architecture as simple as possible structurally. Some advantages of storing image states as external files are:

* Preserve free RAM for processing tasks. Many image processing tasks and algorithms are very demanding in their memory requirements. For example, each execution of the TGVDenoise process requires internally 11 duplicates of a single channel of the target image. Multiscale analysis algorithms, such as the starlet transform, the multiscale median transform, etc, also need many duplicates of the target image (basically, one duplicate per multiscale layer, but of the whole image, not just a single channel). Most multiscale processing tools maintain a cache of previously performed transforms, which requires a lot of available memory. Future implementations of many tools will also use multiple cached data to accelerate generation of intermediate transforms and auxiliary structures. Expect memory requirements to increase dramatically as we improve and extend the current tool set.

* Prevent memory fragmentation. Fragmentation is a serious problem inherent to all software implementations that perform continued allocations and deallocations of dynamic memory blocks of varying sizes. The whole PixInsight platform has been designed to minimize fragmentation, including internal memory pools and other allocation devices. External swap file storage plays a key role in this optimization.

* Coexist well with other software, including other running instances of PixInsight. Image states can easily consume several gigabytes in normal working scenarios (much more for complex processing works). If all of these data blocks are maintained in RAM, this can cause problems to run other applications, the operating system kernel and system services, which in turn can have a severe impact on overall system performance.

* Robustness. A swap file allows recovering an image state in the event of a process error, even after an application crash.

* Modularity. External storage of swap files implement a divide and conquer strategy, which facilitates the implementation of multiple tasks around the same data structures. For example, PixInsight projects use exactly the same swap file format to store image states. In fact, when you save a project all swap files are simply copied from one directory to another. The same happens, in the opposite direction, when you load a project.


PixInsight has been conceived and designed to handle huge image processing projects. The true fact is that, even with the reasonably large RAM sizes available on contemporary high-end workstation machines (32 to 128 GiB), RAM is a precious resource that has to be used judiciously. This not only involves availability of large contiguous blocks for image processing in PixInsight, but also availability of free RAM to run other demanding applications and tasks concurrently. Wasting RAM to keep unused data blocks 'simply stored' on a regular basis is not the most efficient implementation IMO.

With modern hardware, such as solid state disk drives, and considering the flexibility of our implementation, the performance penalty incurred by external swap files is negligible or virtually nonexistent. On the Linux reference implementation, for example, the system /tmp directory used by default for storage of swap files uses tmpfs (a standard file system with dynamic RAM storage) by default on all modern Linux distributions. Even when using external mass storage devices, the Linux kernel implements such an efficient disk caching system that generation of huge swap files is virtually transparent. See for example this benchmark, where both tmpfs and an SSD drive achieve a respectable transfer rate of 5.5 GiB/s. On OS X and Windows file system performance is worse, but also reasonably efficient on modern machines.

The current processing history architecture, based on external storage of pixel data, is efficient and robust. It could be extended by allowing optional storage in RAM, at least partially (for example, just the latest image state for fast single undo/redo operations), but I don't see any urgency in this.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline cdavid

  • PixInsight Addict
  • ***
  • Posts: 137
    • Through Space and Time
Re: suggestions for computer optimization
« Reply #22 on: 2016 September 14 10:03:47 »
Thanks for all the info everyone.  So I made various sized Ram disks and pointed to them several times and compared the Benchmark Script 3 times for each setup.

I tried a Ram disk of 32GB, 24GB, and 16GB.  I pointed to them either 2x, 4x, 6x, 8x, 10X.

Running the Benchmark without a ram disk yielded scores in the 4300 range.  The best scores were achieved with a Ram Disk of 24GB and pointed to 6x.  This gave me a score in the 5800 range.  I could no better than that with any configuration.

This has made registration and integration run much faster.

My original issue was unaffected however.  The startup process for the application is painfully slow.  It takes a while to load all the Java scripts.  Also I have noted that Pixinsight will take a long time to quit as well.  In fact it will hang and become unresponsive after quitting at times.  Not sure whats going on and if it is another peculiarity of "El Crap-itan"....hopefully the upcoming Sierra OS will solve these issues.

Carlos


Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: suggestions for computer optimization
« Reply #23 on: 2016 September 14 13:07:00 »
Quote
My original issue was unaffected however.  The startup process for the application is painfully slow.  It takes a while to load all the Java scripts.  Also I have noted that Pixinsight will take a long time to quit as well.  In fact it will hang and become unresponsive after quitting at times.

I can't reproduce any of these problems on several OS X machines, running both OS 10.10 and 10.11. That's very strange.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline cdavid

  • PixInsight Addict
  • ***
  • Posts: 137
    • Through Space and Time
Re: suggestions for computer optimization
« Reply #24 on: 2016 September 14 13:11:06 »
Thanks Juan, this is troubling.  This is a 9 month old iMac 5k Retina Display 3.3 MHZ with 64GB of RAM.  I have noticed this behavior for quite some time.  I am going to create a screen shot video tonight when I get home and load it.  When I purchased this machine I really expected it to fly with PI but the startup and shut down are painfully slow.  It is running the most recent version of El Capitan.

Carlos


Offline pfile

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 4729
Re: suggestions for computer optimization
« Reply #25 on: 2016 September 14 13:11:50 »
im definitely getting beachballs on el capitan that i didn't get in yosemite - seems to occur when invoking native filesystem dialog boxes, for instance, or after clicking OK in a native file dialog box.

rob

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: suggestions for computer optimization
« Reply #26 on: 2016 September 14 16:41:48 »
I have just recorded a small video:

http://pixinsight.com/tmp/open-close.sv3p.m4v

As you can see, launching and closing PixInsight is very fast; it takes just a few seconds. The machine is a Retina 5K, 27-inch, late 2015 iMac with a 4 GHz Core i7 and 32 GB of RAM, running OS X 10.11.6 (latest version, up-to-date). Something really strange happens with your computer if it takes so long to launch and close PixInsight.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline cdavid

  • PixInsight Addict
  • ***
  • Posts: 137
    • Through Space and Time
Re: suggestions for computer optimization
« Reply #27 on: 2016 September 14 17:29:03 »
 :surprised: :'(

...mine doesn't move that fast at all.  Really unsettling.  I am using a similar computer:  it is the i5 3.3 MHZ version-

I made a similar movie.  Here is the link to it in my dropbox:

https://www.dropbox.com/s/rdrfqw157dimoxk/Pixinsight%20Launch%20and%20quit%20video.mov?dl=0

Notice how long it takes to actually load all the java scripts and also how long it takes for the Pixinsight icon to no longer be active once I have quit the application.

Thanks for your help
Carlos


Offline msmythers

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1178
    • astrobin
Re: suggestions for computer optimization
« Reply #28 on: 2016 September 14 17:43:00 »
Wow and not in a good way. ???

Mike

Offline cdavid

  • PixInsight Addict
  • ***
  • Posts: 137
    • Through Space and Time
Re: suggestions for computer optimization
« Reply #29 on: 2016 September 14 19:11:44 »
So I rebooted in Recovery mode and ran disk utility>repair.  I am not sure there was a problem or if anything was done but I ran it just the same.  I rebooted and ran Console during the Pixinsight Startup and Quit.   This is what the console window shows.  It doesn't mean much to me but just in case it might shed light on the situation i am posting it here.

Thanks
Carlos