LimeReport Forum

General Category | Основное => Discussion | Обсуждение => Topic started by: alexyuisme on April 02, 2021, 10:00:53 AM

Title: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 02, 2021, 10:00:53 AM
Hi, all:

I have a performance issue while calling "new LimeReport" in the ui thread. This new process takes too much time thus the whole ui freezes for about 30~40 seconds for the first-time run!(the second time it runs much faster due to memory cache I guess).

We tried running "new LimeReport" in a seperate thread sucessfully but, the app crashed once we triggered the report designer(via signal-slot mechanism because LimeReport is running in a seperate thread).

I am wondering if "new LimeReport" can be run in a seperate thread? If not, can we speed up the LimeReport initialization process?

Thanks,
Alex
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: Arin Alex on April 02, 2021, 10:03:54 PM
Hi!
Could you explain the issue in more detail? Which OS, compiler, limreport and Qt version do you use?
I have checked the next code:
Code: [Select]
    QTime start = QTime::currentTime();
    report = new LimeReport::ReportEngine(this);
    qDebug() << start.msecsTo(QTime::currentTime());
in my demo_r1 sample project and got 528 msec in debug mode and 268 in the release.   
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 06, 2021, 06:41:18 AM
Hi, Arin:

This is my environment: Win10 64-bit, LimeReport v1.5.35, Qt-5.12.7, Mingw 7.3.0 64-bit, 8GB Ram, i5 6500 quad core cpu.

On some low-end machines, the consructor could even take more than one minute! It seems to me the constructor takes lots of time to copy data from harddisk to memory.

Thanks,
Alex


Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 06, 2021, 10:32:38 AM
Hi!
Could you explain the issue in more detail? Which OS, compiler, limreport and Qt version do you use?
I have checked the next code:
Code: [Select]
    QTime start = QTime::currentTime();
    report = new LimeReport::ReportEngine(this);
    qDebug() << start.msecsTo(QTime::currentTime());
in my demo_r1 sample project and got 528 msec in debug mode and 268 in the release.   

After some hackings, I found one possible way to speed up the init process: just kick off "report = new LimeReport::ReportEngine(this)" before main ui gets initialized. I am not sure why that works but if I put the new statement after ui initialized(like I did before), the new process is bloody slow.

Note: my ui is way more complcated than those in demo1 and demo2.

Thanks,
Alex

Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: Subst on April 06, 2021, 11:20:39 AM
Hi!
Can we see your code of the class where LR instance is created?
(.h & .cpp)
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 07, 2021, 10:57:06 AM
 :-\That's my bad...After restart my machine the problem remains. Is there anyone experiencing the same slow new process?

Alex
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 08, 2021, 09:09:46 AM
My source code: https://github.com/alexyuisme/test_limereport.

I copied this compiled exe into different environment which contains different number of dlls and the launch time varies.(from a few seconds to more than one minutes) Is it caused by dll look-ups?

I did the same thing by copying the demo program "LRDemo_r1.exe" to different environments(with different dlls), and the launch time varies the same.

Note: limereport.dll and QtZint.dll exist in the same directory as the executable for all environments.

Any ideas?

Thanks,
Alex
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: Subst on April 08, 2021, 10:11:55 AM
Your test project works fine. Creating of report instance takes less then half second.

>> I copied this compiled exe into different environments which contains different dlls and the launch time varies. Is it caused by dll look-ups?

Is the same problem when you're lunch the program from build environment?
What version of LR you uses?
What version of QT?
May be QT version you are used when build LR and QT version in another environment are different?
What in PATH variable of "differsnt environment"?
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 08, 2021, 11:03:04 AM
My answers:

Is the same problem when you're launch the program from build environment?

-> No, the launch speed under Qt Creator is ok. Launch speed after deployment is not ok (the launch time varies from a few seconds to more than one minutes, depending on different environments that contain different dlls.)

What version of LR you uses?
What version of QT?

-> This is my environment: Win10 64-bit, LimeReport v1.5.35, Qt-5.12.7, Mingw 7.3.0 64-bit, 8GB Ram, i5 6500 quad core cpu.

May be QT version you are used when build LR and QT version in another environment are different?

-> All environments are built with the same version of QT toolchains as listed above.

What in PATH variable of "differsnt environment"?

-> All environments use the same PATH variable which doesn't contain the paths of limereport.dll and QtZint.dll.
the executable, limereport.dll and QtZint.dll are located in the same directory for all environments.

Thanks,
Alex
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: Subst on April 08, 2021, 12:10:24 PM
>> All environments use the same PATH variable which doesn't contain the paths of limereport.dll and QtZint.dll.
the executable, limereport.dll and QtZint.dll are located in the same directory for all environments.

please type from CMD echo %PATH% copy from & past here result

and second, please make screenshort of folder where located .exe, limereport.dll and so
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 08, 2021, 12:46:05 PM
1. please type from CMD echo %PATH% copy from & past here result

C:\Users\Administrator>echo %PATH%
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\libnvvp;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\libnvvp;C:\Program Files\Microsoft MPI\Bin\;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.1\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.1\libnvvp;C:\Program Files\DahuaTech\MV Viewer\Runtime\x64\;C:\Program Files\DahuaTech\MV Viewer\Runtime\Win32\;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\libnvvp;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;D:\Program Files\PuTTY\;D:\Program Files\TortoiseGit\bin;D:\Program Files\Git\cmd;D:\Qt\Qt5.12.4\Tools\mingw730_64\bin;D:\Qt\Qt5.12.4\5.12.4\mingw73_64\bin;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;D:\Program Files\nodejs\;D:\sqlite;D:\boost_1_70_0\tools\build\src\engine\bin.ntx86_64;D:\Program Files\Java\jdk1.8.0_221\bin;D:\Program Files\CMake\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\Administrator\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Users\Administrator\AppData\Local\Programs\Python\Python37;C:\Users\Administrator\AppData\Local\Programs\Python\Python37\Scripts\;C:\Users\Administrator\AppData\Local\Programs\Python\Python37\Lib;D:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64;D:\Go\bin;D:\Flutter\bin;C:\Program Files\TortoiseHg\;C:\Windows\SysWOW64\5097;C:\Windows\SysWOW64\5097;C:\Windows\SysWOW64;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\NVIDIA Corporation\Nsight Compute 2019.5.0\;C:\Program Files\MySQL\MySQL Shell 8.0\bin\;D:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Administrator\go\bin;C:\Users\Administrator\AppData\Local\Programs\Python\Python37\Scripts;c:\Program Files\MySQL\MySQL Server 8.0\bin;C:\ninja;C:\Users\Administrator\.dotnet\tools

C:\Users\Administrator>

2. Please see the attachments.

Let me know if any more info is needed.

Thanks,
Alex
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: Subst on April 08, 2021, 02:56:55 PM
look the version of Qt5Core or other lib in these folders
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: Subst on April 08, 2021, 03:01:03 PM
and
where QT has installed?
what folder?
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 08, 2021, 03:57:28 PM
My Qt's install path: D:\Qt\Qt5.12.4\
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 08, 2021, 04:09:33 PM
I noticed some environments have dlls: libGLESv2.dll and libEGL.dll but some environments don't have those two files. Are those two dlls necessary?

Thanks,
Alex
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: Subst on April 08, 2021, 04:22:25 PM
libGLESv2.dll and libEGL.dll - the libs for opengl support
They are irrelevant

try to create deployment for your program

create folder named d:\test
copy to this folder your .exe file
from cammand line: D:\Qt\Qt5.12.4\bin\windeployqt d:\test\'you_exe_file'
copy to this folder limereport.dll, QtZint.dll, libgcc_s_seh-1.dll, libstdc++-6.dll, libwinpthread-1.dll

try to lunch program
may be it's nessasary to copy some other libs, OS tell ypu about

Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 09, 2021, 04:14:43 AM
from cammand line: D:\Qt\Qt5.12.4\bin\windeployqt d:\test\'you_exe_file'
copy to this folder limereport.dll, QtZint.dll, libgcc_s_seh-1.dll, libstdc++-6.dll, libwinpthread-1.dll

-> This is exactly what I did for environment 1: the exe takes a few seconds to launch. Not impressive but still acceptable.

If I move the exe into environment 2(our production environment) which has the same dll as environmet 1 plus other dlls, the exe takes more than 1 minutes to launch...and the harddisk is 100% taken for processing something...

It is very strange to me.

Alex


Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 09, 2021, 06:36:35 AM
So the problem becomes much clearer now. If I put limereport-unrelated dlls in the exe directory, the launch becomes much slower.

tested the demo1/demo2 exe in release build.

Alex
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: Subst on April 09, 2021, 08:55:40 AM
now try from command line in folder d:\test
set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;
'your_program'.exe
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 09, 2021, 10:05:54 AM
now try from command line in folder d:\test
set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;
'your_program'.exe

