Sketches 1000 times slower in ubuntu than windows

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
clytle374
Posts: 131
Joined: Wed Nov 06, 2013 3:58 am

Re: Sketches 1000 times slower in ubuntu than windows

Postby clytle374 » Sun Feb 16, 2014 9:46 pm

I'd wondered about that being on gcc 4.7, but the system is 64bit
Cory
triplus
Posts: 9278
Joined: Mon Dec 12, 2011 4:45 pm

Re: Sketches 1000 times slower in ubuntu than windows

Postby triplus » Sun Feb 16, 2014 10:21 pm

Maybe Eigen 3.1.3 used by clytle374 has the same bug... What's your GCC version?
As mentioned in provided bug report Eigen 3.1.3 and 3.1.4 did not fix it for them:

https://github.com/ros-planning/moveit_ ... /issues/60
I'm very disappointed to hear that 3.1.4 doesn't fix it.
They speculate in a way we are seeing it for FreeCAD performance regression:
As for this particular problem, 12.04 does not use GCC 4.7, so it should not be a problem, and the next LTS (14.04) should probably be OK since Eigen and GCC will have learned to play better together (hopefully).
BUT in the end they probably are talking about different issues because if i read it correct they are not able to produce the build but FreeCAD does not have such an issue? And only 32bit is affected for them and here we have example on 64bit systems with performance regression.

Anyway to sum it up based on the tests if it is Eigen related then i am guessing Eigen 3.0.5 or prior version and Eigen 3.2(+) should work. GCC on Ubuntu 13.10 and 14.04 it looks like it is 4.8 and therefore probably does not affect this.
triplus
Posts: 9278
Joined: Mon Dec 12, 2011 4:45 pm

Re: Sketches 1000 times slower in ubuntu than windows

Postby triplus » Sun Feb 16, 2014 11:00 pm

GCC on Ubuntu 13.10 and 14.04 it looks like it is 4.8 and therefore probably does not affect this.
Well just for the sake of completeness there is slight difference.

http://gcc.gnu.org/bugzilla/buglist.cgi ... tone=4.8.2

Ubuntu 13.10 uses gcc 4.8.1 and Ubuntu 14.04 has gcc 4.8.2. Under GENERAL gcc 4.8 release notes it is noted:
Several scalability bottle-necks have been removed from GCC's optimization passes. Compilation of extremely large functions, e.g. due to the use of the flatten attribute in the "Eigen" C++ linear algebra templates library, is significantly faster than previous releases of GCC.
I guess gcc version can play a role when it comes to Eigen! And i found this bug report how for example gcc 4.8.1 used on Ubuntu 13.10 affects Eigen:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59557

I guess it is possible in the end switching gcc could make a difference.
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Sketches 1000 times slower in ubuntu than windows

Postby NormandC » Sun Feb 16, 2014 11:06 pm

Since gcc is such a core component I wonder if it would be advisable to update it... On the other hand, there are 4 different versions in Ubuntu 12.04 (4.4 to 4.7) so it might not be problematic for a local installation.

It would for the Daily Builds PPA though, since the Launchpad servers actually do the building and rely on the Ubuntu repositories. It may be unfixable for the 13.10 Daily Builds.

Good detective work, triplus.
triplus
Posts: 9278
Joined: Mon Dec 12, 2011 4:45 pm

Re: Sketches 1000 times slower in ubuntu than windows

Postby triplus » Mon Feb 17, 2014 12:58 pm

Well today i had some spare time and decided to test the theory and found out something rather interesting. I did an fresh instal of Ubuntu 12.04.4 64bit and used latest code from git to compile FreeCAD following this instructions. I wanted to do some builds to test default packages, updated toolchain (gcc), updated Eigen... to see what introduces sketcher performance regression. First build was with default packages:
  • gcc 4.6.3
  • libeigen3-dev 3.0.5
I did two tests:

Test 1:
Removed constraint 83 before doing anything. Changing constraint 82 from 25mm to 40mm from the time I hit ok it takes 6 seconds for the dimension to move and 14 seconds total before I can interact with the window again. It should take a fraction of the second without sketcher performance regression for operation to complete.
Test 2:
There is huge difference in for example real time manipulation of tangent arcs compared to Ubuntu 13.10. For example opening file from the beginning of the thread and deleting constraint 83, 40, 14 and then trying to move around that tangent arc that constrain 14 was used on works really slow on Ubuntu 13.10 and in real time on Ubuntu 14.04.
The results are here:

Test 1: Performance regression detected = YES
Test 2: Performance regression detected = YES

Manual build of latest code on Ubuntu 12.04.4 64bit with default packages and default compile instructions and performance regression is already there just like the situation on Ubuntu 13.10! I was not expecting that and this i guess rules out Eigen and gcc and something else is making the difference. Are some additional compile flags used for Ubuntu 12.04 daily PPA builds?

I added and tested daily PPA build and the results:

Test 1: Performance regression detected = NO
Test 2: Performance regression detected = NO

Now i have daily PPA build and manual build made with default compile instructions and default packages on Ubuntu 12.04.4 64bit and PPA build works without sketcher regressions and manual build with them! This does indicate sketcher performance regression(s) is/are introduced at the build time? There must be some differences between default compile instructions and the procedure used for PPA build and if we find that well then i guess we might have/find a solution for our problems!
triplus
Posts: 9278
Joined: Mon Dec 12, 2011 4:45 pm

Re: Sketches 1000 times slower in ubuntu than windows

