Skip to content
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

Add O2 and LTCG flag for MSVC Windows branch #2

Merged
merged 3 commits into from
Jul 29, 2021
Merged

Add O2 and LTCG flag for MSVC Windows branch #2

merged 3 commits into from
Jul 29, 2021

Conversation

VOM7HC
Copy link

@VOM7HC VOM7HC commented Jun 25, 2021

CMakeList current just optimize for Unix. Clang and GNU GCC have O3 flag for optimize performance code. MSVC doesn't have O3, so I use O2 flag for speed and LTCG for force compiler use inline function every time.
In my personal test, I saw in task manager, use O2 and LTCG help to improve estimate 2% ~ 5% CPU usage.

LTCG flag
O2 flag

@vi3itor
Copy link
Owner

vi3itor commented Jun 28, 2021

Hi @WesleyKhoiVo! Thanks for your contribution! I will check it out after I finish with the PR for gfootball.
I plan to finalize the changes and merge windows branch once I have enough time.

I thought that cmake's --config Release adds O2 flag automatically, but indeed LTCG might squeeze in some additional performance.

@VOM7HC
Copy link
Author

VOM7HC commented Jun 28, 2021

I can't find any document or link say cmake add O2 automatically when we switch to Release, so I added it manually.

Note: it just improve CPU usage, FPS still drop sometime, so we need more time to cleanup game engine

@vi3itor vi3itor mentioned this pull request Jul 27, 2021
@vi3itor
Copy link
Owner

vi3itor commented Jul 28, 2021

I'm testing the PR and get the following warning after building:
LINK : /LTCG specified but no code generation required; remove /LTCG from the link command line to improve linker performance.
Do you have it too?

@VOM7HC
Copy link
Author

VOM7HC commented Jul 28, 2021

Update comment:
MSVC require so much. I use Visual Studio solution, which generated by CMake, then I added LTCG flag in properties window to build, for test performance. It may be auto add or remove some other flags when I add LTCG. Then I added LTCG back to cmakelist.txt. Now I will find solution, then update it again
Reference issue and fix it from MS forum:
Compiling with "Whole Program Optimization" but linker says no code generation required

@VOM7HC
Copy link
Author

VOM7HC commented Jul 28, 2021

And linker performance is just effect to compile time, not effect to runtime anyway 😄

@VOM7HC
Copy link
Author

VOM7HC commented Jul 28, 2021

Hi @vi3itor, can you recheck again?

@vi3itor
Copy link
Owner

vi3itor commented Jul 29, 2021

I checked, the warning is gone.
Funny, the total size of the *.lib files is 1.3 Gb, with blunted2.lib along being 706 Mb. Since only an executable and .dll are required for running the game I will add an installation script to compile the game and remove unnecessary files. Probably even better is to improve CMakeLists.txt.

@VOM7HC
Copy link
Author

VOM7HC commented Jul 29, 2021

Yeah, I think I will remove *.lib in another PR. This PR is just improve performance via flags compiler.

@vi3itor vi3itor merged commit 7f0d6d2 into vi3itor:windows Jul 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants