Sol2: How to speed up compilation?

Created on 10 Nov 2020  路  2Comments  路  Source: ThePhD/sol2

Hello,
In my project, there are a lot of classes need to be exported. the cpp file is about 100,000 lines, takes 30 minutes to compile, and fails out of memory.
At present, I have split the CPP files.
The compiler is vs2019, and I tried the CLang compiler, but it took a long time.
So, how can i speed up compilation?

Thanks for your help !

Help.Desk

Most helpful comment

My suggestions are along the same lines:

  • use .new_enum<blah>( { { "name", value }, {"name", value } } ); to explicitly use theinitializer_list` form, which is vastly cheaper than the variadic functino form
  • similarly, use auto ut = state.new_usertype<my_class>("my_class", constructor ); and then ut["foo"] = &my_class::foo to prevent from using the long-form constructor that is a variadic template and thus takes a million years to compile
  • split usertypes up between different files, make sure they are in .cpp files and not headers to avoid dragging bloat into every other header/compiled file

I have to do a formal compile-time investigation with aras-p's tool. I just have a lot of other things on my plate at the moment, too. 馃槄

All 2 comments

I assume your mainly registering usertypes? This is non-performace critical code, so chunk your usertype defintions into seperate files and cache the object files.
Use CCache (linux, I assume windows has something similar) to speed up object compilation and llvm linker to speed up linking.

Compile times are long - that is the trade off for runtime speed.

My suggestions are along the same lines:

  • use .new_enum<blah>( { { "name", value }, {"name", value } } ); to explicitly use theinitializer_list` form, which is vastly cheaper than the variadic functino form
  • similarly, use auto ut = state.new_usertype<my_class>("my_class", constructor ); and then ut["foo"] = &my_class::foo to prevent from using the long-form constructor that is a variadic template and thus takes a million years to compile
  • split usertypes up between different files, make sure they are in .cpp files and not headers to avoid dragging bloat into every other header/compiled file

I have to do a formal compile-time investigation with aras-p's tool. I just have a lot of other things on my plate at the moment, too. 馃槄

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sagunkho picture sagunkho  路  4Comments

squeek502 picture squeek502  路  3Comments

mrgreywater picture mrgreywater  路  4Comments

hmenke picture hmenke  路  6Comments

karenzshea picture karenzshea  路  4Comments