FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Performance optimization of the Vector class by ruevs · Pull Request #762 · solvespace/solvespace · GitHub

Performance optimization of the Vector class - #762

Merged
phkahler merged 1 commit into
solvespace:masterfrom
ruevs:VectorOptimisations
Oct 24, 2020
Merged

phkahler merged 1 commit into
solvespace:masterfrom
ruevs:VectorOptimisations

Conversation

ruevs commented Oct 21, 2020

Copy link
Copy Markdown
Member

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

ruevs force-pushed the VectorOptimisations branch from 3fc6df1 to 06a2dfb Compare October 21, 2020 15:15

ruevs commented Oct 21, 2020 •
edited
Loading

Copy link
Copy Markdown
Member Author

Very interesting. GCC complained about more of the inline functions than MSVC...
XCode on the other hand was fine.

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...

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member

Never mind, I see you moved them to the header file.

ruevs commented Oct 22, 2020

Copy link
Copy Markdown
Member Author

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.

It's C++11 - returning list initialized objects directly is possible:
https://en.cppreference.com/w/cpp/language/list%20initialization

  1. in a return statement with braced-init-list used as the return expression and list-initialization initializes the returned object

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)
ruevs force-pushed the VectorOptimisations branch from 06a2dfb to c6a06e7 Compare October 23, 2020 19:02
phkahler merged commit 7035071 into solvespace:master Oct 24, 2020

Copy link
Copy Markdown
Member

@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!

ruevs deleted the VectorOptimisations branch October 24, 2020 08:07

ruevs commented Oct 24, 2020 •
edited
Loading

Copy link
Copy Markdown
Member Author

The credit goes entirely to MSVC 2019 which makes profiling extremely easy. These were just the "low hanging fruit" :-)

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL