Skip to content

Commit 8aa0add

Browse files
Insert software prefetches into proto parsing functions. This improves performance when hardware prefetchers are disabled on AMD platforms.
PiperOrigin-RevId: 671461897
1 parent 9b019ee commit 8aa0add

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/google/protobuf/generated_message_tctable_lite.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,8 @@ MessageLite* TcParser::AddMessage(const TcParseTableBase* table,
369369
template <typename TagType, bool group_coding, bool aux_is_table>
370370
inline PROTOBUF_ALWAYS_INLINE const char* TcParser::SingularParseMessageAuxImpl(
371371
PROTOBUF_TC_PARAM_DECL) {
372+
PROTOBUF_PREFETCH_WITH_OFFSET(ptr, 192);
373+
PROTOBUF_PREFETCH_WITH_OFFSET(ptr, 256);
372374
if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
373375
PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_NO_DATA_PASS);
374376
}
@@ -452,6 +454,7 @@ inline PROTOBUF_ALWAYS_INLINE const char* TcParser::RepeatedParseMessageAuxImpl(
452454
if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) {
453455
PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_NO_DATA_PASS);
454456
}
457+
PROTOBUF_PREFETCH_WITH_OFFSET(ptr, 256);
455458
const auto expected_tag = UnalignedLoad<TagType>(ptr);
456459
const auto aux = *table->field_aux(data.aux_idx());
457460
auto& field = RefAt<RepeatedPtrFieldBase>(msg, data.offset());

0 commit comments

Comments
 (0)