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

Improve compilation time #643

Open
mpusz opened this issue Nov 16, 2024 · 6 comments
Open

Improve compilation time #643

mpusz opened this issue Nov 16, 2024 · 6 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed refactor Modify existing code potentially causing breaking changes

Comments

@mpusz
Copy link
Owner

mpusz commented Nov 16, 2024

I made some changes recently that improved the compilation time roughly 2x. Those were low-hanging fruits.
There is probably still room for improvement, but I do not have time to invest time in it now.

Today I did some benchmarks with -ftime-trace and ClangBuildAnalyzer. I timed building all the examples separately for headers and modules. Here is the output of both experiments:

Headers
Analyzing build trace from 'headers.trace'...
**** Time summary:
Compilation (50 times):
  Parsing (frontend):          590.1 s
  Codegen & opts (backend):    212.0 s

**** Files that took longest to parse (compiler frontend):
 51814 ms: build/clang-18-26/example/CMakeFiles/spectroscopy_units-headers.dir/Release/spectroscopy_units.cpp.o
 39061 ms: build/clang-18-26/example/CMakeFiles/storage_tank-headers.dir/Release/storage_tank.cpp.o
 33830 ms: build/clang-18-26/example/CMakeFiles/strong_angular_quantities-headers.dir/Release/strong_angular_quantities.cpp.o
 33648 ms: build/clang-18-26/example/CMakeFiles/hello_units-headers.dir/Release/hello_units.cpp.o
 33192 ms: build/clang-18-26/example/CMakeFiles/avg_speed-headers.dir/Release/avg_speed.cpp.o
 32207 ms: build/clang-18-26/example/CMakeFiles/hw_voltage-headers.dir/Release/hw_voltage.cpp.o
 31185 ms: build/clang-18-26/example/CMakeFiles/foot_pound_second-headers.dir/Release/foot_pound_second.cpp.o
 31047 ms: build/clang-18-26/example/CMakeFiles/capacitor_time_curve-headers.dir/Release/capacitor_time_curve.cpp.o
 27889 ms: build/clang-18-26/example/CMakeFiles/total_energy-headers.dir/Release/total_energy.cpp.o
 27176 ms: build/clang-18-26/example/CMakeFiles/clcpp_response-headers.dir/Release/clcpp_response.cpp.o

**** Files that took longest to codegen (compiler backend):
 25327 ms: build/clang-18-26/example/CMakeFiles/spectroscopy_units-headers.dir/Release/spectroscopy_units.cpp.o
 22368 ms: build/clang-18-26/example/CMakeFiles/foot_pound_second-headers.dir/Release/foot_pound_second.cpp.o
 17469 ms: build/clang-18-26/example/CMakeFiles/si_constants-headers.dir/Release/si_constants.cpp.o
 14646 ms: build/clang-18-26/example/CMakeFiles/storage_tank-headers.dir/Release/storage_tank.cpp.o
 13589 ms: build/clang-18-26/example/CMakeFiles/glide_computer-headers.dir/Release/glide_computer.cpp.o
 11753 ms: build/clang-18-26/example/CMakeFiles/conversion_factor-headers.dir/Release/conversion_factor.cpp.o
 10305 ms: build/clang-18-26/example/CMakeFiles/hello_units-headers.dir/Release/hello_units.cpp.o
  9961 ms: build/clang-18-26/example/CMakeFiles/clcpp_response-headers.dir/Release/clcpp_response.cpp.o
  9141 ms: build/clang-18-26/example/CMakeFiles/unmanned_aerial_vehicle-headers.dir/Release/unmanned_aerial_vehicle.cpp.o
  8931 ms: build/clang-18-26/example/glide_computer_lib/CMakeFiles/glide_computer_lib-headers.dir/Release/glide_computer_lib.cpp.o

**** Templates that took longest to instantiate:
 11305 ms: mp_units::explicitly_convertible<mp_units::derived_quantity_spec<mp_... (7 times, avg 1615 ms)
 11301 ms: mp_units::detail::convertible<mp_units::derived_quantity_spec<mp_uni... (7 times, avg 1614 ms)
 11021 ms: mp_units::detail::convertible_impl<mp_units::derived_quantity_spec<m... (7 times, avg 1574 ms)
 10854 ms: mp_units::detail::explode<0, mp_units::derived_quantity_spec<mp_unit... (7 times, avg 1550 ms)
 10562 ms: mp_units::detail::explode<0, mp_units::derived_quantity_spec<mp_unit... (7 times, avg 1508 ms)
 10540 ms: mp_units::explicitly_convertible<mp_units::derived_quantity_spec<mp_... (12 times, avg 878 ms)
 10532 ms: mp_units::detail::convertible<mp_units::derived_quantity_spec<mp_uni... (12 times, avg 877 ms)
 10303 ms: mp_units::detail::convertible_impl<mp_units::derived_quantity_spec<m... (12 times, avg 858 ms)
 10108 ms: mp_units::detail::explode<0, mp_units::derived_quantity_spec<mp_unit... (7 times, avg 1444 ms)
  9696 ms: mp_units::explicitly_convertible<mp_units::derived_quantity_spec<mp_... (7 times, avg 1385 ms)
  9690 ms: mp_units::detail::convertible<mp_units::derived_quantity_spec<mp_uni... (7 times, avg 1384 ms)
  9597 ms: mp_units::detail::explode<0, mp_units::derived_quantity_spec<mp_unit... (7 times, avg 1371 ms)
  9573 ms: mp_units::detail::convertible_impl<mp_units::derived_quantity_spec<m... (7 times, avg 1367 ms)
  9261 ms: mp_units::detail::explode<0, mp_units::derived_quantity_spec<mp_unit... (12 times, avg 771 ms)
  9210 ms: mp_units::explicitly_convertible<mp_units::derived_quantity_spec<mp_... (7 times, avg 1315 ms)
  9204 ms: mp_units::detail::convertible<mp_units::derived_quantity_spec<mp_uni... (7 times, avg 1314 ms)
  8880 ms: mp_units::detail::convertible_impl<mp_units::derived_quantity_spec<m... (7 times, avg 1268 ms)
  8749 ms: mp_units::explicitly_convertible<mp_units::derived_quantity_spec<mp_... (7 times, avg 1249 ms)
  8742 ms: mp_units::detail::convertible<mp_units::derived_quantity_spec<mp_uni... (7 times, avg 1248 ms)
  8662 ms: mp_units::detail::explode<0, mp_units::derived_quantity_spec<mp_unit... (7 times, avg 1237 ms)
  8650 ms: mp_units::detail::convertible_impl<mp_units::derived_quantity_spec<m... (7 times, avg 1235 ms)
  8540 ms: mp_units::detail::explode<0, mp_units::derived_quantity_spec<mp_unit... (12 times, avg 711 ms)
  8532 ms: mp_units::detail::explode<0, mp_units::derived_quantity_spec<mp_unit... (7 times, avg 1218 ms)
  8464 ms: mp_units::detail::explode<0, mp_units::derived_quantity_spec<mp_unit... (7 times, avg 1209 ms)
  8132 ms: mp_units::detail::explode<0, mp_units::derived_quantity_spec<mp_unit... (7 times, avg 1161 ms)
  8057 ms: mp_units::detail::explode<0, mp_units::derived_quantity_spec<mp_unit... (12 times, avg 671 ms)
  8028 ms: mp_units::detail::explode<0, mp_units::derived_quantity_spec<mp_unit... (12 times, avg 669 ms)
  7842 ms: mp_units::detail::explode<0, mp_units::derived_quantity_spec<mp_unit... (7 times, avg 1120 ms)
  7806 ms: mp_units::detail::explode<0, mp_units::derived_quantity_spec<mp_unit... (7 times, avg 1115 ms)
  7176 ms: mp_units::explicitly_convertible<mp_units::derived_quantity_spec<mp_... (12 times, avg 598 ms)

**** Template sets that took longest to instantiate:
119499 ms: mp_units::detail::convertible<$> (748 times, avg 159 ms)
115721 ms: mp_units::prefixed_unit<$> (16161 times, avg 7 ms)
115425 ms: mp_units::detail::convertible_impl<$> (662 times, avg 174 ms)
112488 ms: mp_units::explicitly_convertible<$> (404 times, avg 278 ms)
 79991 ms: mp_units::detail::get_optimized_expression<$> (4691 times, avg 17 ms)
 70900 ms: mp_units::detail::explode<$> (426 times, avg 166 ms)
 68320 ms: mp_units::detail::expr_map<$> (5901 times, avg 11 ms)
 65983 ms: mp_units::detail::expr_divide<$> (3855 times, avg 17 ms)
 65636 ms: mp_units::derived_quantity_spec<$> (4691 times, avg 13 ms)
 65329 ms: mp_units::detail::derived_quantity_spec_impl<$> (4691 times, avg 13 ms)
 63912 ms: mp_units::detail::expr_map_impl<$> (5892 times, avg 10 ms)
 58125 ms: mp_units::detail::expr_make_spec_impl<$> (4345 times, avg 13 ms)
 48413 ms: mp_units::detail::expr_multiply<$> (3043 times, avg 15 ms)
 36770 ms: mp_units::detail::_multiply_impl<$> (1763 times, avg 20 ms)
 33063 ms: mp_units::detail::get_associated_quantity<$> (1521 times, avg 21 ms)
 33034 ms: mp_units::get_quantity_spec<$> (1459 times, avg 22 ms)
 32060 ms: mp_units::detail::get_associated_quantity_impl<$> (1521 times, avg 21 ms)
 31893 ms: std::__1::format<$> (98 times, avg 325 ms)
 30399 ms: std::__1::make_format_args<$> (150 times, avg 202 ms)
 30270 ms: std::__format_arg_store<$>::__format_arg_store (143 times, avg 211 ms)
 30182 ms: std::__format::__create_packed_storage<$> (143 times, avg 211 ms)
 29889 ms: std::__format::__create_format_arg<$> (244 times, avg 122 ms)
 29145 ms: mp_units::detail::expr_less_impl<$> (4859 times, avg 5 ms)
 28996 ms: mp_units::magnitude<$> (5091 times, avg 5 ms)
 25480 ms: mp_units::detail::are_ingredients_convertible<$> (295 times, avg 86 ms)
 24982 ms: mp_units::detail::expr_fractions<$> (7207 times, avg 3 ms)
 23737 ms: mp_units::detail::expr_fractions_impl<$> (7140 times, avg 3 ms)
 23275 ms: mp_units::detail::get_kind_tree_root<$> (1998 times, avg 11 ms)
 21686 ms: mp_units::detail::determine_associated_quantity<$> (1496 times, avg 14 ms)
 21625 ms: std::__1::formatter<$>::format_quantity<$> (432 times, avg 50 ms)