-> gave it a try but it doesn't solve the problem.
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: Subst on April 09, 2021, 10:19:07 AM
is disc d: just a partition or separate physical disk?
may be trouble with drivers or something like this?

and.. I could build your program on my comp, but I use the mingw with SJLJ not SEH
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 09, 2021, 10:35:27 AM
I realy doubt it is a physical disk issue because environemnt 1 works fine.

No need to use my program because the problem exists in demo1 too. I think you can create a deployment folder for demo1 under release build.

How to reproduce:

1. restart the machine, in the deployment folder, run LRDemo_r1.exe, time the launch time as T1.
2. restart the machine, copy some extra dlls(> 20) in the deployment folder, run LRDemo_r1.exe, time the launch time as T2.

You will notice T2 is much larger than T1.

Thanks,
Alex
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 09, 2021, 11:02:30 AM
BTW, what is the correct way to build static lib of limereport? I wanna give it a try.

Thanks,
Alex
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: Subst on April 09, 2021, 11:47:28 AM
first..
I have some projects uses LR. All of them works realy fast on my machine and others, more slower then my. On Win 10, 7 & XP.
I can't reproduce your problem
And nobody can it

Therefore I think the problem in your environments, machine or so on. On your side.
I trying to do is figure out what's going on
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 09, 2021, 12:46:50 PM
That's strange. On our side, three machines have been tested and all have the same issues.

Alex
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: Subst on April 09, 2021, 01:03:34 PM
I agree it's so strange

it's especially strange because it work fine from QtCreator, as you said
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: Subst on April 09, 2021, 01:05:42 PM
well
can you send me your test project with all libs exists in folder?
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 10, 2021, 05:58:09 AM
Sure. I have prepared two environments.

env1 : https://github.com/alexyuisme/test_limereport/blob/master/env1.zip

env2: https://github.com/alexyuisme/test_limereport/blob/master/env2.zip.001
      https://github.com/alexyuisme/test_limereport/blob/master/env2.zip.002
      https://github.com/alexyuisme/test_limereport/blob/master/env2.zip.003
      https://github.com/alexyuisme/test_limereport/blob/master/env2.zip.004
      https://github.com/alexyuisme/test_limereport/blob/master/env2.zip.005

After unzip, click LRDemo_r1.exe.

Thanks,
Alex
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: Subst on April 10, 2021, 01:55:03 PM
well
look this video
https://disk.yandex.ru/i/OP9vL_fskx0Flw
it's so fast I think, less then 0.5 sec
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: Subst on April 10, 2021, 03:25:37 PM
alexyuisme, what antivirus are you using?
try to temporary disable it and lunch program
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 10, 2021, 06:47:07 PM
I can only see you launched the exe in env1 in the video. So you also tried env2 and the launch speed is the same?

I tested the static build today and the speed is similarly slow. Maybe we can root out the cause of dll look-ups.

I will try disable any antivirus and let you know.

Thanks,
Alex
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: Subst on April 10, 2021, 09:13:24 PM
yep in video only env1 shown
I sure that the second will show the same result but 'll try it

P.S. Alex, the author of LR, is monitors the our conversation and speak with me by telegram regularly
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: Subst on April 10, 2021, 09:17:21 PM
I've did it
result is same, may be one second as maximum
if you need I'll record the video also
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: Subst on April 10, 2021, 09:19:07 PM
P.S. you are using the opencv as I see
why the 3-d version not 4-th?
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 12, 2021, 03:36:38 AM
Parts of our software require opencv3. Does it hurt anything?

Alex
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 12, 2021, 03:48:23 AM
I did run .exe in env2 with antivirus disabled. The program was still slow to start.

One question: Did you run the test program on ssd or hdd? Our computers use hdd.

Thanks,
Alex
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 12, 2021, 06:01:59 AM
I did try running .exe under env1/env2 on ssd with antivirus disabled. Here's the result:

env1: 2.2 secs;
env2: 9~10 secs;

The launch speed is way faster than hdd. Tried a couple times and the result is firmed.

I know it makes zero sense, but here the launch time increases with the number of dlls increases in the exe's directory.

Thanks,
Alex
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 12, 2021, 12:48:39 PM
To confirm my theory, I used "processing explorer" to check which dlls will be accessed during the exe program startup. I found that the exe is trying to access some of the irrelevant dlls within the directory!

I don't know who is forcing this behavior but the program really does this kind of unnecessary dll-lookups.

