Forum > General

Lazarus 2.2 seems to be a lot slower loading a form than Lazarus 1.4.4

(1/4) > >>

Pi:
I have a Lazarus program that I wrote in Lazarus version 1.4.4, on a Windows 10 machine that has 96 GB RAM (it used to have more) and an Intel i7-6850K processor.
On that PC whenever I clicked on an option that loaded a new form with the new form's name and showmodal (usually by using a control character shortcut) it seemed to almost always load the new form instantaneously.
The only thing that happens immediately after the form is loaded (in the formshow event) is it calls the clear option to clear the contents of a memo on the new form.

On my new PC (with Lazarus 2.2, Windows 10, 256 GB RAM with a faster processor - AMD 3960X) when the program initially runs I can select the new form and it seems to load immediately. If I then use an option on the new form that does do a lot of processing of records (using read command to read lots of records from a file, then maybe updating records or adding new ones), and that form then closes and the processing has finished (I know the processing has finished as I've added a showmessage on the  original form's calling procedure after it has, eg. after it may have updated a listbox with new info), if I then select the option to open the new form again or use the control shortcut to it (eg. control G), it can take seconds to open the new form (eg. about 6 to 8 secs) - even though the only thing happening when the new form shows is that it clears a memo's text on it (ie. that's before I've selected any button on the new form again to do any further processing). I don't know if the duration is dependent on the length of the text that was in the memo that is getting cleared.

Why does it take so long on the new machine with the newer version of Lazarus to open the new form at that time (when the processing that happened before trying to open it had finished) and is there anything I can do to make it faster (like it was on the old pc with the old lazarus)?

Is it anything to do with compiler debug info (it's set to use "Dwarf2 -gw2" in the newer Lazarus - the Lazarus 1.4.4 used "automatic (-g)" in the "Type of debug" option.
 (note: if I change the debug option to use "automatic (-g)" in the Lazarus 2.2 on the new PC like it was originally I get a message saying "This project does not write debug info in dwarf format" and giving 3 debug options or cancel so I assume it requires writing debug info in one of those 3 formats if you want some debug info written).

Is it anything to do with having more RAM in the new PC?
Or is it that the new Lazarus is a lot slower at clearing memos than the Lazarus 1.4.4) - depending on the amount of text in it?

dseligo:
Sometimes adding more RAM helps  :)

If you suspect clearing of memo to be cause of this, why don't you test it?

You could do something like this:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var t: TDateTime;...t := Now;Memo1.Lines.Clear;ShowMessage(FormatDateTime('nn:ss.zzz', Now - t));
If that is the cause then you can try to solve it like that:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Memo1.Lines.BeginUpdate;Memo1.Lines.Clear;Memo1.Lines.EndUpdate;

Pi:
Thanks a lot for both of the replies. I tried testing with the different codes. Originally I was using the memo_name.clear;
So I tried running it with the same stuff pasted into the memo and with that timer in each (timing the clearing of the memo) and also timing the appearance of the new form (using a watch) after pressing Ctrl G.

The 1st time into the new form (when the memo is already empty) with memo_name.clear shows time taken to clear the memo as 00:00.000 and is about immediately loaded.
After pressing the button to process records and that finishing and the form closing and other processing finishing:

The 2nd time into the new form (when the memo had text in the memo) still with the FormShow with memo_name.clear, shows the time taken to clear the memo as either 00:00.004 or 00:00.005 (and takes about 15 secs for the form to appear).
--
The 1st time into the new form (when the memo is already empty) with beginupdate, lines.clear, endupdate, showed 00:00.001 as the time taken for clearing the memo.
The 2nd time into the new form (when the memo had text into the memo) with beginupdate, lines.clear and endupdate, showed 00:00.002 as the time taken for clearing the memo and the form took about 13 secs to appear).
--
Using memo.text:='';

The 1st time into the new form (when the memo was already empty):  shows 00:00.000 as the time taken to clear the memo.
The 2nd time into the new form (when it had text in the memo before clearing it): shows 0:00.005 as the time taken to clear the memo and took about 13 secs for the form to appear.

So if my stopping of the stopwatch on my watch is right, those 2 seem to have reduced the time taken for the new form to appear the 2nd time by about 2 secs,
but still taking around 13 secs is quite a long time.

