serialization performance improvements#361
serialization performance improvements#361reicheratwork wants to merge 3 commits intoeclipse-cyclonedds:masterfrom
Conversation
797af1d to
de4843d
Compare
|
Tested on my Ubuntu 18.04 in VirtualBox( 6 cores of Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz, 12G/32G RAM): |
@tez1szh Sorry to hear that these changes did not result in the performance gains we had hoped for. All changes were made by running the throughput example in valgrind with the callgrind option set, and then examining the points in the serialization functions which were of most influence on the performance I will have a further look at this |
Removed the completeness checks on structs being written, as this is nonsensical for writing, as the compiler will ensure that all members that are mandatory (such as key members) are present in the struct passed for writing For the reading step, this validation will still need to be done as the data here does not originate from the structs being read into Signed-off-by: Martijn Reicher <martijn.reicher@zettascale.tech>
Because std::vector::resize adds an unnecessary initialization step this performs worse than using assign Signed-off-by: Martijn Reicher <martijn.reicher@zettascale.tech>
In read operations, the completeness checking can be skipped for final extensibility structs Signed-off-by: Martijn Reicher <martijn.reicher@zettascale.tech>
de4843d to
1c27b67
Compare
|
Did some rebasing and reorganising of the commits, I think it is ready for review now. |
eboasson
left a comment
There was a problem hiding this comment.
It makes sense to me, but I do have a few questions, likely out of ignorance ...
| * Depending on the implementation and mode header length fields may be completed. | ||
| * This function can be overridden in cdr streaming implementations. | ||
| * | ||
| * @param[in] props Properties of the member to finish. |
There was a problem hiding this comment.
So presumably the _unchecked refers to it not outputting a set of members that were completed successfully (the member_ids) in the original one. I presume that for both functions the return value is false iff some failure occurred, and that the nice bit of the non-unchecked version is that you get more detailed information on what actually happened.
Ok, that makes sense.
What I do wonder is if it would not make more sense to overload them? If the only difference is getting some additional information out, then it seems like that would more elegant and introduce less risk of head-scratching.
Would you agree?
There was a problem hiding this comment.
The _unchecked versions of the finish_member and finish_struct functions do not check the member or struct for completeness (whether all members are present) when doing a streaming operation.
These functions do the streaming steps when finishing a struct or a member, like reading/inserting headers etc.
The check for completeness is not necessary, unless reading a non-final extensibility struct, since there we have no control over the set of members present.
This check uses std::set as a container of the member ids that were read, and this was a significant performance drain, and therefore was split out for those datatype+streaming operation combinations that needed it.
Overloading is indeed an option, i will look in to this, this should also simplify the code generator.
Don't know why I overlooked this when writing this, probably went into this with a little too much C code attitude.
| * | ||
| * @return Whether the struct is complete and correct. | ||
| */ | ||
| virtual bool finish_struct_unchecked(const entity_properties_t &props) {(void)props; return true;} |
There was a problem hiding this comment.
Similar reasoning to the finish_member_unchecked applies here (perhaps there are other places as well, I won't repeat this if there are, that'd be silly).
I am cool with being wrong, mind 🙂
There was a problem hiding this comment.
Yep, the explanation is included in the previous comment.
| return cdr_stream::start_member(prop, is_set); | ||
| } | ||
|
|
||
| bool xcdr_v1_stream::finish_member(const entity_properties_t &prop, member_id_set &member_ids, bool is_set) |
There was a problem hiding this comment.
Am I correct that finish_member is no longer needed because cdr_stream::finish_member takes care of it?
There was a problem hiding this comment.
Yes, the functionality which was duplicated here is now absorbed into the base class's version of the function.
| return move_final_list_entry(); | ||
| break; | ||
| case stream_mode::read: | ||
| return check_struct_completeness(props, member_ids); |
There was a problem hiding this comment.
I can't yet figure out how check_struct_completeness role is now being fulfilled (also applies to xcdr_v2_stream, obviously).
These improvements could solve part of issue #358
Further performance improvements by:
Expanding the buffer in place while writing
Not checking the completeness of the written struct (as it is already complete as far as we know)
@wjbbupt : could you give this a look?