To download process explore, here is the link:|

https://download.sysinternals.com/files/ProcessExplorer.zip

to enter view dll mode:

1. On the View menu make sure “Show Lower Pane” is checked.
2. Press CTRL + D or click View - Lower Pane View - DLLs to enable DLL view mode.

Alex
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: Subst on April 13, 2021, 02:34:53 PM
alexyuisme, I've run the test from hdd
from sdd rather faster

I have the sysinternals suite.
What exactly libraries are irrelevant you think?
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 13, 2021, 03:44:10 PM
Additional dlls look-ups include: libGLESV2d.dll, libopenblas.dll. I uploaded a video to show the launch time on my ssd takes about 22 seconds:

https://github.com/alexyuisme/test_limereport/blob/master/2021-04-12%2022-02-49.mkv

Alex
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: Subst on April 13, 2021, 04:09:35 PM
alexyuisme, Why in your environment release libraries are mixing with debug ones?
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 13, 2021, 04:36:34 PM
One crash log lib requires elf info thus lots of debug libs are included in the deployment environment folder. Are those debug libs problematic?

Alex
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: Subst on April 13, 2021, 07:23:31 PM
alexyuisme, well, lets I build test and send you?
With all libraries & dependencies
Let's see the result on your comps
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 14, 2021, 02:02:55 AM
Sure, please me know when your build is ready.

Alex
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: Subst on April 14, 2021, 09:06:51 AM
alexyuisme, it's here https://disk.yandex.ru/d/XQZqgkkc__BuZw
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 14, 2021, 10:12:06 AM
It takes 4 secs to launch your designer.exe within your test folder. Can you copy the extra dlls from my env2 to your test folder and do a hard restart(restart your machine and run again)? In this case, mine takes more than 50 secs.

Alex
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: Subst on April 14, 2021, 03:20:13 PM
alexyuisme, designer.exe it's not my application it's native app from LR, LimeReport Designer
test_limereport.exe - it's your test application

I can't hard restart my machine now :( I do it very rarely. And second - my build is with mingw SJLJ, your dll's are building with mingw SEH
SJLJ & SEH - are different methods of exception handling and not compatible one to other

but I can say it seems the your additional libs are slow down the lauching ANY application
The trouble not in Limereport
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 14, 2021, 03:56:47 PM
but I can say it seems the your additional libs are slow down the lauching ANY application
The trouble not in Limereport

-> Can't agree. If you comment out "new LimeReport" in my test program, the launch time becomes much much faster, so it definitely has something to do with Limereport. I will dive into the source code and narrow down the problem. Maybe Lamereport is looking for dll plugins that are located in the exe directory but I don't find proof at this moment.

Alex
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: Subst on April 14, 2021, 04:56:50 PM
alexyuisme, I can't andastand why on my machine LRDemo_r1 in env2 takes about 2 seconds not 30 secs or minute
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 14, 2021, 06:09:30 PM
alexyuisme, I can't andastand why on my machine LRDemo_r1 in env2 takes about 2 seconds not 30 secs or minute

Restart your machine and try again. Doing restart guarantees no memory cached.

Alex
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: Subst on April 14, 2021, 06:15:02 PM
alexyuisme, I can't restart machine
I restart my machine once at several monthes
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 14, 2021, 06:39:41 PM
alexyuisme, I can't restart machine
I restart my machine once at several monthes

Restart once at several months ;D...then I am afraid it is difficult to reproduce this issue.

That's fine. I will keep you posted whenever I find something in the source code.

Alex
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: Arin Alex on April 14, 2021, 07:04:53 PM
alexyuisme, Hi. You can try to switch off the form designer. Compile limereport with CONFIG+=no_formdesigner. 
It seems I found where limereport tries to load dlls from application dir. I will fix it soon. 
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: Arin Alex on April 14, 2021, 09:25:37 PM
alexyuisme, I think I have fixed the issue :) You can check it.
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: Subst on April 14, 2021, 10:23:46 PM
alexyuisme, why?
I have some toolchains for different platform, 32 bits and 64 bits with mingw, x64 with MSVC, x86-32 for Win XP (qt 5.6)
I can run one of them then another and cash will be unload

Alex has fixed trouble, try
Title: Re: "new LimeReport" takes 30~40 seconds!
Post by: alexyuisme on April 15, 2021, 05:16:27 AM
Hi, all:

Now we are talking.  ;)

tested ver.1.5.85 and the launch time is OK now.

Thanks,
Alex