Performance optimization of the Vector class#762
Conversation
3fc6df1 to
06a2dfb
Compare
|
Very interesting. GCC complained about more of the I would have tried with MinGW GCC but the "mimalloc" library we started using breaks both GCC and clang on windows since it uses <bcrypt.h> <winternl.h> headers that are included only in the Microsoft SDK :-( I'll move the ones the Travis build complained about in the header. Tomorrow... |
|
Also, please don't remove Negated or MakeMaxMin I was actually looking for MakeMaxMin earlier but didn't notice it. I'll be using it soon. Also, I'm not familiar with that syntax: return { a,b,c } has that been possible for a long time or more recent? Either way I think I like it. |
|
Never mind, I see you moved them to the header file. |
It's C++11 - returning list initialized objects directly is possible:
I checked the generated assembler and is makes it more compact (event with full optimizations) by not asking the compiler to create a local variable on the stack. When inlined I hope it helps even more. |
Profiling with MSVC 2019 showed that many of the Vector methods are on a critical path (not surprising). They are changed to be inline and unnecessary temporaries are removed. On the example below generate times decreased from 102s. to 64s. At the same time the executable size shrank from 5569536 to 5150208 bytes in release mode (with global optimizations). This should not stop us from working on optimizing inner loops e.g. solvespace#759 . [Test model](https://github.com/solvespace/solvespace/files/5414683/PrismConeNURBSNormalsTangents300.zip)
06a2dfb to
c6a06e7
Compare
|
@ruevs this has little effect on that sketch I've been using as a benchmark (which is down to 8s on LTO master) but it does have a very perceptible improvement in the smoothness of dragging shapes with compound curvature like resizing a torus or dragging control points of the curved surface from issue 315. Different sketches, different bottlenecks. Nice improvement here! |
|
The credit goes entirely to MSVC 2019 which makes profiling extremely easy. These were just the "low hanging fruit" :-) |
Profiling with MSVC 2019 showed that many of the Vector methods are on a critical path (not surprising). They are changed to be inline and unnecessary temporaries are removed.
On the example below generate times decreased from 102s. to 64s.
At the same time the executable size shrank from 5569536 to 5150208 bytes in release mode (with global optimizations).
This should not stop us from working on optimizing inner loops e.g. #759 .
Test model
Profiling results:
20201021_Profiling_Before.txt
20201021_ProfilingAfterVectorInline1.txt
20201021_ProfilingAfterVectorInline2.txt
20201021_ProfilingAfterVectorInline3.txt