Postby triplus » Mon Feb 17, 2014 6:04 pm

cmake

Test 1: Performance regression detected = YES
Test 2: Performance regression detected = YES

cmake -DCMAKE_BUILD_TYPE=Release

Test 1: Performance regression detected = NO
Test 2: Performance regression detected = NO

Then i remembered nahshon asking in the past if maybe gcc defaults to Debug if Release is not explicitly set? Well i guess gcc could do that:
-O0

Reduce compilation time and make debugging produce the expected results. This is the default.
http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

AFAIK -DCMAKE_BUILD_TYPE=Release equals -O3? Does -DCMAKE_BUILD_TYPE=Debug equals -O0? Anyway at least on Ubuntu 12.04 64bit it makes huge difference if mentioned optimizations are used or not.
-O3

Optimize yet more. -O3 turns on all optimizations specified by -O2 and also turns on the -finline-functions, -funswitch-loops, -fpredictive-commoning, -fgcse-after-reload, -ftree-loop-vectorize, -ftree-slp-vectorize, -fvect-cost-model, -ftree-partial-pre and -fipa-cp-clone options.
If -DCMAKE_BUILD_TYPE=Release equals -O3 then i guess one (or more) of the mentioned -O3 optimizations makes the real difference when it comes to sketcher performance. I would test the same theory on Ubuntu 13.10 but after fighting with trying to manually compile FreeCAD and finding one barrier after another i gave up. I am willing to test the daily PPA for Ubuntu 13.10 if this is added (if it is already not added) -DCMAKE_BUILD_TYPE=Release. To see if it makes the difference or not compared to current build!

clytle374 you could test:

cmake -DCMAKE_BUILD_TYPE=Release

To see if it makes a difference on Gentoo Linux.
clytle374
Posts: 131
Joined: Wed Nov 06, 2013 3:58 am

Re: Sketches 1000 times slower in ubuntu than windows

Postby clytle374 » Mon Feb 17, 2014 6:47 pm

Will try that tonight. Being on a gentoo machine makes building stuff so much easier. Had switched to Ubuntu a few years ago, but went back the first time I needed a tool chain
Cory
User avatar
quick61
Posts: 3793
Joined: Sat Aug 24, 2013 2:49 am
Location: u.S.A.

Re: Sketches 1000 times slower in ubuntu than windows

Postby quick61 » Mon Feb 17, 2014 7:57 pm

Hokey smokes! Could it really be that simple? I just recompiled with cmake-gui having "Release" entered into the option for CMAKE_BUILD_TYPE (I was just leaving it blank) and what do you know... I can't ever remember my sketches reacting so fast! :shock:
Cmake-gui.png
Cmake-gui.png (141.96 KiB) Viewed 2991 times
Again, could it really be this simple? I have some more testing to do but the blegh.fcstd file in the first post behaves like it's a simple rectangle in Sketcher and it's taking about 90 convoluted constraints on a chicken scratch line and arc sketch, (bunches of tangent, summetry and equality constraints) before it even starts to show any signs of slowing down. WOW!

Oh, this is all on Kubuntu 13.10...

@normandc

Normand, is this set on the daily PPA?

Mark

OS: Ubuntu 13.10
Platform: 64-bit
Version: 0.14.3161 (Git)
Branch: master
Hash: 28b5d77408370551fd04a71e05649695ab72b6ed
Python version: 2.7.5+
Qt version: 4.8.4
Coin version: 4.0.0a
SoQt version: 1.5.0
OCC version: 6.7.0
This post made with 0.0% Micro$oft products - GOT LINUX?
triplus
Posts: 9278
Joined: Mon Dec 12, 2011 4:45 pm

Re: Sketches 1000 times slower in ubuntu than windows

Postby triplus » Mon Feb 17, 2014 10:28 pm

Ubuntu 13.10 64bit with default packages plus manually compiled FreeCAD (3161):
  • gcc 4.8.1
  • libeigen3-dev 3.2.0
  • OCE used from PPA.
Daily PPA

Test 1: Performance regression detected = YES
Test 2: Performance regression detected = YES

cmake

Test 1: Performance regression detected = YES
Test 2: Performance regression detected = YES

cmake -DCMAKE_BUILD_TYPE=Release

Test 1: Performance regression detected = NO
Test 2: Performance regression detected = NO

Well on both Ubuntu 12.04.4 64bit and Ubuntu 13.10 64bit using compiler optimizations (-O3) made sketcher way faster. I do not know if this affects older hardware or if any drawbacks arise because optimizations are used. Based on the tests i can say using gcc optimizations does speed up sketcher and probably that is exactly why those optimizations exist and it makes sense in a way does it not? To use compiler optimizations you get more speed compared to not using it? Latest gcc has special Eigen release note intended just for that as mentioned above and surely that has to do something if used compared to not being used. Anyway this is beyond me now i made the tests and other should decide what to do with the data and if compiler optimizations should be enabled by default or not.
User avatar
quick61
Posts: 3793
Joined: Sat Aug 24, 2013 2:49 am
Location: u.S.A.

Re: Sketches 1000 times slower in ubuntu than windows

Postby quick61 » Tue Feb 18, 2014 12:55 am

Well I for one won't be compiling without the "Release" option any time soon. It has made a noticeable difference and FreeCAD is acting like FreeCAD once again. Good on you guys for sussing this out.

I think you all deserve the :ugeek: of the week award for this one.


Mark
This post made with 0.0% Micro$oft products - GOT LINUX?