Skip to content

Commit

Permalink
Reduce builtin endpoints memory consumption (#1041)
Browse files Browse the repository at this point in the history
* Reduce builtin endpoints memory consumption

This is a port of #918 from 1.9.x

* 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.

* Avoid problems with template method inlining.

This is a port of #1009 from 1.9.x

* Apply review suggestions
  • Loading branch information
MiguelCompany authored Mar 5, 2020
1 parent 26fe712 commit 528bd74
Show file tree
Hide file tree
Showing 26 changed files with 1,089 additions and 576 deletions.
86 changes: 60 additions & 26 deletions include/fastdds/dds/core/policy/ParameterTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,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(
fastrtps::rtps::CDRMessage_t* msg) = 0;
fastrtps::rtps::CDRMessage_t* msg) const = 0;

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

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

/**
* Read the parameter from a CDRMessage_t message.
Expand Down Expand Up @@ -335,7 +340,7 @@ class ParameterString_t : public Parameter_t
* @return True if the parameter was correctly added.
*/
bool addToCDRMessage(
fastrtps::rtps::CDRMessage_t* msg) override;
fastrtps::rtps::CDRMessage_t* msg) const override;
inline const char* getName() const
{
return string_.c_str();
Expand All @@ -357,6 +362,16 @@ class ParameterString_t : public Parameter_t
fastrtps::rtps::CDRMessage_t* msg,
uint16_t size) override;


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

static uint32_t cdr_serialized_size(
const fastrtps::string_255& str);


private:

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

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

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

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

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

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

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

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

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

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

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

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

/**
* Read the parameter from a CDRMessage_t message.
Expand All @@ -1366,6 +1381,14 @@ class ParameterPropertyList_t : public Parameter_t
fastrtps::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 @@ -1423,7 +1446,7 @@ class ParameterSampleIdentity_t : public Parameter_t
* @return True if the parameter was correctly added.
*/
bool addToCDRMessage(
fastrtps::rtps::CDRMessage_t* msg) override;
fastrtps::rtps::CDRMessage_t* msg) const override;

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

/**
* Read the parameter from a CDRMessage_t message.
Expand All @@ -1485,8 +1508,19 @@ class ParameterToken_t : public Parameter_t
fastrtps::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 fastrtps::rtps::Token& data);

};

#define PARAMETER_PARTICIPANT_SECURITY_INFO_LENGTH 8

class ParameterParticipantSecurityInfo_t : public Parameter_t
{
public:
Expand All @@ -1495,7 +1529,7 @@ class ParameterParticipantSecurityInfo_t : public Parameter_t
fastrtps::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 @@ -1517,7 +1551,7 @@ class ParameterParticipantSecurityInfo_t : public Parameter_t
* @return True if the parameter was correctly added.
*/
bool addToCDRMessage(
fastrtps::rtps::CDRMessage_t* msg) override;
fastrtps::rtps::CDRMessage_t* msg) const override;

/**
* Read the parameter from a CDRMessage_t message.
Expand All @@ -1531,7 +1565,7 @@ class ParameterParticipantSecurityInfo_t : public Parameter_t

};

#define PARAMETER_PARTICIPANT_SECURITY_INFO_LENGTH 8
#define PARAMETER_ENDPOINT_SECURITY_INFO_LENGTH 8

class ParameterEndpointSecurityInfo_t : public Parameter_t
{
Expand All @@ -1541,7 +1575,7 @@ class ParameterEndpointSecurityInfo_t : public Parameter_t
fastrtps::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 @@ -1563,7 +1597,7 @@ class ParameterEndpointSecurityInfo_t : public Parameter_t
* @return True if the parameter was correctly added.
*/
bool addToCDRMessage(
fastrtps::rtps::CDRMessage_t* msg) override;
fastrtps::rtps::CDRMessage_t* msg) const override;

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

0 comments on commit 528bd74

Please sign in to comment.