Skip to content

Commit

Permalink
Reduce builtin endpoints memory consumption (#918)
Browse files Browse the repository at this point in the history
* Refs #6971. Reducing default builtin history size.

* Refs #6971. Default memory policy to preallocated with realloc.

* Refs #6971. EDP listeners: remove change from history before releasing lock.

* Refs #6971. Reducing EDP readers history.

* Refs #6971. WLP not creating secure endpoint when not necessary.

* Refs #6971. Improving WLP history.

* Refs #6971. Correctly setting DATA(p) serialized size.

* Refs #6971. Taking sentinel into account.

* Refs #6971. Fixed comparison on addParameterSentinel.

* Refs #6971. Fixed WLP destructor.

* Refs #6971. Uncrustify EDPSimple and children.

* Refs #6971. Joining common code serializing a WriterProxyData.

* Refs #6971. Templating for both proxy datas.

* Refs #6971. Use templated code for ReaderProxyData.

* Refs #6971. Adding basic get_serialized_size() methods.

* Refs #6971. Parameter_t::addToCDRMessage made const.

* Refs #6971. Added method cdr_serialized_size() to Parameter_t

* Refs #6971. Updating ParticipantProxyData

* Refs #6971. ReaderProxyData calculating serialization size.

* Refs #6971. WriterProxyData calculating serialization size.

* Refs #6971. Fixing mocks.

* Refs #6971. Fixing warnings.

* Refs #7035. Adressing review comments.

* Refs #7035. Fixing EDP listeners.
  • Loading branch information
MiguelCompany authored Feb 12, 2020
1 parent 4134783 commit d1d7605
Show file tree
Hide file tree
Showing 26 changed files with 1,047 additions and 589 deletions.
83 changes: 57 additions & 26 deletions include/fastrtps/qos/ParameterTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,18 @@ class Parameter_t
(this->length == b.length);
}

virtual uint32_t cdr_serialized_size() const
{
return 4 + length;
}

/**
* Virtual method used to add the parameter to a CDRMessage_t message.
* @param[in,out] msg Pointer to the message where the parameter should be added.
* @return True if the parameter was correctly added.
*/
RTPS_DllAPI virtual bool addToCDRMessage(
rtps::CDRMessage_t* msg) = 0;
rtps::CDRMessage_t* msg) const = 0;

/**
* Virtual method used to get the parameter from a CDRMessage_t message.
Expand Down Expand Up @@ -209,7 +214,7 @@ class ParameterKey_t : public Parameter_t
ParameterKey_t(
ParameterId_t pid,
uint16_t in_length,
rtps::InstanceHandle_t& ke)
const rtps::InstanceHandle_t& ke)
: Parameter_t(pid, in_length)
, key(ke)
{
Expand All @@ -221,7 +226,7 @@ class ParameterKey_t : public Parameter_t
* @return True if the parameter was correctly added.
*/
bool addToCDRMessage(
rtps::CDRMessage_t* msg) override;
rtps::CDRMessage_t* msg) const override;

/**
* Read the parameter from a CDRMessage_t message.
Expand Down Expand Up @@ -276,7 +281,7 @@ class ParameterLocator_t : public Parameter_t
* @return True if the parameter was correctly added.
*/
bool addToCDRMessage(
rtps::CDRMessage_t* msg) override;
rtps::CDRMessage_t* msg) const override;

/**
* Read the parameter from a CDRMessage_t message.
Expand Down Expand Up @@ -329,7 +334,7 @@ class ParameterString_t : public Parameter_t
* @return True if the parameter was correctly added.
*/
bool addToCDRMessage(
rtps::CDRMessage_t* msg) override;
rtps::CDRMessage_t* msg) const override;

/**
* Read the parameter from a CDRMessage_t message.
Expand All @@ -351,6 +356,14 @@ class ParameterString_t : public Parameter_t
m_string = name;
}

virtual uint32_t cdr_serialized_size() const override
{
return cdr_serialized_size(m_string);
}

static uint32_t cdr_serialized_size(
const string_255& str);

private:

string_255 m_string;
Expand Down Expand Up @@ -397,7 +410,7 @@ class ParameterPort_t : public Parameter_t
* @return True if the parameter was correctly added.
*/
bool addToCDRMessage(
rtps::CDRMessage_t* msg) override;
rtps::CDRMessage_t* msg) const override;

/**
* Read the parameter from a CDRMessage_t message.
Expand Down Expand Up @@ -439,7 +452,7 @@ class ParameterGuid_t : public Parameter_t
ParameterGuid_t(
ParameterId_t pid,
uint16_t in_length,
rtps::GUID_t guidin)
const rtps::GUID_t& guidin)
: Parameter_t(pid, in_length)
, guid(guidin)
{
Expand All @@ -448,7 +461,7 @@ class ParameterGuid_t : public Parameter_t
ParameterGuid_t(
ParameterId_t pid,
uint16_t in_length,
rtps::InstanceHandle_t& iH)
const rtps::InstanceHandle_t& iH)
: Parameter_t(pid, in_length)
{
for (uint8_t i = 0; i < 16; ++i)
Expand All @@ -470,7 +483,7 @@ class ParameterGuid_t : public Parameter_t
* @return True if the parameter was correctly added.
*/
bool addToCDRMessage(
rtps::CDRMessage_t* msg) override;
rtps::CDRMessage_t* msg) const override;

/**
* Read the parameter from a CDRMessage_t message.
Expand Down Expand Up @@ -517,7 +530,7 @@ class ParameterProtocolVersion_t : public Parameter_t
* @return True if the parameter was correctly added.
*/
bool addToCDRMessage(
rtps::CDRMessage_t* msg) override;
rtps::CDRMessage_t* msg) const override;

/**
* Read the parameter from a CDRMessage_t message.
Expand Down Expand Up @@ -564,7 +577,7 @@ class ParameterVendorId_t : public Parameter_t
* @return True if the parameter was correctly added.
*/
bool addToCDRMessage(
rtps::CDRMessage_t* msg) override;
rtps::CDRMessage_t* msg) const override;

/**
* Read the parameter from a CDRMessage_t message.
Expand Down Expand Up @@ -611,7 +624,7 @@ class ParameterIP4Address_t : public Parameter_t
* @return True if the parameter was correctly added.
*/
bool addToCDRMessage(
rtps::CDRMessage_t* msg) override;
rtps::CDRMessage_t* msg) const override;

/**
* Read the parameter from a CDRMessage_t message.
Expand Down Expand Up @@ -672,7 +685,7 @@ class ParameterBool_t : public Parameter_t
* @return True if the parameter was correctly added.
*/
bool addToCDRMessage(
rtps::CDRMessage_t* msg) override;
rtps::CDRMessage_t* msg) const override;

/**
* Read the parameter from a CDRMessage_t message.
Expand Down Expand Up @@ -728,7 +741,7 @@ class ParameterStatusInfo_t : public Parameter_t
* @return True if the parameter was correctly added.
*/
bool addToCDRMessage(
rtps::CDRMessage_t* msg) override;
rtps::CDRMessage_t* msg) const override;

/**
* Read the parameter from a CDRMessage_t message.
Expand Down Expand Up @@ -775,7 +788,7 @@ class ParameterCount_t : public Parameter_t
* @return True if the parameter was correctly added.
*/
bool addToCDRMessage(
rtps::CDRMessage_t* msg) override;
rtps::CDRMessage_t* msg) const override;

/**
* Read the parameter from a CDRMessage_t message.
Expand Down Expand Up @@ -822,7 +835,7 @@ class ParameterEntityId_t : public Parameter_t
* @return True if the parameter was correctly added.
*/
bool addToCDRMessage(
rtps::CDRMessage_t* msg) override;
rtps::CDRMessage_t* msg) const override;

/**
* Read the parameter from a CDRMessage_t message.
Expand Down Expand Up @@ -867,7 +880,7 @@ class ParameterTime_t : public Parameter_t
* @return True if the parameter was correctly added.
*/
bool addToCDRMessage(
rtps::CDRMessage_t* msg) override;
rtps::CDRMessage_t* msg) const override;

/**
* Read the parameter from a CDRMessage_t message.
Expand Down Expand Up @@ -914,7 +927,7 @@ class ParameterBuiltinEndpointSet_t : public Parameter_t
* @return True if the parameter was correctly added.
*/
bool addToCDRMessage(
rtps::CDRMessage_t* msg) override;
rtps::CDRMessage_t* msg) const override;

