concurrency

Forums for specific tips, techniques and example code
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

concurrency

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:44 pm

by johnmunro >> Mon, 21 Jul 2003 17:02:52 GMT

Is there any way of getting more than one thing to happen at the same time in Jade?

The current issue is the loading time of a form - there is information on the form that cannot be precalculated and stored, so pretty much has to be generated when the form is loaded, but this adds four seconds to the form's loading time. As form loading time is one of the things users notice most, we would like to reduce this as much as possible.

The thought ocurred to me that the information doesn't need to be on the form the instant it's loaded, but the form does need to be responsive right away. So if we could have something like a background thread running which added the information to the form as and when when it's finished calculating it, this would be pretty much ideal.

My first thought was to use notifications, but in my test app the notification code seemed to either wait until the main action is complete, or to stop the main action until the notification code was complete...

Any ideas?


--
John Munro

Synergist Limited - Home of FileVision(TM)
The Bioscience Innovation Centre
Cowley Road, Cambridge, UK
CB4 0DS
Telephone: +44 (0) 1223 478200
Fax: +44 (0) 1223 477969
Email: john.munro@filevision.com
Web: http://www.filevision.com

The contents of this communication are confidential and are only intended to be read by the addressee. We apologize if you receive this communication in error and ask that you contact Synergist Limited immediately to arrange for its return. The use of any information contained in this communication by an unauthorized person is strictly prohibited. Synergist Limited cannot accept responsibility for the accuracy or completeness of this communication as it is being transmitted over a public network. If you suspect this message may have been intercepted or amended, please inform Synergist Limited.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: concurrency

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:44 pm

by cnw/cnwsb1 >> Mon, 21 Jul 2003 18:23:01 GMT
Is there any way of getting more than one thing to happen at the same time in Jade?

The current issue is the loading time of a form - there is information on the form that cannot be precalculated and stored, so pretty much has to be generated when the form is loaded, but this adds four seconds to the form's loading time. As form loading time is one of the things users notice most, we would like to reduce this as much as possible.

The thought ocurred to me that the information doesn't need to be on the form the instant it's loaded, but the form does need to be responsive right away. So if we could have something like a background thread running which added the information to the form as and when when it's finished calculating it, this would be pretty much ideal.

My first thought was to use notifications, but in my test app the notification code seemed to either wait until the main action is complete, or to stop the main action until the notification code was complete...

Any ideas?

Hi John. One way to do this would be to have a background non-gui Query application that registers for Request notifications. Your form sends a Request notification (with enough information in the userInfo to define the Request). The background request application receives the notification (when it is free from processing any prior requests in its notification queue), retrieves the information required, then returns it (eg. in some form of tag and value formatted string) in the userInfo of
a Result notification. Your form receives the Result notification, unbusts it, and populates itself. Consider running the Query
application as a Server Application.

Here are some more ideas, one of which may be appropriate (and simpler !):

* Work out a way to precalculate and store the information. Don't tie yourself down to the same data structures as the original data. One technique is to persistently store the Query Result as string attributes on the primary query object (or on an aggregate of the query object if you prefer). Every time any data affecting the Query Result is updated, these string attributes are also updated in the same transaction. You now have a form that opens and displays instantly, at the cost of performing and storing your Query whenever certain data is updated.
This technique is called "early updating".
* If you are using multiple sheets on a folder, only populate the sheet that is displayed, then display the other sheets as they are first selected. This does mean a slight pause between selecting each sheet
for the first time.
* In the load method of your form start a one-off timer that runs for a millisecond. When the form has finished loading the timer fires, then perform your 4 second query in the timerEvent. This technique means the form displays quickly, but is not responsive until after the query has run.

- Simon.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: concurrency

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:44 pm

by allistar >> Mon, 21 Jul 2003 21:44:34 GMT

Hi John,
Simon has already mentioned some great ideas, here is what we have done in the past:

1) only populate bits that the user can actually see (i.e. the visible tabs). Populate other tabs when they are made active.

2) In conjunction with number 1 have a process that brings things into cache. For thin client this would be a background application on the application server. All it need to do is to touch the objects you will be loading. When the form goes to populate those obetcts onto the form they will already be in the cache for this node which can save quite a bit of time.

3) Above all else: use the profiling tool. This will provide invaluable information about why your form is taking so long to load.

4) Don't populate entire tables on form load time, only populate the part you can see. When the user scrolls in a table then you can populate the remaining lines. We have a special table class that handles for this automatically.

5) Be careful about how many locks/unlocks you are doing. If you are doing a lot of locks and a lot of unlocks for a load then you could consider going into load state (using "beginLoad" and "endLoad"). This will not relinquish locks until the endLoad, which improves performance. There is a trade off however as you are holding things locked for longer which could have a detrimental effect on other processes.

6) Store as much in the database as possible. A form load shouldn't do any real processing or querying of data, where ever possible have the data stored in the database in the format/breakdown that the form needs it in. This may mean creating "in-between" objects that represent, for example, balances for particular customer for a particular period. If you find your code is iterating through large collection to gather data then consider storing that data in the database somewhere. I am a strong believer in trading off database size for performance. (i.e. I would rather have a big database with a fast application than a small database with a slow one).

Regarding your idea on notifications: If you send a notification that the current thread will process then you will get what you have noticed. Since you are running in one process there is no way you can get the notification code AND you form loading code to process at the same time. To do that you would need to have a separate process running (these can take some time to start and are expensive from a licensing point of view in Jade 6).

Regards,
Allistar.

P.S. I am in the process of putting together a white paper detailing performance improvements that can be made in Jade applications.

------------------------------------------------------------------
Allistar Melville
Software Developer, Analyst allistar@silvermoon.co.nz
Auckland, NEW ZEALAND

Silvermoon Software
Specialising in JADE development and consulting
Visit us at: http://www.silvermoon.co.nz
*NEW* Simple web access to Jade at: www.silvermoon.co.nz/jhp.html ------------------------------------------------------------------


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 21 guests