Skip to content

Commit

Permalink
remove the inclusion of the all-encompassing Types.hpp header in Task…
Browse files Browse the repository at this point in the history
…Base.hpp

This saves both CPU time and memory during the build. On
control/orogen/auv_control, which only imports the 'base' typekit,
we save on my (very old Core 2 Duo) machine 1min 20s and 250M of
memory (benchmark done with -j1). On -j4, this would mean roughly
1G of memory.

In addition, it avoids unnecessarily rebuilding task files. The
Types.hpp headers include all types of a typekit, as well as the
imported typekits, which means that we currently MUST rebuild all
task files as soon as a single header is modified in e.g. base/types.

BACKWARD INCOMPATIBILITY: since a lot less headers are included, the user-facing
code in Task.cpp / Task.hpp cannot assume that all types are available
anymore. This does include typedefs that are used in the orogen file.
All types must be manually included in Task.hpp. For instance,
as base::commands::Joints is a typedef, one would need to include
base/commands/Joints.hpp explicitly even if there is a port of type
base::commands::Joints on the task. I personally think that it is
worth it.

RAW DATA

Command being timed: "make -C build/tasks"

Without this commit:
  User time (seconds): 249.27
  System time (seconds): 16.02
  Percent of CPU this job got: 99%
  Elapsed (wall clock) time (h:mm:ss or m:ss): 4:27.81
  Maximum resident set size (kbytes): 893588

With the patch:
  User time (seconds): 176.46
  System time (seconds): 12.16
  Percent of CPU this job got: 99%
  Elapsed (wall clock) time (h:mm:ss or m:ss): 3:09.72
  Maximum resident set size (kbytes): 640356
  • Loading branch information
doudou committed Oct 7, 2014
1 parent 728c4cd commit c956ee2
Showing 1 changed file with 34 additions and 6 deletions.
40 changes: 34 additions & 6 deletions lib/orogen/templates/tasks/TaskBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#ifndef <%= project.name.upcase %>_<%= task.basename.upcase %>_TASK_BASE_HPP
#define <%= project.name.upcase %>_<%= task.basename.upcase %>_TASK_BASE_HPP

<% typekit = project.typekit %>

#include <string>
#include <boost/cstdint.hpp>
#include <<%= task.superclass.header_file %>>
Expand All @@ -16,17 +18,43 @@
#include <<%= project.typekit.name %>/TaskStates.hpp>
<% end %>

<% task.self_properties.sort_by(&:name).each do |p| %>
<% type = p.type %>
<%= typekit.cxx_gen_includes(*typekit.include_for_type(type)) %>
extern template class RTT::Property< <%= type.cxx_name %> >;
<% end %>

<% task.self_attributes.sort_by(&:name).each do |a| %>
<% type = a.type %>
<%= typekit.cxx_gen_includes(*typekit.include_for_type(type)) %>
extern template class RTT::Attribute< <%= type.cxx_name %> >;
<% end %>

<% task.self_ports.sort_by(&:name).each do |p| %>
<% type = p.type %>
<%= typekit.cxx_gen_includes(*typekit.include_for_type(type)) %>
extern template class <%= p.orocos_class %>< <%= type.cxx_name %> >;
extern template class RTT::base::ChannelElement< <%= type.cxx_name %> >;
<% end %>

<% types = task.self_dynamic_ports.
map { |p| [p.orocos_class, p.type] if p.type }.
compact %>
<% types.each do |orocos_class, type| %>
<%= typekit.cxx_gen_includes(*typekit.include_for_type(type)) %>
extern template class <%= orocos_class %>< <%= type.cxx_name %> >;
extern template class RTT::base::ChannelElement< <%= type.cxx_name %> >;
<% end %>

<% task.used_typekits.sort_by(&:name).each do |tk| %>
<% next if tk.virtual? %>
#include <<%= tk.name %>/typekit/Types.hpp>
<% task.self_operations.sort_by(&:name).each do |op| %>
<% op.used_types.each do |type| %>
<%= typekit.cxx_gen_includes(*typekit.include_for_type(type)) %>
<% end %>
<% end %>

<% task.implemented_classes.sort.each do |class_name, include_file| %>
#include <<%= include_file %>> // to get <%= class_name %>
<% end %>
<% if component.typekit %>
#include "<%= component.typekit.name %>/typekit/Types.hpp"
<% end %>

<% code_before, code_after =
task.base_header_code.partition(&:first)
Expand Down

0 comments on commit c956ee2

Please sign in to comment.