Author Topic: Single PCH file for building the CodeBlocks_wx31_64.cbp  (Read 15127 times)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Single PCH file for building the CodeBlocks_wx31_64.cbp
« Reply #15 on: November 30, 2020, 09:25:04 pm »
BTW: Don't get me wrong. I'm not opposing the visibility related changes. They are good and important!
I just don't like PCHs and I think they are stupid and a waste of time. :)

Do you get improvement when loading C::B? It should improve load performance, because the dynamic library loader has less work to do when loading DLLs with smaller number of symbols. At least on linux this is pretty slow step.

I don't know if the windows toolchain supports the gc-sections linker option (you need to use -fdata-sections and -ffunction-sections for the compiler for this to work). This leads to smaller .exe and .dll files when using hidden visibility at least on linux. My knowledge about windows related stuff is quite limited these days. :)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Single PCH file for building the CodeBlocks_wx31_64.cbp
« Reply #16 on: December 01, 2020, 03:33:19 pm »
No this is not how you benchmark. Apply all changes in your branch, then try to measure PCH-on versus PCH-off.
Currently you're measuring noPCH+massive amount of symbols and PCH+smaller amount of symbols. The linking step in C::B is serial, so it has big effects on the overall time. Smaller number of symbols improves linking performance.
OK, I see. I may need to create a new branches, and cherry pick some commits to compare the PCH-on vs PCH-off issue.

Quote
Also what happens if you just put only wx related includes in the PCH or you use the wxprec.h or whatever is called?
How can I do it, I need to first build/compile the wx.h file to a gch file?
Quote
p.s. My build time on Linux, GCC 9.3.0, Amd Ryzen7 1700 (relatively slow CPU in 2020, it is slower than a mobile cpu produced by a fashion/fruit company) is:
1. 93 sec with PCH.
2. 123 sec without PCH.
You computer is strong! I'm using an old PC which I bought in 2016.

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Single PCH file for building the CodeBlocks_wx31_64.cbp
« Reply #17 on: December 01, 2020, 04:29:13 pm »
OK, I see. I may need to create a new branches, and cherry pick some commits to compare the PCH-on vs PCH-off issue.
You don't need to do this. Just build from your branch, this would give you the PCH build time. After that disable compiling of the two pch files and change CB_PRECOMP to something else in the project settings. This would give you the noPCH build time.

How can I do it, I need to first build/compile the wx.h file to a gch file?
No idea... Probably the build of wx already provides it. The other option is to remove all non-wx headers from the sdk.h and sdk_precomp.h.

You computer is strong! I'm using an old PC which I bought in 2016.
Actually it is really slow in 2020. As I've said the fruit company has a mobile processor which is faster than it. :)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Single PCH file for building the CodeBlocks_wx31_64.cbp
« Reply #18 on: December 01, 2020, 06:34:34 pm »
OK, I see. I may need to create a new branches, and cherry pick some commits to compare the PCH-on vs PCH-off issue.
You don't need to do this. Just build from your branch, this would give you the PCH build time. After that disable compiling of the two pch files and change CB_PRECOMP to something else in the project settings. This would give you the noPCH build time.

How can I do it, I need to first build/compile the wx.h file to a gch file?
No idea... Probably the build of wx already provides it. The other option is to remove all non-wx headers from the sdk.h and sdk_precomp.h.

You computer is strong! I'm using an old PC which I bought in 2016.
Actually it is really slow in 2020. As I've said the fruit company has a mobile processor which is faster than it. :)

I find that changing "CB_PRECOMP" to "NOPCH" and disable compiling of PCH headers (remember to delete the PCH gch files if they exists) works okay for me.

Edit: Remember to remove the compiler "--include" command in your case.

Tim S.
« Last Edit: December 01, 2020, 06:44:09 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Single PCH file for building the CodeBlocks_wx31_64.cbp
« Reply #19 on: December 04, 2020, 12:27:11 am »
...

I find that changing "CB_PRECOMP" to "NOPCH" and disable compiling of PCH headers (remember to delete the PCH gch files if they exists) works okay for me.

Edit: Remember to remove the compiler "--include" command in your case.

Tim S.

I just did it, and the build time is:

Code
Process terminated with status 0 (8 minute(s), 44 second(s))
0 error(s), 22 warning(s) (8 minute(s), 44 second(s))

So, the "NOPCH" build time is just the same as the standard "two PCH files" build time. :)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Single PCH file for building the CodeBlocks_wx31_64.cbp
« Reply #20 on: December 04, 2020, 04:00:55 am »
I have check the exported symbol in the codeblocks.dll

With my changes to the visibility, the generated codeblocks.dll is about 6.2M, and the export symbol number is 3830.

Without my changes to the visibility, the dll size is about 8.2M, and the export symbol number is 28043.

This, this indeed shows some improvement :)
« Last Edit: December 04, 2020, 06:10:48 am by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Single PCH file for building the CodeBlocks_wx31_64.cbp
« Reply #21 on: December 14, 2020, 02:22:20 am »
I am planning to push the visibility related commits, not pch related commits, any objections?
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Single PCH file for building the CodeBlocks_wx31_64.cbp
« Reply #22 on: December 14, 2020, 12:40:11 pm »
Can you please make a branch based on master with the commits you want to push, so I can take a look?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Single PCH file for building the CodeBlocks_wx31_64.cbp
« Reply #23 on: December 14, 2020, 04:57:17 pm »
Can you please make a branch based on master with the commits you want to push, so I can take a look?

OK, I have created a new clean branch, see here:
https://github.com/asmwarrior/codeblocks_sf/tree/visibility2020
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Single PCH file for building the CodeBlocks_wx31_64.cbp
« Reply #24 on: December 15, 2020, 01:06:41 am »
In fact can you start a pull request, so we can do a discussion there?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Single PCH file for building the CodeBlocks_wx31_64.cbp
« Reply #25 on: December 15, 2020, 01:19:28 am »
In fact can you start a pull request, so we can do a discussion there?

Done.

https://github.com/obfuscated/codeblocks_sf/pull/15
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Single PCH file for building the CodeBlocks_wx31_64.cbp
« Reply #26 on: December 22, 2020, 07:27:13 pm »
I've posted some comments on it.

It seems to build fine on Linux.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Single PCH file for building the CodeBlocks_wx31_64.cbp
« Reply #27 on: December 23, 2020, 06:45:45 am »
I've posted some comments on it.

It seems to build fine on Linux.

I make some fix, and do a rebase, and I see the pull request get updated.

BTW: there are too many "extern" keywords already in our code base for global functions.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Single PCH file for building the CodeBlocks_wx31_64.cbp
« Reply #28 on: December 23, 2020, 10:38:17 am »
Yes, I know, just don't add new ones. :)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Single PCH file for building the CodeBlocks_wx31_64.cbp
« Reply #29 on: December 23, 2020, 10:40:13 am »
And please don't do any more rebases. I'm really confused what happened.  :o
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]