**** Functions that took longest to compile:
   217 ms: main (/home/mpusz/repos/units.worktrees/master/example/glide_computer.cpp)
   217 ms: std::__1::back_insert_iterator<std::__1::__format::__output_buffer<c... (/home/mpusz/repos/units.worktrees/master/example/spectroscopy_units.cpp)
   184 ms: _ZNSt3__19formatterIN8mp_units8quantityIXtlNS1_2si6milli_INS3_5metre... (/home/mpusz/repos/units.worktrees/master/example/conversion_factor.cpp)
   139 ms: std::__1::back_insert_iterator<std::__1::__format::__output_buffer<c... (/home/mpusz/repos/units.worktrees/master/example/unmanned_aerial_vehicle.cpp)
   130 ms: _ZNSt3__111__formatter23__format_floating_pointB8ne180100ITkNS_14flo... (/home/mpusz/repos/units.worktrees/master/example/spectroscopy_units.cpp)
   128 ms: _ZNSt3__111__formatter32__write_using_decimal_separatorsB8ne180100IN... (/home/mpusz/repos/units.worktrees/master/example/hello_units.cpp)
   122 ms: std::__1::__wrap_iter<char*> std::__1::basic_string<char, std::__1::... (/home/mpusz/repos/units.worktrees/master/example/conversion_factor.cpp)
   115 ms: main (/home/mpusz/repos/units.worktrees/master/example/measurement.cpp)
   114 ms: std::__1::__formatter::__float_result std::__1::__formatter::__forma... (/home/mpusz/repos/units.worktrees/master/example/kalman_filter/kalman_filter-example_4.cpp)
   106 ms: std::__1::back_insert_iterator<std::__1::__format::__output_buffer<c... (/home/mpusz/repos/units.worktrees/master/example/kalman_filter/kalman_filter-example_2.cpp)
   104 ms: _ZNSt3__111__formatter32__write_using_decimal_separatorsB8ne180100IN... (/home/mpusz/repos/units.worktrees/master/example/conversion_factor.cpp)
   102 ms: _ZNSt3__111__formatter23__format_floating_pointB8ne180100ITkNS_14flo... (/home/mpusz/repos/units.worktrees/master/example/si_constants.cpp)
    98 ms: std::__1::back_insert_iterator<std::__1::__format::__output_buffer<c... (/home/mpusz/repos/units.worktrees/master/example/conversion_factor.cpp)
    97 ms: std::__1::back_insert_iterator<std::__1::__format::__output_buffer<c... (/home/mpusz/repos/units.worktrees/master/example/hw_voltage.cpp)
    96 ms: _ZNSt3__111__formatter23__format_floating_pointB8ne180100ITkNS_14flo... (/home/mpusz/repos/units.worktrees/master/example/conversion_factor.cpp)
    96 ms: std::__1::back_insert_iterator<std::__1::__format::__output_buffer<c... (/home/mpusz/repos/units.worktrees/master/example/kalman_filter/kalman_filter-example_3.cpp)
    96 ms: _ZNSt3__111__formatter32__write_using_decimal_separatorsB8ne180100IN... (/home/mpusz/repos/units.worktrees/master/example/si_constants.cpp)
    96 ms: _ZNSt3__111__formatter23__format_floating_pointB8ne180100ITkNS_14flo... (/home/mpusz/repos/units.worktrees/master/example/spectroscopy_units.cpp)
    95 ms: std::__1::back_insert_iterator<std::__1::__format::__output_buffer<c... (/home/mpusz/repos/units.worktrees/master/example/kalman_filter/kalman_filter-example_4.cpp)
    95 ms: _ZN8mp_units6detail9to_streamIcNSt3__111char_traitsIcEENS_8quantityI... (/home/mpusz/repos/units.worktrees/master/example/hello_units.cpp)
    95 ms: _ZNSt3__111__formatter23__format_floating_pointB8ne180100ITkNS_14flo... (/home/mpusz/repos/units.worktrees/master/example/storage_tank.cpp)
    94 ms: _ZNKSt3__19formatterIN8mp_units8quantityIXtlNS1_9referenceINS1_3isq9... (/home/mpusz/repos/units.worktrees/master/example/spectroscopy_units.cpp)
    94 ms: std::__1::back_insert_iterator<std::__1::__format::__output_buffer<c... (/home/mpusz/repos/units.worktrees/master/example/conversion_factor.cpp)
    94 ms: std::__1::back_insert_iterator<std::__1::__format::__output_buffer<c... (/home/mpusz/repos/units.worktrees/master/example/si_constants.cpp)
    93 ms: std::__1::back_insert_iterator<std::__1::basic_string<char, std::__1... (/home/mpusz/repos/units.worktrees/master/example/conversion_factor.cpp)
    93 ms: std::__1::back_insert_iterator<std::__1::__format::__output_buffer<c... (/home/mpusz/repos/units.worktrees/master/example/storage_tank.cpp)
    93 ms: _ZNSt3__111__formatter23__format_floating_pointB8ne180100ITkNS_14flo... (/home/mpusz/repos/units.worktrees/master/example/hw_voltage.cpp)
    92 ms: std::__1::back_insert_iterator<std::__1::__format::__output_buffer<c... (/home/mpusz/repos/units.worktrees/master/example/si_constants.cpp)
    92 ms: _ZNSt3__111__formatter23__format_floating_pointB8ne180100ITkNS_14flo... (/home/mpusz/repos/units.worktrees/master/example/conversion_factor.cpp)
    91 ms: std::__1::back_insert_iterator<std::__1::__format::__output_buffer<c... (/home/mpusz/repos/units.worktrees/master/example/kalman_filter/kalman_filter-example_4.cpp)

**** Function sets that took longest to compile / optimize:
  3634 ms: std::__1::back_insert_iterator<$> std::__1::formatter<$>::format_qua... (232 times, avg 15 ms)
  3229 ms: std::__1::back_insert_iterator<$> std::__1::__formatter::__format_lo... (38 times, avg 84 ms)
  1353 ms: std::__1::formatter<$>::quantity_formatter<$>::on_number() (232 times, avg 5 ms)
  1351 ms: std::__1::formatter<$>::quantity_formatter<$>::on_dimension() (232 times, avg 5 ms)
  1346 ms: auto std::__1::formatter<$>::format<$>(mp_units::quantity<$> const&,... (116 times, avg 11 ms)
  1314 ms: std::__1::formatter<$>::quantity_formatter<$>::on_unit() (232 times, avg 5 ms)
  1046 ms: std::__1::__wrap_iter<$> std::__1::basic_string<$>::__insert_with_si... (19 times, avg 55 ms)
   891 ms: decltype(fp0.out()) std::__1::formatter<$>::format<$>(mp_units::deri... (51 times, avg 17 ms)
   889 ms: std::__1::formatter<$>::formatter() (119 times, avg 7 ms)
   852 ms: std::__1::__formatter::__float_result std::__1::__formatter::__forma... (19 times, avg 44 ms)
   828 ms: std::__1::__formatter::__float_result std::__1::__formatter::__forma... (19 times, avg 43 ms)
   780 ms: std::__1::__formatter::__float_result std::__1::__formatter::__forma... (19 times, avg 41 ms)
   554 ms: decltype(fp0.out()) std::__1::formatter<$>::format<$>(mp_units::deri... (29 times, avg 19 ms)
   387 ms: char const* std::__1::formatter<$>::parse_default_spec<$>(char const... (12 times, avg 32 ms)
   379 ms: std::__1::__basic_format_arg_value<$>::__handle::__handle[abi:ne1801... (51 times, avg 7 ms)
   365 ms: decltype(auto) std::__1::__visit_format_arg[abi:ne180100]<$>(mp_unit... (19 times, avg 19 ms)
   306 ms: std::__1::basic_format_parse_context<$>::iterator std::__1::__format... (19 times, avg 16 ms)
   302 ms: std::__1::to_chars_result std::__1::__to_chars_integral[abi:ne180100... (19 times, avg 15 ms)
   297 ms: std::__1::basic_format_context<$>::iterator std::__1::formatter<$>::... (19 times, avg 15 ms)
   277 ms: std::__1::__unicode::__extended_grapheme_cluster_view<$>::__get_brea... (19 times, avg 14 ms)
   268 ms: std::__1::basic_ostream<$>& std::__1::__put_character_sequence[abi:n... (25 times, avg 10 ms)
   267 ms: std::__1::formatter<$>::~formatter() (123 times, avg 2 ms)
   255 ms: std::__1::__formatter::__float_result std::__1::__formatter::__forma... (19 times, avg 13 ms)
   253 ms: std::__1::__unicode::__code_point_view<$>::__consume[abi:ne180100]() (19 times, avg 13 ms)
   249 ms: decltype(fp0.out()) std::__1::formatter<$>::format<$>(mp_units::isq:... (12 times, avg 20 ms)
   246 ms: std::__1::__formatter::__float_result std::__1::__formatter::__forma... (19 times, avg 12 ms)
   243 ms: std::__1::__formatter::__float_result std::__1::__formatter::__forma... (19 times, avg 12 ms)
   239 ms: std::__1::__format_spec::__parsed_specifications<$> std::__1::__form... (19 times, avg 12 ms)
   231 ms: void std::__1::__formatter::__escape[abi:ne180100]<$>(std::__1::basi... (19 times, avg 12 ms)
   230 ms: std::__1::basic_format_context<$>::iterator std::__1::__formatter_st... (19 times, avg 12 ms)

**** Expensive headers:
166546 ms: /home/mpusz/repos/units.worktrees/master/src/systems/include/mp-units/systems/si.h (included 19 times, avg 8765 ms), included via:
  16x: <direct include>
  2x: geographic.h 
  1x: glide_computer_lib.h geographic.h 

157625 ms: /home/mpusz/repos/units.worktrees/master/src/systems/include/mp-units/systems/si/unit_symbols.h (included 24 times, avg 6567 ms), included via:
  16x: si.h 
  5x: <direct include>
  2x: geographic.h si.h 
  1x: glide_computer_lib.h geographic.h si.h 

113495 ms: /home/mpusz/repos/units.worktrees/master/src/systems/include/mp-units/systems/isq.h (included 6 times, avg 18915 ms), included via:
  5x: <direct include>
  1x: isq_angle.h 

108188 ms: /home/mpusz/repos/units.worktrees/master/src/systems/include/mp-units/systems/isq/electromagnetism.h (included 7 times, avg 15455 ms), included via:
  5x: isq.h 
  1x: isq_angle.h isq.h 
  1x: <direct include>

45330 ms: /home/mpusz/repos/units.worktrees/master/src/systems/include/mp-units/systems/isq/mechanics.h (included 12 times, avg 3777 ms), included via:
  5x: isq.h electromagnetism.h 
  3x: thermodynamics.h 
  2x: <direct include>
  1x: electromagnetism.h 
  1x: isq_angle.h isq.h electromagnetism.h 

38387 ms: /home/mpusz/repos/units.worktrees/master/example/include/geographic.h (included 3 times, avg 12795 ms), included via:
  2x: <direct include>
  1x: glide_computer_lib.h 

26700 ms: /home/mpusz/repos/units.worktrees/master/src/systems/include/mp-units/systems/isq/thermodynamics.h (included 9 times, avg 2966 ms), included via:
  5x: isq.h 
  3x: <direct include>
  1x: isq_angle.h isq.h 

22689 ms: /home/mpusz/repos/units.worktrees/master/src/core/include/mp-units/format.h (included 19 times, avg 1194 ms), included via:
  8x: kalman.h 
  8x: <direct include>
  2x: geographic.h 
  1x: glide_computer_lib.h geographic.h 

21117 ms: /home/mpusz/repos/units.worktrees/master/src/systems/include/mp-units/systems/isq/space_and_time.h (included 24 times, avg 879 ms), included via:
  7x: <direct include>
  5x: isq.h electromagnetism.h mechanics.h 
  3x: thermodynamics.h mechanics.h 
  2x: geographic.h 
  2x: mechanics.h 
  2x: si.h math.h 
  ...

19912 ms: /home/mpusz/repos/units.worktrees/master/src/systems/include/mp-units/systems/isq_angle.h (included 1 times, avg 19912 ms), included via:
  1x: <direct include>

  done in 0.5s.
Modules
Analyzing build trace from 'modules.trace'...
**** Time summary:
Compilation (53 times):
  Parsing (frontend):          383.9 s
  Codegen & opts (backend):    232.1 s

**** Files that took longest to parse (compiler frontend):
 40307 ms: build/clang-18-26/src/systems/CMakeFiles/mp-units-systems.dir/Release/mp_units.systems.json
 39233 ms: build/clang-18-26/example/CMakeFiles/spectroscopy_units.dir/Release/spectroscopy_units.cpp.o
 23861 ms: build/clang-18-26/example/CMakeFiles/foot_pound_second.dir/Release/foot_pound_second.cpp.o
 23543 ms: build/clang-18-26/example/CMakeFiles/total_energy.dir/Release/total_energy.cpp.o
 17183 ms: build/clang-18-26/example/CMakeFiles/storage_tank.dir/Release/storage_tank.cpp.o
 16633 ms: build/clang-18-26/example/glide_computer_lib/CMakeFiles/glide_computer_lib.dir/Release/glide_computer_lib.cpp.o
 16184 ms: build/clang-18-26/example/CMakeFiles/clcpp_response.dir/Release/clcpp_response.cpp.o
 13694 ms: build/clang-18-26/example/CMakeFiles/si_constants.dir/Release/si_constants.cpp.o
 13567 ms: build/clang-18-26/example/kalman_filter/CMakeFiles/kalman_filter-example_2.dir/Release/kalman_filter-example_2.cpp.o
 12594 ms: build/clang-18-26/example/CMakeFiles/glide_computer.dir/Release/glide_computer.cpp.o

**** Files that took longest to codegen (compiler backend):
 25438 ms: build/clang-18-26/example/CMakeFiles/foot_pound_second.dir/Release/foot_pound_second.cpp.o
 23214 ms: build/clang-18-26/example/CMakeFiles/si_constants.dir/Release/si_constants.cpp.o
 20984 ms: build/clang-18-26/example/CMakeFiles/spectroscopy_units.dir/Release/spectroscopy_units.cpp.o
 15532 ms: build/clang-18-26/example/CMakeFiles/storage_tank.dir/Release/storage_tank.cpp.o
 15188 ms: build/clang-18-26/example/CMakeFiles/glide_computer.dir/Release/glide_computer.cpp.o
 13365 ms: build/clang-18-26/example/CMakeFiles/clcpp_response.dir/Release/clcpp_response.cpp.o
 10994 ms: build/clang-18-26/example/CMakeFiles/unmanned_aerial_vehicle.dir/Release/unmanned_aerial_vehicle.cpp.o
 10657 ms: build/clang-18-26/example/glide_computer_lib/CMakeFiles/glide_computer_lib.dir/Release/glide_computer_lib.cpp.o
 10426 ms: build/clang-18-26/example/kalman_filter/CMakeFiles/kalman_filter-example_5.dir/Release/kalman_filter-example_5.cpp.o
  9619 ms: build/clang-18-26/example/kalman_filter/CMakeFiles/kalman_filter-example_4.dir/Release/kalman_filter-example_4.cpp.o

**** Templates that took longest to instantiate:
  8369 ms: print_line_si<mp_units::quantity<mp_units::reference<mp_units::isq::... (1 times, avg 8369 ms)
  7774 ms: std::__1::vformat_to<std::__1::back_insert_iterator<std::__format::_... (38 times, avg 204 ms)
  7716 ms: std::__vformat_to<std::__1::back_insert_iterator<std::__format::__ou... (36 times, avg 214 ms)
  7200 ms: print_header<mp_units::quantity_point<reference<Celsius_temperature,... (3 times, avg 2400 ms)
  6127 ms: mp_units::_numerator (149 times, avg 41 ms)
  5909 ms: mp_units::_pow<-1, 1> (226 times, avg 26 ms)
  5580 ms: std::__basic_format_arg_value<std::__1::basic_format_context<std::__... (19 times, avg 293 ms)
  5437 ms: std::__1::vformat_to<std::__1::back_insert_iterator<std::__1::basic_... (38 times, avg 143 ms)
  5357 ms: std::__vformat_to<std::__1::back_insert_iterator<std::__1::basic_str... (38 times, avg 140 ms)
  5333 ms: std::__formatter_integer<char>::format<__int128, std::__1::basic_for... (19 times, avg 280 ms)
  5268 ms: mp_units::pow<2L, 1L> (12 times, avg 439 ms)
  4779 ms: (anonymous namespace)::total_energy<mp_units::quantity<reference<mom... (1 times, avg 4779 ms)
  4503 ms: print<mp_units::quantity_point<struct hw_voltage_unit{{{{}, {}}}}, s... (1 times, avg 4503 ms)
  4496 ms: mp_units::get_quantity_spec<mp_units::si::si2019::speed_of_light_in_... (3 times, avg 1498 ms)
  4486 ms: mp_units::detail::get_associated_quantity<mp_units::si::si2019::spee... (3 times, avg 1495 ms)
  4465 ms: mp_units::detail::get_associated_quantity_impl<mp_units::si::si2019:... (3 times, avg 1488 ms)
  4397 ms: kalman::system_state_estimate<mp_units::quantity_point<reference<Cel... (3 times, avg 1465 ms)
  4391 ms: std::__1::format<const kalman::system_state<mp_units::quantity_point... (3 times, avg 1463 ms)
  4365 ms: std::__1::make_format_args<std::__1::basic_format_context<std::__1::... (3 times, avg 1455 ms)
  4364 ms: std::__format_arg_store<std::__1::basic_format_context<std::__1::bac... (3 times, avg 1454 ms)
  4361 ms: std::__format::__create_packed_storage<std::__1::basic_format_contex... (3 times, avg 1453 ms)
  4337 ms: mp_units::detail::determine_associated_quantity<mp_units::si::si2019... (3 times, avg 1445 ms)
  4091 ms: mp_units::detail::determine_associated_quantity_impl<mp_units::si::s... (3 times, avg 1363 ms)
  3956 ms: std::__format::__create_format_arg<std::__1::basic_format_context<st... (3 times, avg 1318 ms)
  3939 ms: mp_units::detail::expr_map<mp_units::detail::to_quantity_spec, mp_un... (3 times, avg 1313 ms)
  3783 ms: mp_units::pow<2L, 1L, mp_units::isq::Celsius_temperature> (3 times, avg 1261 ms)
  3641 ms: fmt_line<struct mechanical_horsepower{{{{}, {{}}}}}, kilo_<decltype(... (1 times, avg 3641 ms)
  3629 ms: print_header<kalman::system_state<mp_units::quantity_point<reference... (2 times, avg 1814 ms)
  3615 ms: mp_units::detail::expr_pow<2L, 1L, mp_units::derived_quantity_spec, ... (3 times, avg 1205 ms)
  3594 ms: mp_units::derived_quantity_spec<mp_units::power<mp_units::isq::Celsi... (3 times, avg 1198 ms)

**** Template sets that took longest to instantiate:
 39159 ms: std::__1::format<$> (98 times, avg 399 ms)
 37990 ms: mp_units::detail::convertible<$> (383 times, avg 99 ms)
 37642 ms: std::__1::make_format_args<$> (151 times, avg 249 ms)
 37486 ms: std::__format_arg_store<$>::__format_arg_store (143 times, avg 262 ms)
 37353 ms: std::__format::__create_packed_storage<$> (143 times, avg 261 ms)
 37023 ms: mp_units::detail::_multiply_impl<$> (539 times, avg 68 ms)
 37008 ms: std::__format::__create_format_arg<$> (244 times, avg 151 ms)
 36742 ms: mp_units::detail::convertible_impl<$> (334 times, avg 110 ms)
 34863 ms: mp_units::magnitude<$> (1247 times, avg 27 ms)
 33572 ms: mp_units::detail::sudo_cast<$> (223 times, avg 150 ms)
 31888 ms: mp_units::convertible<$> (144 times, avg 221 ms)
 30777 ms: mp_units::get_canonical_unit<$> (141 times, avg 218 ms)
 30690 ms: mp_units::detail::get_canonical_unit_result<$> (140 times, avg 219 ms)
 30257 ms: mp_units::detail::get_canonical_unit_impl<$> (134 times, avg 225 ms)
 27218 ms: std::__1::formatter<$>::format_quantity<$> (432 times, avg 63 ms)
 26829 ms: std::__1::basic_format_string<$>::basic_format_string<$> (116 times, avg 231 ms)
 25609 ms: mp_units::quantity<$>::quantity<$> (188 times, avg 136 ms)
 23385 ms: mp_units::explicitly_convertible<$> (82 times, avg 285 ms)
 23229 ms: std::__basic_format_arg_value<$>::__handle::__handle<$> (328 times, avg 70 ms)
 23095 ms: std::__1::formatter<$>::format<$> (392 times, avg 58 ms)
 23087 ms: mp_units::detail::expr_map<$> (1028 times, avg 22 ms)
 21725 ms: mp_units::detail::get_optimized_expression<$> (886 times, avg 24 ms)
 20929 ms: mp_units::detail::expr_map_impl<$> (1025 times, avg 20 ms)
 20223 ms: mp_units::detail::expr_divide<$> (662 times, avg 30 ms)
 19566 ms: mp_units::quantity<$>::in<$> (86 times, avg 227 ms)
 19439 ms: mp_units::derived_quantity_spec<$> (711 times, avg 27 ms)
 19375 ms: mp_units::detail::derived_quantity_spec_impl<$> (711 times, avg 27 ms)
 19208 ms: print_header<$> (8 times, avg 2401 ms)
 16845 ms: mp_units::get_quantity_spec<$> (347 times, avg 48 ms)
 16631 ms: mp_units::detail::get_associated_quantity<$> (336 times, avg 49 ms)

**** Functions that took longest to compile:
   339 ms: main (/home/mpusz/repos/units.worktrees/master/example/glide_computer.cpp)
   259 ms: _ZNSt3__111__formatter23__format_floating_pointB8ne180100ITkNS_14flo... (/home/mpusz/repos/units.worktrees/master/example/clcpp_response.cpp)
   241 ms: std::__1::back_insert_iterator<std::__1::__format::__output_buffer<c... (/home/mpusz/repos/units.worktrees/master/example/clcpp_response.cpp)
   203 ms: std::__1::back_insert_iterator<std::__1::__format::__output_buffer<c... (/home/mpusz/repos/units.worktrees/master/example/kalman_filter/kalman_filter-example_3.cpp)
   178 ms: std::__1::back_insert_iterator<std::__1::__format::__output_buffer<c... (/home/mpusz/repos/units.worktrees/master/example/kalman_filter/kalman_filter-example_1.cpp)
   160 ms: _ZNSt3__111__formatter23__format_floating_pointB8ne180100ITkNS_14flo... (/home/mpusz/repos/units.worktrees/master/example/foot_pound_second.cpp)
   158 ms: std::__1::back_insert_iterator<std::__1::__format::__output_buffer<c... (/home/mpusz/repos/units.worktrees/master/example/foot_pound_second.cpp)
   143 ms: _ZNSt3__111__formatter23__format_floating_pointB8ne180100ITkNS_14flo... (/home/mpusz/repos/units.worktrees/master/example/clcpp_response.cpp)
   139 ms: _ZNSt3__111__formatter23__format_floating_pointB8ne180100ITkNS_14flo... (/home/mpusz/repos/units.worktrees/master/example/clcpp_response.cpp)
   134 ms: std::__1::back_insert_iterator<std::__1::__format::__output_buffer<c... (/home/mpusz/repos/units.worktrees/master/example/hw_voltage.cpp)
   134 ms: std::__1::back_insert_iterator<std::__1::__format::__output_buffer<c... (/home/mpusz/repos/units.worktrees/master/example/clcpp_response.cpp)
   123 ms: _ZNSt3__19formatterIN8mp_unitsW8mp_unitsW4core8quantityIXtlNS1_S3_9r... (/home/mpusz/repos/units.worktrees/master/example/kalman_filter/kalman_filter-example_2.cpp)
   118 ms: main (/home/mpusz/repos/units.worktrees/master/example/measurement.cpp)
   116 ms: std::__1::__formatter::__float_result std::__1::__formatter::__forma... (/home/mpusz/repos/units.worktrees/master/example/clcpp_response.cpp)
   116 ms: std::__1::__formatter::__float_result std::__1::__formatter::__forma... (/home/mpusz/repos/units.worktrees/master/example/clcpp_response.cpp)
   115 ms: _ZNSt3__111__formatter23__format_floating_pointB8ne180100ITkNS_14flo... (/home/mpusz/repos/units.worktrees/master/example/kalman_filter/kalman_filter-example_1.cpp)
   112 ms: _ZNSt3__111__formatter23__format_floating_pointB8ne180100ITkNS_14flo... (/home/mpusz/repos/units.worktrees/master/example/foot_pound_second.cpp)
   111 ms: std::__1::back_insert_iterator<std::__1::__format::__output_buffer<c... (/home/mpusz/repos/units.worktrees/master/example/kalman_filter/kalman_filter-example_3.cpp)
   111 ms: _ZNSt3__111__formatter32__write_using_decimal_separatorsB8ne180100IN... (/home/mpusz/repos/units.worktrees/master/example/glide_computer_lib/glide_computer_lib.cpp)
   111 ms: _ZNSt3__111__formatter23__format_floating_pointB8ne180100ITkNS_14flo... (/home/mpusz/repos/units.worktrees/master/example/kalman_filter/kalman_filter-example_3.cpp)
   108 ms: std::__1::back_insert_iterator<std::__1::__format::__output_buffer<c... (/home/mpusz/repos/units.worktrees/master/example/hello_units.cpp)
   108 ms: _ZNSt3__111__formatter23__format_floating_pointB8ne180100ITkNS_14flo... (/home/mpusz/repos/units.worktrees/master/example/hw_voltage.cpp)
   108 ms: _ZNSt3__19formatterIN8mp_unitsW8mp_unitsW4core8quantityIXtlNS1_S3_9r... (/home/mpusz/repos/units.worktrees/master/example/glide_computer.cpp)
   107 ms: _ZNKSt3__19formatterIN8mp_unitsW8mp_unitsW4core8quantityIXtlNS1_S3_9... (/home/mpusz/repos/units.worktrees/master/example/glide_computer.cpp)
   104 ms: std::__1::back_insert_iterator<std::__1::__format::__output_buffer<c... (/home/mpusz/repos/units.worktrees/master/example/glide_computer.cpp)
   104 ms: std::__1::back_insert_iterator<std::__1::__format::__output_buffer<c... (/home/mpusz/repos/units.worktrees/master/example/foot_pound_second.cpp)
   104 ms: _ZNSt3__19formatterIN8mp_unitsW8mp_unitsW4core8quantityIXtlNS1_S3_9r... (/home/mpusz/repos/units.worktrees/master/example/kalman_filter/kalman_filter-example_2.cpp)
   103 ms: _ZNSt3__19formatterIN8mp_unitsW8mp_unitsW4core8quantityIXtlNS1_S3_9r... (/home/mpusz/repos/units.worktrees/master/example/foot_pound_second.cpp)
   103 ms: _ZNSt3__111__formatter23__format_floating_pointB8ne180100ITkNS_14flo... (/home/mpusz/repos/units.worktrees/master/example/glide_computer.cpp)
   102 ms: std::__1::back_insert_iterator<std::__1::__format::__output_buffer<c... (/home/mpusz/repos/units.worktrees/master/example/kalman_filter/kalman_filter-example_5.cpp)

**** Function sets that took longest to compile / optimize:
  3671 ms: std::__1::back_insert_iterator<$> std::__1::__formatter::__format_lo... (38 times, avg 96 ms)
  1110 ms: std::__1::__wrap_iter<$> std::__1::basic_string<$>::__insert_with_si... (19 times, avg 58 ms)
   952 ms: std::__1::__formatter::__float_result std::__1::__formatter::__forma... (19 times, avg 50 ms)
   913 ms: std::__1::__formatter::__float_result std::__1::__formatter::__forma... (19 times, avg 48 ms)
   836 ms: std::__1::__formatter::__float_result std::__1::__formatter::__forma... (19 times, avg 44 ms)
   343 ms: std::__1::basic_format_parse_context<$>::iterator std::__1::__format... (19 times, avg 18 ms)
   339 ms: std::__1::basic_format_context<$>::iterator std::__1::formatter<$>::... (19 times, avg 17 ms)
   337 ms: std::__1::to_chars_result std::__1::__to_chars_integral[abi:ne180100... (19 times, avg 17 ms)
   332 ms: std::__1::__unicode::__extended_grapheme_cluster_view<$>::__get_brea... (19 times, avg 17 ms)
   308 ms: std::__1::__formatter::__float_result std::__1::__formatter::__forma... (19 times, avg 16 ms)
   294 ms: std::__1::basic_ostream<$>& std::__1::__put_character_sequence[abi:n... (25 times, avg 11 ms)
   286 ms: std::__1::__unicode::__code_point_view<$>::__consume[abi:ne180100]() (19 times, avg 15 ms)
   281 ms: std::__1::__formatter::__float_result std::__1::__formatter::__forma... (19 times, avg 14 ms)
   257 ms: std::__1::__format_spec::__parsed_specifications<$> std::__1::__form... (19 times, avg 13 ms)
   255 ms: std::__1::__formatter::__float_result std::__1::__formatter::__forma... (19 times, avg 13 ms)
   250 ms: void std::__1::__formatter::__escape[abi:ne180100]<$>(std::__1::basi... (19 times, avg 13 ms)
   247 ms: std::__1::to_chars_result std::__1::__to_chars_itoa[abi:ne180100]<$>... (19 times, avg 13 ms)
   244 ms: std::__1::basic_format_context<$>::iterator std::__1::__formatter_st... (19 times, avg 12 ms)
   233 ms: std::__1::to_chars_result std::__1::__to_chars_integral[abi:ne180100... (19 times, avg 12 ms)
   221 ms: bool std::__1::__formatter::__is_escaped_sequence_written[abi:ne1801... (19 times, avg 11 ms)
   220 ms: std::__1::ostreambuf_iterator<$> std::__1::__pad_and_output[abi:ne18... (25 times, avg 8 ms)
   200 ms: std::__1::__format_spec::__parser<$>::__validate[abi:ne180100](std::... (19 times, avg 10 ms)
   189 ms: std::__1::basic_format_context<$>::iterator std::__1::__formatter::_... (19 times, avg 9 ms)
   183 ms: std::__1::to_chars_result std::__1::__to_chars_integral[abi:ne180100... (19 times, avg 9 ms)
   176 ms: int std::__1::__to_chars_integral_width[abi:ne180100]<$>(unsigned __... (19 times, avg 9 ms)
   176 ms: decltype(auto) std::__1::__visit_format_arg[abi:ne180100]<$>(std::__... (19 times, avg 9 ms)
   172 ms: void std::__1::__formatter::__write_well_formed_escaped_code_unit[ab... (19 times, avg 9 ms)
   164 ms: std::__1::basic_format_context<$>::iterator std::__1::__format::__vf... (19 times, avg 8 ms)
   143 ms: std::__1::back_insert_iterator<$> std::__1::__formatter::__format_fl... (19 times, avg 7 ms)
   130 ms: int std::__1::__to_chars_integral_width[abi:ne180100]<$>(unsigned lo... (19 times, avg 6 ms)

**** Expensive headers:
36475 ms: /home/mpusz/repos/units.worktrees/master/example/kalman_filter/kalman.h (included 8 times, avg 4559 ms), included via:
  8x: <direct include>

15640 ms: /home/mpusz/repos/units.worktrees/master/src/systems/include/mp-units/systems/iec.h (included 1 times, avg 15640 ms), included via:
  1x: <direct include>

11498 ms: /home/mpusz/repos/units.worktrees/master/example/glide_computer_lib/include/glide_computer_lib.h (included 2 times, avg 5749 ms), included via:
  2x: <direct include>

9018 ms: /home/mpusz/repos/units.worktrees/master/example/include/geographic.h (included 3 times, avg 3006 ms), included via:
  2x: <direct include>
  1x: glide_computer_lib.h 

8639 ms: /home/mpusz/repos/units.worktrees/master/src/systems/include/mp-units/systems/hep.h (included 1 times, avg 8639 ms), included via:
  1x: <direct include>

4541 ms: /usr/lib/llvm-18/include/c++/v1/chrono (included 1 times, avg 4541 ms), included via:
  1x: <direct include>

3248 ms: /home/mpusz/repos/units.worktrees/master/src/systems/include/mp-units/systems/cgs.h (included 1 times, avg 3248 ms), included via:
  1x: <direct include>

1857 ms: /home/mpusz/repos/units.worktrees/master/src/systems/include/mp-units/systems/imperial.h (included 1 times, avg 1857 ms), included via:
  1x: <direct include>

1833 ms: /home/mpusz/repos/units.worktrees/master/src/systems/include/mp-units/systems/isq.h (included 1 times, avg 1833 ms), included via:
  1x: <direct include>

1622 ms: /home/mpusz/repos/units.worktrees/master/src/systems/include/mp-units/systems/iau.h (included 1 times, avg 1622 ms), included via:
  1x: <direct include>

  done in 0.2s.

Everyone is welcome to contribute changes or share ideas on possible improvements.

@mpusz mpusz added help wanted Extra attention is needed good first issue Good for newcomers refactor Modify existing code potentially causing breaking changes labels Nov 16, 2024
@mpusz
Copy link
Owner Author

mpusz commented Nov 17, 2024

Everything that is yellow below is the _multiply_impl on magnitudes:

image

@mpusz
Copy link
Owner Author

mpusz commented Nov 17, 2024

expr_map gets the expression template of one abstraction and maps it to another. To get from one type list to a second type list, it uses C++ operators. Maybe it is possible to implement it directly on typelists?

Everything yellow below is expr_map:

image

@mpusz
Copy link
Owner Author

mpusz commented Nov 17, 2024

The same as above applies to are_ingredients_convertible:

image

@mpusz
Copy link
Owner Author

mpusz commented Nov 17, 2024

And again, the same for explode:

image

@mpusz
Copy link
Owner Author

mpusz commented Nov 17, 2024

Also, a similar pattern can be found in some overloads of get_canonical_unit.

Based on the above, it seems that if we can somehow find out how we can improve the process of multiplying (potentially transformed) elements from type lists directly on the type lists, we could save many seconds during compilation.

@mpusz
Copy link
Owner Author

mpusz commented Nov 17, 2024

Resolving #610 may also help here for newer compilers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed refactor Modify existing code potentially causing breaking changes
Projects
None yet
Development

No branches or pull requests

1 participant