/**
* Read the parameter from a CDRMessage_t message.
Expand Down Expand Up @@ -1333,7 +1346,7 @@ class ParameterPropertyList_t : public Parameter_t
* @return True if the parameter was correctly added.
*/
bool addToCDRMessage(
rtps::CDRMessage_t* msg) override;
rtps::CDRMessage_t* msg) const override;

/**
* Read the parameter from a CDRMessage_t message.
Expand All @@ -1345,6 +1358,14 @@ class ParameterPropertyList_t : public Parameter_t
rtps::CDRMessage_t* msg,
uint16_t size) override;

virtual uint32_t cdr_serialized_size() const override
{
return cdr_serialized_size(*this);
}

static uint32_t cdr_serialized_size(
const ParameterPropertyList_t& data);

protected:

void push_back_helper (
Expand Down Expand Up @@ -1403,7 +1424,7 @@ class ParameterSampleIdentity_t : public Parameter_t
* @return True if the parameter was correctly added.
*/
bool addToCDRMessage(
rtps::CDRMessage_t* msg) override;
rtps::CDRMessage_t* msg) const override;

/**
* Read the parameter from a CDRMessage_t message.
Expand Down Expand Up @@ -1449,7 +1470,7 @@ class ParameterToken_t : public Parameter_t
* @return True if the parameter was correctly added.
*/
bool addToCDRMessage(
rtps::CDRMessage_t* msg) override;
rtps::CDRMessage_t* msg) const override;

/**
* Read the parameter from a CDRMessage_t message.
Expand All @@ -1460,8 +1481,18 @@ class ParameterToken_t : public Parameter_t
bool readFromCDRMessage(
rtps::CDRMessage_t* msg,
uint16_t size) override;

virtual uint32_t cdr_serialized_size() const override
{
return cdr_serialized_size(token);
}

static uint32_t cdr_serialized_size(
const rtps::Token& data);
};

#define PARAMETER_PARTICIPANT_SECURITY_INFO_LENGTH 8

class ParameterParticipantSecurityInfo_t : public Parameter_t
{
public:
Expand All @@ -1470,7 +1501,7 @@ class ParameterParticipantSecurityInfo_t : public Parameter_t
rtps::security::PluginParticipantSecurityAttributesMask plugin_security_attributes;

ParameterParticipantSecurityInfo_t()
: Parameter_t(PID_PARTICIPANT_SECURITY_INFO, 0)
: Parameter_t(PID_PARTICIPANT_SECURITY_INFO, PARAMETER_PARTICIPANT_SECURITY_INFO_LENGTH)
{
}

Expand All @@ -1492,7 +1523,7 @@ class ParameterParticipantSecurityInfo_t : public Parameter_t
* @return True if the parameter was correctly added.
*/
bool addToCDRMessage(
rtps::CDRMessage_t* msg) override;
rtps::CDRMessage_t* msg) const override;

/**
* Read the parameter from a CDRMessage_t message.
Expand All @@ -1505,7 +1536,7 @@ class ParameterParticipantSecurityInfo_t : public Parameter_t
uint16_t size) override;
};

#define PARAMETER_PARTICIPANT_SECURITY_INFO_LENGTH 8
#define PARAMETER_ENDPOINT_SECURITY_INFO_LENGTH 8

class ParameterEndpointSecurityInfo_t : public Parameter_t
{
Expand All @@ -1515,7 +1546,7 @@ class ParameterEndpointSecurityInfo_t : public Parameter_t
rtps::security::PluginEndpointSecurityAttributesMask plugin_security_attributes;

ParameterEndpointSecurityInfo_t()
: Parameter_t(PID_ENDPOINT_SECURITY_INFO, 0)
: Parameter_t(PID_ENDPOINT_SECURITY_INFO, PARAMETER_ENDPOINT_SECURITY_INFO_LENGTH)
{
}

Expand All @@ -1537,7 +1568,7 @@ class ParameterEndpointSecurityInfo_t : public Parameter_t
* @return True if the parameter was correctly added.
*/
bool addToCDRMessage(
rtps::CDRMessage_t* msg) override;
rtps::CDRMessage_t* msg) const override;

/**
* Read the parameter from a CDRMessage_t message.
Expand Down
Loading

0 comments on commit d1d7605

Please sign in to comment.