-
Notifications
You must be signed in to change notification settings - Fork 363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance: Slow analysis of arrays #1415
Comments
Hi @ryosa can you provide a small sample please to reproduce the issue. Regards |
@guwirth Attached is not large but should take several minutes to analyze. Please change the file name. It turned out that the issue also takes place with large sized 1D arrays, say 1MB or so. |
@ryosa trying this in the SSLR toolkit it needs about 5s on my computer to parse it and create an AST.
Normally compiler are compiling one cpp file always with one core only. To reduce total time we can think about compiling more than one cpp file in parallel but that would help nothing here. Think we can have a look why total time is 5s. |
@guwirth Thank you for your try and comment. If analysis of arrays should be improved, that will be a big advantage for sonar-cxx. I expect it will be done. :-) |
@ryosa thinks I'm wondering:
Can you give some more hints? |
@guwirth Analysis is slow with both 1D and 2D arrays, and the analyzing time seems to be in proportion to the size of array. It is not a matter of hex numbers because analysis is also slow with 1D floating point and decimal number arrays. The server has been equipped with 128GB memory. The shell script below runs prior to each analysis.
The params below have been set in the properties.
Clang analyzes the project (7M LOC) in less than 10 minutes, using 20+ cores, while cppcheck takes around 40 minutes with |
Hi @ryosa, can you please tell us why do you want to execute a source code analysis on huge multi-dimensional arrays? The plug-in does not execute any special analysis on arrays and to accelerate the analysis I recommend to exclude the files with the huge array. You can use also preprocessor statements and avoid parsing all values of the array while the AST is build e.g. #ifdef SONAR_ANALYSIS
// define only a small array
#else
// the array with all values
#endif The pre-processor |
As already mentioned, I've done it. Yet the project includes a number of arrays by its nature, and it's virtually impossible to find arrays and judge if
Sonar-cxx may not do any special things, however, there must be a cause to reduce the performance of analysis. |
* precompiled regex pattern are faster than String.split() (https://shipilev.net/talks/joker-Oct2014-string-catechism.pdf, from page 72) * there are visitors, which use splitting for every ASTNode -> perceptible improvement I used example from SonarOpenCommunity#1415 and could measure some spead-up (10%?) The basic profiling with `-agentlib:hprof=cpu=samples,depth=100` was however not enough to find a root cause
@ivangalkin are you familiar with profiling? I like to analyze where we are loosing so much time in the sample : dim_test.cpp.txt |
- reduce the number of regex rules to detect a number - use only one channel to detect numbers - improve SonarOpenCommunity#1415
With SQ 5.6.7 and sonar-cxx 0.9.8, analysis of multi dimensional arrays is very slow. A 22-hour run (as a Jenkins job on CentOS7) didn't analyze a file which contains 512 2D arrays, the file size is near 5MB.
It seems that the analysis uses only one CPU. This may be a matter of Jenkins, but I wonder if the performance would be improved.
Thanks.
The text was updated successfully, but these errors were encountered: