Re: slow startup on windows

"John Selverian" <[email protected]> Fri, 25 Oct 2024 10:18:47 -0400
Newsgroups gmane.comp.lib.fox-toolkit.user
Organization JAHM Software
Message-ID <[email protected]>
On the Mac I’m using Clang, on Linux I’m using g++ (gcc). For Linux, I running Ubuntu 20 LTS in a VMWare VM on the Windows PC.

 

I tried to use Clang in visual studio. When I just complied my program using Clang there was no change. I then tried to rebuild the fox library with Clang but got too many errors.

 

js

 

 

From: Roland Hughes via Foxgui-users <[email protected]> 
Sent: Friday, October 25, 2024 8:05 AM
To: [email protected]
Subject: Re: [Foxgui-users] slow startup on windows

 

I can provide some unrelated information that might prove enlightening.

Qt implements Copy-on-Write where QStrings are not actually copied until something needs to alter the string. According to C++ language standards purists this is illegal and a clear violation. Two academics enamored with pursuing C++ language standards (and not much else) forked Qt 4.8.x to CopperSpice. The first thing they did was get rid of Copy-on-Write. Yep yep yep, they can put on white robes, sit cross legged with palms skyward chanting ooooohhhhhhmmmmm now.

The library now also takes 16 minutes to build a QList. <https://www.logikalsolutions.com/wordpress/information-technology/qlist/> 

Yes, I forked their stuff <https://lscs-software.com/>  and am busy trying to un-pooch all the things they pooched.

The two behind CopperSpice are all Gaga that Microsoft uses their OpenSource project to test language standards compliance. There won't be any shortcuts in the Microsoft string libraries. You will have to physically copy each and every string each and every time, even for the temporaries used as function parameters and intermediary results. GCC, being a series of front ends for an intermediary language that is compiled by a common back end, is a bit "less pure." It has to handle how FORTRAN, COBOL, and dozens of other languages do things and have a front end that is "C++ standards compliant." I assume you are using GCC on Linux and Mac, correct?

Do you actually want to know the answer or "just make something that works?"

Know the Answer:

1.) port the little QList example program from the link above to Fox. It doesn't do much. Build and run on all three platforms making note of the elapsed time. 16 minutes is a long time to wait for an application to update something on the screen so don't get impatient. Have another computer to surf the Web with. <Grin>

2.) After proving to yourself performance duth sucketh on Windows, visit this link <https://learncplusplus.org/top-c-compilers-for-windows-in-2020/>  and find a "free enough" C++ compiler for Windows. Re-run step 1 on Windows using new compiler.

3) If no measurable speed improvement repeat with a couple of other "free enough" C+ compilers from the list.

If no C++ compiler shows any real difference you are being screwed by an inefficient memory allocation service that is provided by Windows/Microsoft in the OS. I haven't written on Windows in a loooong time, but it really was "just DOS" for the longest time. In the documentation for the DOS GUI compilers we had settings like STACKSIZE, HEAPSIZE, et-al that could be compiled into the code. We would tweak these settings to pre-allocate our working storage.

Today's PC operating systems steal quite a bit of tech from OpenVMS, MVS, etc. You know, the real operating systems. Memory is allocated in chunks. When your initial chunk is consumed the runtime linked into your program requests another chunk of the "economical size" from the OS. Various quotas and system configurations determine the "economical size" of each chunk. Each OS request has to do a lot of checking before it gives you a chunk. Setting the above values (no matter what they are called now) to about what you think your program will need means you can get a basket of chunks, possibly contiguous, from the initial request, never having to pay this price again. All of your little new and malloc operations occur in the chunk of working storage you've been given, not at the OS level, until you need another chunk. One of the other compilers may have different defaults for the above so your program "just works" and you can remain blissfully ignorant of all this. Wish I didn't have to know it!

Just make something that works:

Ditch the array.

You need an SQLite in-memory (or on disk) database.

https://stackoverflow.com/questions/277551/how-can-i-use-sqlite-to-open-a-database-from-memory

https://runebook.dev/en/articles/sqlite/inmemorydb

I really hate that on-line tutorials and even many academic programs today don't bother to teach students how to use a relational database and most importantly __when__ to use one. 500,000 strings shouldn't be in an array of any dimension. The database library will have been compiled with appropriate settings for efficient memory use. Most versions are even going to compress the strings to make the memory requirements smaller.

If your 500,000 strings are "the same" for each run, you can bundle an SQLite db file with your application. Operating system disk caching and I/O minimum chunks will have a bunch of it in memory after first access.

Sorry if this response is too long. These are the type of things I have to deal with in the embedded systems world all the time. Almost every embedded system has incredibly poor dynamic memory allocation. They have to cut costs somewhere. Slower memory takes less power and is cheaper.

Btw, if you aren't dual-booting Windows and Linux, your Windows machine, especially if it is from a big name like HP or DELL, probably came with cheap slow memory. Those "promotional" machines they send to retailers come with the slowest RAM they can get away with. You have to custom spec faster RAM. Most of your customers/users won't have the faster RAM so good that you are testing with what they will have.

 

On 10/24/2024 7:02 PM, John Selverian wrote:



I’m back to this issue again…

 

On Windows 11, start-up time is 7 seconds. I’ve turned off “real-time protection” and it still takes 7 seconds.

 

On both the Mac and Linux it takes about 1 second or less.

 

Basically, the program dynamically creates (via new/alloc) and fills in a 4D array with strings (about 500,000 strings, each in a separate array element, it does some operations on these strings before saving them). When I profile in Visual Studio the CPU time seems to be evenly distributed across the routines where the strings are loaded. No single routines uses a large part of the CPU time.

 

I’ve commented out various section of the code to see if I can effect the speed but nothing really do it so I’m thinking it’s just FXString being slower on Windows.

 

Is there a reason why FXString would be much slower on Windows?

 

 

Kind regards,

 

js






_______________________________________________
Foxgui-users mailing list
[email protected] <mailto:[email protected]> 
https://lists.sourceforge.net/lists/listinfo/foxgui-users

-- 
Roland Hughes, President
Logikal Solutions
(630)-205-1593  (cell)
https://theminimumyouneedtoknow.com
https://infiniteexposure.net
https://johnsmith-book.com

_______________________________________________
Foxgui-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/foxgui-users
image001.gif (image/gif, 70 B) - not displayed