As of these tests for this post the debug option in the project options is set to "Dwarf with sets (-gw godwarfsets)" - I don't know if that makes any difference.

If the end figure in the time taken for the clearing of the memo is showing under a second in each that's probably meaning it can't really be the memo clearing that's the main issue (even though that's the only thing that happens in the FormShow event of the new form (apart from the new timer code to time it and display the time taken). But the first time of loading the new form (when the memo in it was already empty and before we've pressed any buttons later in that new form to process lots of records) was when it loads it instantly.

Could it be anything to do with the different debug options?
Or could past processing not have really stopped even though it's past the end of it and shown that it has with a showmessage saying it has (ie. if Lazarus does something in the background)?
Could Lazarus be doing it's own processing for some other reason (eg. garbage collection? or flushing some file buffers - even though previous processing should have stopped since it showed a message I put in that said that it had finished in the previous procedure?)?

I've checked and it definitely isn't doing anything much before the call to open the new form (when the past processing should already have been stopped).

ie. menu option to call the new form at the start just:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---added_or_updated:=false; // sets a global variable frm_the_new_form_name.showmodal();showmessage('after showmodal');  // so never gets here until after the new form has                                 // been closed, so anything after this isn't what's                                  // causing the slowdown.
----
And in the new form that gets called (after selecting the option or pressing Control G),
the FormCreate procedure is empty.
and the FormShow just has the timer code and display and the memo clearing.

eg.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var t: tdatetime;begin   t:=now;  //  the_memo.clear; // bits commented out so I could try the different ways of clearing it {   the_memo.Lines.BeginUpdate;    the_memo.Lines.Clear;    the_memo.Lines.EndUpdate;  }   the_memo.text:='';   ShowMessage(FormatDateTime('nn:ss.zzz', Now - t));      end;
[Edited to add code tags; please read How to use the Forum.]

Edited to add the timings for
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---the_memo.lines.clear on its own (without the BeginUpdate and EndUpdate)
---
With the_memo.lines.clear (without beginupdate and endupdate);

1st time into new form: shows 00:00.000 as time taken to clear the memo. The new form appeared immediately after pressing Ctrl+G to show it.
2nd time into new form (when there had been something in the memo and past processing should have stopped): shows 00:00.002 as the time taken to clear the memo and the form appeared about 13 secs after pressing Ctrl+G to display it.

Martin_fr:
The debug info itself ( "Dwarf with sets (-gw godwarfsets)" or other) will not change the timing.
But => run your code outside the IDE. To make sure the debugger is not interfering.

Also, what else is on your form?

If you prevent text from being added to your form (during the first run), does the 2nd form.show go better?

What happens if instead you do not clear the lines?

If I understand correct, then you run "memo.Lines.Clear;" within the "OnFormShow" ?
What happens if you clear the lines before calling "form.show" or "form.showModal"?

How many lines are we talking about? 1000? 10000? 100k? 1M?

Pi:
On the new form (that gets called after Ctrl+G is pressed or the main menu option for it is selected), the only other things on it apart from the memo that we've been talking about is:

7 labels
6 edit boxes and 1 other memo (that doesn't get much text added to it).
2 buttons (one to process the memo text being discussed and the other button to cancel (close the form)

The edit boxes and the other memo only get filled in after pressing a button on that new form to process the contents of the memo that's been discussed (about the clearing of it).
----
If there is no text added to the memo then there can be no processing of the text in it (after pressing a button the form) so yes it does make it load faster (immediately).

I think it is because of the amount of text in the memo (not the processing of the records) because when I just press the cancel button when it has that amount of text in it (so no records are read from a file again) it still takes about 10-11 secs for it to show the form after pressing Ctrl+G.

The amount of lines in the memo that is being discussed (the memo that gets processed) is currently 29,333 and the length of the memo.text is 619,618 (it depends what I paste into it but that's the amount that there was on the 2nd load of the form for the timings shown above). The width of the memo is 150 (so quite narrow - I could reduce the amount of lines probably by increasing that if that helped - but the procedure that reads the memo text doesn't look at the lines, only the memo.text in it.

Yes I'll check to see what difference there is running just the .exe file of the program out side of the IDE tomorrow morning thanks.

Navigation

[0] Message Index

[#] Next page

Go to full version