Skip to content

Commit

Permalink
Insert software prefetches into proto parsing functions. This improve…
Browse files Browse the repository at this point in the history
…s performance when hardware prefetchers are disabled on AMD platforms.

PiperOrigin-RevId: 671461897
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Sep 5, 2024
1 parent 9b019ee commit 8aa0add
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/google/protobuf/generated_message_tctable_lite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ MessageLite* TcParser::AddMessage(const TcParseTableBase* table,
template <typename TagType, bool group_coding, bool aux_is_table>
inline PROTOBUF_ALWAYS_INLINE const char* TcParser::SingularParseMessageAuxImpl(
PROTOBUF_TC_PARAM_DECL) {
PROTOBUF_PREFETCH_WITH_OFFSET(ptr, 192);
PROTOBUF_PREFETCH_WITH_OFFSET(ptr, 256);
if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_NO_DATA_PASS);
}
Expand Down Expand Up @@ -452,6 +454,7 @@ inline PROTOBUF_ALWAYS_INLINE const char* TcParser::RepeatedParseMessageAuxImpl(
if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_NO_DATA_PASS);
}
PROTOBUF_PREFETCH_WITH_OFFSET(ptr, 256);
const auto expected_tag = UnalignedLoad<TagType>(ptr);
const auto aux = *table->field_aux(data.aux_idx());
auto& field = RefAt<RepeatedPtrFieldBase>(msg, data.offset());
Expand Down

0 comments on commit 8aa0add

Please sign in to comment.