v8toolkit icon indicating copy to clipboard operation
v8toolkit copied to clipboard

Wrapping a lot of types in a single file results in very large compilations

Open xaxxon opened this issue 8 years ago • 2 comments

I had a file with 1000 lines of wrapping code and couldn't compile it on a computer with 4GB of ram without it going many GB into swap.

I've attempted to optimize some of the more commonly used templates and stopped using many of the templated helper types internally in the library to reduce template bloat.

If anyone has any good suggestions on how to profile template creation during compile time, that would be great (or just post results from doing so).

Also, compiling without -g (or by adding -g0 after a -g flag) for these files can help dramatically. To do so for a subset of your files in CMake, you can use the following command:

set_source_files_properties(${LIST_OF_FILES} PROPERTIES COMPILE_FLAGS -g0)

Of course, then you don't get debugging information in these files, though.

xaxxon avatar Jul 17 '16 18:07 xaxxon

I've made a bunch of changes to limit how often the template is instantiated, but it adds complexity to using the library.

xaxxon avatar Jul 29 '16 10:07 xaxxon

Some additional progress made my limiting use of certain std:: constructs like std::map and std::unique_ptr. Turning off debugging symbols while compiling translation units with the bindings also helps a lot.

xaxxon avatar Apr 23 '17 04:04 xaxxon